diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -419,6 +419,7 @@ ExpectedType VisitObjCInterfaceType(const ObjCInterfaceType *T); ExpectedType VisitObjCObjectType(const ObjCObjectType *T); ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T); + ExpectedType VisitMacroQualifiedType(const MacroQualifiedType *T); // Importing declarations Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD, @@ -1701,6 +1702,17 @@ return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr); } +ExpectedType +ASTNodeImporter::VisitMacroQualifiedType(const MacroQualifiedType *T) { + ExpectedType ToUnderlyingTypeOrErr = import(T->getUnderlyingType()); + if (!ToUnderlyingTypeOrErr) + return ToUnderlyingTypeOrErr.takeError(); + + IdentifierInfo *ToIdentifier = Importer.Import(T->getMacroIdentifier()); + return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr, + ToIdentifier); +} + //---------------------------------------------------------------------------- // Import Declarations //---------------------------------------------------------------------------- diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -8638,6 +8638,24 @@ EXPECT_TRUE(ToCtx.hasSameType(ToInjTypedef, ToInjParmVar)); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportMacroQualifiedType) { + Decl *From, *To; + std::tie(From, To) = getImportedDecl( + R"( + #define CDECL __attribute__((cdecl)) + typedef void (CDECL *X)(); + )", + Lang_CXX03, "", Lang_CXX03, "X"); + + auto *FromTy = + FirstDeclMatcher().match(From, macroQualifiedType()); + auto *ToTy = + FirstDeclMatcher().match(To, macroQualifiedType()); + + EXPECT_TRUE(isa(FromTy->getUnderlyingType())); + EXPECT_TRUE(isa(ToTy->getUnderlyingType())); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplateName) { constexpr auto TestCode = R"( template