Skip to content

Conversation

patrykstefanski
Copy link

This is an initial part of an analysis of count-attributed assignment groups. This commit adds an AST visitor that is responsible for finding bounds-attributed assignment groups and assignments to bounds-attributed objects (pointers and dependent counts) that are too complex to verify.

As a PoC, this commit adds checks for too complex assignments, which are assignments that are not directly inside of a compound statement (like other assignment groups) and modify the pointer or count in some way. Our model rejects those and requires the user to simplify their code. For example:

  void foo(int *__counted_by(count) p, int count) {
    q = p = ...;
          ^ this is rejected
    n = count = ...;
              ^ this is rejected
    // the following is fine:
    p = ...;
    count = ...;
  }

rdar://161607826

(cherry picked from commit 0227c6f)

Conflicts:
clang/include/clang/Basic/DiagnosticSemaKinds.td

@patrykstefanski
Copy link
Author

@swift-ci test llvm

@patrykstefanski
Copy link
Author

@swift-ci test

…ments

This is an initial part of an analysis of count-attributed assignment
groups. This commit adds an AST visitor that is responsible for finding
bounds-attributed assignment groups and assignments to bounds-attributed
objects (pointers and dependent counts) that are too complex to verify.

As a PoC, this commit adds checks for too complex assignments, which are
assignments that are not directly inside of a compound statement (like
other assignment groups) and modify the pointer or count in some way.
Our model rejects those and requires the user to simplify their code.
For example:

```
  void foo(int *__counted_by(count) p, int count) {
    q = p = ...;
          ^ this is rejected
    n = count = ...;
              ^ this is rejected
    // the following is fine:
    p = ...;
    count = ...;
  }
```

rdar://161607826

(cherry picked from commit 0227c6f)

Conflicts:
	clang/include/clang/Basic/DiagnosticSemaKinds.td
@patrykstefanski patrykstefanski force-pushed the eng/pstefanski/PR-161607826-21.x branch from 4ab9951 to b219222 Compare October 10, 2025 17:31
@patrykstefanski
Copy link
Author

@swift-ci test

@patrykstefanski
Copy link
Author

@swift-ci test llvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant