Skip to content

Reland "[APINotes] Add support for bounds safety annotations" #9942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

hnrklssn
Copy link

@hnrklssn hnrklssn commented Feb 3, 2025

Reverts #9908

@hnrklssn hnrklssn requested a review from a team as a code owner February 3, 2025 18:25
@hnrklssn
Copy link
Author

hnrklssn commented Feb 3, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 3, 2025

@swift-ci please test llvm

5 similar comments
@hnrklssn
Copy link
Author

hnrklssn commented Feb 4, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 4, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 4, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 5, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 5, 2025

@swift-ci please test llvm

These test cases use clang modules. TypeCoupledDeclRefInfo
serialization/deserialization is currently broken on Linux, so disable
these tests until it's been resolved.
@hnrklssn hnrklssn force-pushed the revert-9908-revert-9822-bounds-safety-apinotes branch from 72de84a to 9f4dbbc Compare February 6, 2025 04:08
@hnrklssn
Copy link
Author

hnrklssn commented Feb 6, 2025

@swift-ci please test llvm

@hnrklssn
Copy link
Author

hnrklssn commented Feb 6, 2025

@swift-ci please test

@hnrklssn hnrklssn merged commit 9fbb19c into stable/20240723 Feb 6, 2025
2 of 4 checks passed
@hnrklssn hnrklssn deleted the revert-9908-revert-9822-bounds-safety-apinotes branch February 6, 2025 18:43
delcypher pushed a commit to delcypher/apple-llvm-project that referenced this pull request May 22, 2025
This cherry-picks

```
commit e5e04cd
Author: Henrik G. Olsson <[email protected]>
Date:   Mon Feb 3 10:25:30 2025 -0800

    Revert "Revert "[APINotes] Add support for bounds safety annotations""

    This reverts commit 7cbd1e7.
```

from the `swift/release/6.2` branch (landed in
swiftlang#9942).

Conflicts:
	clang/include/clang/Parse/Parser.h
	clang/include/clang/Sema/Sema.h
	clang/lib/APINotes/APINotesFormat.h

Below is the original commit message.

rdar://151820159

---
[APINotes] Add support for bounds safety annotations

This adds support for annotating function parameters with __counted_by,
__sized_by, __counted_by_or_null, __sized_by_or_null, and __ended_by,
using API notes. The main content of handlePtrCountedByEndedByAttr is
extracted to applyPtrCountedByEndedByAttr and decoupled from ParsedAttr.
The helper function ParseBoundsAttributeArgFromString is added to make
it possible to parse count expressions from SemaAPINotes.

The current implementation of __terminated_by/__null_terminated makes it
harder to extract from the iterative type processing, but since it
doesn't require any extra context to parse the attribute, it can be
applied using the normal Type override instead.

rdar://139830881
delcypher pushed a commit that referenced this pull request May 22, 2025
This cherry-picks

```
commit e5e04cd
Author: Henrik G. Olsson <[email protected]>
Date:   Mon Feb 3 10:25:30 2025 -0800

    Revert "Revert "[APINotes] Add support for bounds safety annotations""

    This reverts commit 7cbd1e7.
```

from the `swift/release/6.2` branch (landed in
#9942).

Conflicts:
	clang/include/clang/Parse/Parser.h
	clang/include/clang/Sema/Sema.h
	clang/lib/APINotes/APINotesFormat.h

Below is the original commit message.

rdar://151820159

---
[APINotes] Add support for bounds safety annotations

This adds support for annotating function parameters with __counted_by,
__sized_by, __counted_by_or_null, __sized_by_or_null, and __ended_by,
using API notes. The main content of handlePtrCountedByEndedByAttr is
extracted to applyPtrCountedByEndedByAttr and decoupled from ParsedAttr.
The helper function ParseBoundsAttributeArgFromString is added to make
it possible to parse count expressions from SemaAPINotes.

The current implementation of __terminated_by/__null_terminated makes it
harder to extract from the iterative type processing, but since it
doesn't require any extra context to parse the attribute, it can be
applied using the normal Type override instead.

rdar://139830881
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