@@ -216,6 +216,20 @@ class ParsedAttr final
216216 memcpy (getArgsBuffer (), args, numArgs * sizeof (ArgsUnion));
217217 }
218218
219+ // / Constructor for an annotation with expression argument
220+ ParsedAttr (SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args,
221+ unsigned numArgs, Form formUsed, SourceLocation ellipsisLoc)
222+ : AttributeCommonInfo(attrRange, ParsedAttr::Kind::AT_CXX26Annotation,
223+ ParsedAttr::Form::Annotation ()),
224+ EllipsisLoc(ellipsisLoc), NumArgs(numArgs), Invalid(false ),
225+ UsedAsTypeAttr(false ), IsAvailability(false ),
226+ IsTypeTagForDatatype(false ), IsProperty(false ), HasParsedType(false ),
227+ HasProcessingCache(false ), IsPragmaClangAttribute(false ),
228+ Info(ParsedAttrInfo::get(*this )) {
229+ assert (numArgs == 1 );
230+ memcpy (getArgsBuffer (), args, sizeof (ArgsUnion));
231+ }
232+
219233 // / Constructor for availability attributes.
220234 ParsedAttr (IdentifierInfo *attrName, SourceRange attrRange,
221235 AttributeScopeInfo scope, IdentifierLoc *Parm,
@@ -504,6 +518,7 @@ class ParsedAttr final
504518 // / error. Returns false if a diagnostic is produced.
505519 bool checkAtMostNumArgs (class Sema &S, unsigned Num) const ;
506520
521+ bool isAnnotationAttr () const ;
507522 bool isTargetSpecificAttr () const ;
508523 bool isTypeAttr () const ;
509524 bool isStmtAttr () const ;
@@ -732,6 +747,22 @@ class AttributePool {
732747 // / them at the end of this \c AttributePool.
733748 void takeFrom (ParsedAttributesView &List, AttributePool &Pool);
734749
750+ // Create a Cxx26 annotation
751+ ParsedAttr *create (SourceRange attrRange, AttributeScopeInfo scope,
752+ ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form,
753+ SourceLocation ellipsisLoc = SourceLocation()) {
754+ // Only annotations are allowed to pass through without an identifier
755+ assert (form.getSyntax () == ParsedAttr::Syntax::AS_Annotation);
756+
757+ void *memory = allocate (
758+ ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
759+ detail::TypeTagForDatatypeData, ParsedType,
760+ detail::PropertyData>(numArgs, 0 , 0 , 0 ,
761+ 0 ));
762+ return add (new (memory) ParsedAttr (attrRange, scope, args, numArgs, form,
763+ ellipsisLoc));
764+ }
765+
735766 ParsedAttr *create (IdentifierInfo *attrName, SourceRange attrRange,
736767 AttributeScopeInfo scope, ArgsUnion *args,
737768 unsigned numArgs, ParsedAttr::Form form,
@@ -974,6 +1005,16 @@ class ParsedAttributes : public ParsedAttributesView {
9741005 Range = SourceRange ();
9751006 }
9761007
1008+ // / Add annotation with expression argument
1009+ ParsedAttr *addNew (SourceRange attrRange, AttributeScopeInfo scope,
1010+ ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form,
1011+ SourceLocation ellipsisLoc = SourceLocation()) {
1012+ ParsedAttr *attr =
1013+ pool.create (attrRange, scope, args, numArgs, form, ellipsisLoc);
1014+ addAtEnd (attr);
1015+ return attr;
1016+ }
1017+
9771018 // / Add attribute with expression arguments.
9781019 ParsedAttr *addNew (IdentifierInfo *attrName, SourceRange attrRange,
9791020 AttributeScopeInfo scope, ArgsUnion *args,
0 commit comments