[clang] [BoundsSafety][NFC] Add counted_by type-shape validation helper (PR #227774)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 13 11:57:09 PDT 2026
================
@@ -710,6 +710,12 @@ class LangOptions : public LangOptionsBase {
return ConvergentFunctions;
}
+ /// Return true if bounds attributes follow the -fbounds-safety programming
+ /// model. Downstream, which has the full -fbounds-safety implementation, uses
+ /// this predicate to gate behavior that differs from upstream. Remove it once
+ /// that divergence is resolved.
+ bool hasBoundsSafetyAttributes() const { return BoundsSafety; }
----------------
delcypher wrote:
We may want to consider renaming `hasBoundsSafetyAttributes()` (maybe a separate PR) because the name is confusing because `__counted_by` can be used without any kind of `-fbounds-safety` mode.
For now we might want to consider rewording to comments (which I also think are confusing) and also refer to a GitHub issue that tracks upstreaming "-fbounds-safety attribute-only mode".
Suggested rewording:
```
/// Return true if using -fbounds-safety in full or attribute-only mode
bool hasBoundsSafetyAttributes() const {
// TODO: Upstream attribute-only mode (refer to github issue here)
return BoundsSafety;
}
```
https://github.com/llvm/llvm-project/pull/227774
More information about the cfe-commits
mailing list