@@ -9751,6 +9751,43 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const ASTContext *Context) {
97519751 return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
97529752}
97539753
9754+ static TypedefDecl *
9755+ CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context) {
9756+ // typedef struct __va_list_tag {
9757+ RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9758+
9759+ VaListTagDecl->startDefinition();
9760+
9761+ // int* __va_stk;
9762+ // int* __va_reg;
9763+ // int __va_ndx;
9764+ constexpr size_t NumFields = 3;
9765+ QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
9766+ Context->getPointerType(Context->IntTy),
9767+ Context->IntTy};
9768+ const char *FieldNames[NumFields] = {"__va_stk", "__va_reg", "__va_ndx"};
9769+
9770+ // Create fields
9771+ for (unsigned i = 0; i < NumFields; ++i) {
9772+ FieldDecl *Field = FieldDecl::Create(
9773+ *Context, VaListTagDecl, SourceLocation(), SourceLocation(),
9774+ &Context->Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr,
9775+ /*BitWidth=*/nullptr,
9776+ /*Mutable=*/false, ICIS_NoInit);
9777+ Field->setAccess(AS_public);
9778+ VaListTagDecl->addDecl(Field);
9779+ }
9780+ VaListTagDecl->completeDefinition();
9781+ Context->VaListTagDecl = VaListTagDecl;
9782+ QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9783+
9784+ // } __va_list_tag;
9785+ TypedefDecl *VaListTagTypedefDecl =
9786+ Context->buildImplicitTypedef(VaListTagType, "__builtin_va_list");
9787+
9788+ return VaListTagTypedefDecl;
9789+ }
9790+
97549791static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
97559792 TargetInfo::BuiltinVaListKind Kind) {
97569793 switch (Kind) {
@@ -9772,6 +9809,8 @@ static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
97729809 return CreateSystemZBuiltinVaListDecl(Context);
97739810 case TargetInfo::HexagonBuiltinVaList:
97749811 return CreateHexagonBuiltinVaListDecl(Context);
9812+ case TargetInfo::XtensaABIBuiltinVaList:
9813+ return CreateXtensaABIBuiltinVaListDecl(Context);
97759814 }
97769815
97779816 llvm_unreachable("Unhandled __builtin_va_list type kind");
0 commit comments