[clang] [BoundsSafety][NFC] Introduce LateParsedTypeAttribute for late-parsed type attributes (PR #192799)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 22 02:14:25 PDT 2026


================
@@ -190,20 +190,63 @@ class LateParsedDeclaration {
 /// FIXME: Perhaps we should change the name of LateParsedDeclaration to
 /// LateParsedTokens.
 struct LateParsedAttribute : public LateParsedDeclaration {
+
+  enum LPA_Kind {
+    LPA_Declaration,
+    LPA_Type,
+  };
+
   Parser *Self;
   CachedTokens Toks;
   IdentifierInfo &AttrName;
   IdentifierInfo *MacroII = nullptr;
   SourceLocation AttrNameLoc;
   SmallVector<Decl *, 2> Decls;
 
+private:
+  LPA_Kind Kind;
+
+public:
   explicit LateParsedAttribute(Parser *P, IdentifierInfo &Name,
-                               SourceLocation Loc)
-      : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
+                               SourceLocation Loc,
+                               LPA_Kind Kind = LPA_Declaration)
+      : Self(P), AttrName(Name), AttrNameLoc(Loc), Kind(Kind) {}
 
   void ParseLexedAttributes() override;
 
   void addDecl(Decl *D) { Decls.push_back(D); }
+
+  LPA_Kind getKind() const { return Kind; }
+
+  // LLVM-style RTTI support
+  static bool classof(const LateParsedAttribute *LA) {
+    // LateParsedAttribute matches both Declaration and Type kinds
----------------
zmodem wrote:

(ultra nit: The comment doesn't really add much to the code.

I'd also consider dropping the "LLVM-style RTTI support" comment here and below, but up to you.)

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


More information about the cfe-commits mailing list