[clang] [BoundsSafety] Support late parsing for `counted_by` in type positions (PR #166491)
Yeoul Na via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 19 11:46:26 PST 2025
================
@@ -1161,10 +1161,13 @@ class Parser : public CodeCompletionHandler {
IdentifierInfo *MacroII = nullptr;
SourceLocation AttrNameLoc;
SmallVector<Decl *, 2> Decls;
+ unsigned NestedTypeLevel;
----------------
rapidsna wrote:
I agree bounds safety attributes are the only type attributes that need late parsing right now. That said, any late-parsed type attribute needs to know its position in the type tree, so tracking this seems inherent to the feature—not bounds-safety specific.
IOW, even if we stored both QualTypes and walked between them like you suggested, we'd still need that position-calculating logic for any `LateParsedTypeAttribute`.
> But because we're expanding the capabilities here... Do we want LateParsedDeclAttribute and LateParsedTypeAttribute with the common stuff in a base class? Do we want a discriminated union in LatestParsedAttribute so only one of the decls, type, (or eventually smt) is valid at a time? My concern with the current approach is that it's unclear which fields are actually used under what circumstances,. e.g., you can get a LatedParsedAttribute which sets PointerIndirectionLevel but is actually for a declaration attribute rather than a type attribute.
This makes sense to me. I can try `LateParsedDeclAttribute` and `LateParsedTypeAttribute` with the common stuff in a base class.
https://github.com/llvm/llvm-project/pull/166491
More information about the cfe-commits
mailing list