================
@@ -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;
----------------
rapidsna wrote:
This follows the existing pattern around LateParsedAttribute, which is already
raw new/delete. They're allocated with new in `ParseSingleGNUAttribute` and
deleted after parsing in `Parser::ParseLexedAttributeList`:
```C
for (unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
if (D) LAs[i]->addDecl(D);
ParseLexedAttribute(*LAs[i], EnterScope, OnDefinition, OutAttrs);
delete LAs[i];
}
LAs.clear();
```
This pattern is not something this PR introduced. Could we track the
improvement as a follow-up?
https://github.com/llvm/llvm-project/pull/224556
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits