| Issue |
238453
|
| Summary |
[BoundsSafety] Tracking issue: upstreaming -fbounds-safety
|
| Labels |
clang,
clang:bounds-safety
|
| Assignees |
|
| Reporter |
rapidsna
|
This issue tracks the upstreaming of `-fbounds-safety` to Clang. Bounds annotations are upstreamed first, so that projects can start annotating their code; the full `-fbounds-safety` model follows. Until the model is complete, it is guarded by the experimental `-cc1` flag `-fexperimental-bounds-safety`.
Design: https://clang.llvm.org/docs/BoundsSafety.html
Preview implementation: https://github.com/swiftlang/llvm-project/tree/stable/21.x
Open issues and PRs: label [`clang:bounds-safety`](https://github.com/llvm/llvm-project/issues?q=is%3Aopen+label%3Aclang%3Abounds-safety)
## Bounds annotations
- [x] `__counted_by`, `__sized_by`, `__counted_by_or_null`, `__sized_by_or_null` on struct fields (limits: the count must be a single identifier; handled as declaration attributes rather than type attributes)
- [x] Use by `-fsanitize=array-bounds` and `_FORTIFY_SOURCE=3` (`__builtin_dynamic_object_size`)
- [ ] Bounds annotations as type attributes (draft: #224560)
- [ ] Late parsing as type attributes, for struct fields
- [x] NFC groundwork: #192799, #223267, #224556, #224558, #227774
- [ ] #224559
- [ ] #233583 (draft)
- [ ] `__counted_by` on function parameters, where the count refers to an earlier parameter (drafts: #234941, #234950, #234963, #234981; contributed by Mohammed Ashraf as part of Google Summer of Code)
- [ ] Late parsing of `__counted_by` on function parameters, where the count refers to a later parameter (to be split out of #230538; see also #167365)
- [ ] `__counted_by` on function return types and variables (to be split out of #230538; see also #167365)
- [ ] `__single` (refactoring in progress downstream: swiftlang/llvm-project#13651, swiftlang/llvm-project#13846, swiftlang/llvm-project#13925; contributed by Anupam Kumar)
- [ ] `__ended_by`
- [ ] `__null_terminated` (#230685)
- [ ] `__unsafe_indexable`
- [ ] Complex count expressions (#141827, #229345)
## Full `-fbounds-safety` model
- [ ] Wide pointers (`__bidi_indexable`, `__indexable`) and bounds checks
- [ ] New AST expressions for bounds checks (RFC needed)
- [ ] Cast and operation checks on annotated pointers
- [ ] Implicit (default) bounds annotations
- [ ] Checks on assignments to a pointer and its count in the same scope (RFC needed)
## Roadmap
- Early 2027: bounds annotations are ready for open-source projects to adopt.
- After that: the full `-fbounds-safety` model.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs