[clang] [BoundsSafety] Support bounds-safety attributes in type positions (PR #179612)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 06:51:00 PST 2026


zmodem wrote:

> Whether `LateParsedAttribute` is in `Parser` or in `DeclSpec`, the fundamental problem is that this creates either an AST → Sema or AST → Parser dependency because `LateParsedAttrType` in AST references `LateParsedTypeAttribute`.

Right, but I think the idea is that the reference to `LateParsedTypeAttribute` should be opaque, since it's referencing state in the parser? The AST library shouldn't need to see through it.

> Currently, some AST code includes `DeclSpec.h` to access `AttrNameLoc` from `LateParsedTypeAttribute`. However, I think I can eliminate this dependency by storing the SourceLocation separately instead of accessing it through `LateParsedTypeAttribute`.
> 
> Would that address your concern about the AST → Sema dependency?

Yes, I think so.

It looks like `ASTContext.cpp` also includes `DeclSpec.h` for `ASTContext::getLateParsedAttrType`, but I don't think that actually needs the definition of `LateParsedTypeAttribute` -- a forward declaration should be enough (and it has one already, via Type.h -> TypeBase.h).

https://github.com/llvm/llvm-project/pull/179612


More information about the cfe-commits mailing list