[clang] [BoundsSafety][NFC] Add the count-refill logic for late-parsed bounds attributes (PR #224556)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 18 09:01:37 PDT 2026


================
@@ -4896,6 +4896,54 @@ void Parser::ParseLexedTypeAttribute(LateParsedTypeAttribute &LA,
   OutAttrs.takeAllAppendingFrom(Attrs);
 }
 
+void Parser::CompleteLateParsedTypeAttributes(
+    SmallVectorImpl<LateParsedTypeAttribute *> &LateTypeAttrs) {
+  for (LateParsedTypeAttribute *LTA : LateTypeAttrs) {
+    // Read these out before parsing, which destroys the attribute. The type is
+    // null if construction rejected the attribute, in which case the diagnostic
+    // has already been emitted and there is nothing to complete.
+    BoundsAttributedType *BATy = LTA->TypeToComplete;
+    // Rejected during construction (already diagnosed); the cached tokens are
+    // self-contained, so there is nothing to drain — just discard it.
+    if (!BATy) {
+      delete LTA;
+      continue;
+    }
+    // The fields were
+    // attached in ParseStructDeclaration as each declarator was completed; more
+    // than one appears when several declarators share a
+    // declaration-specifier-position attribute.
+    SmallVector<Decl *, 2> Fields(LTA->Decls);
----------------
erichkeane wrote:

So we have a calculated 'default' value for that argument that we don't stray from unless we have reason to believe it is going to consistently be higher or lower.  

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


More information about the cfe-commits mailing list