Skip to content

Commit

Permalink
[clang][ASTImporter] Add import of 'MacroQualifiedType'
Browse files Browse the repository at this point in the history
Add import of 'MacroQualifiedType'.

Reviewed By: balazske

Differential Revision: https://reviews.llvm.org/D157780
  • Loading branch information
danix800 committed Aug 16, 2023
1 parent ec483c2 commit 3b0eeb6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace clang {
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,
Expand Down Expand Up @@ -1701,6 +1702,17 @@ ASTNodeImporter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
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
//----------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions clang/unittests/AST/ASTImporterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8638,6 +8638,24 @@ TEST_P(ImportInjectedClassNameType, ImportTypedefType) {
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<MacroQualifiedType>().match(From, macroQualifiedType());
auto *ToTy =
FirstDeclMatcher<MacroQualifiedType>().match(To, macroQualifiedType());

EXPECT_TRUE(isa<AttributedType>(FromTy->getUnderlyingType()));
EXPECT_TRUE(isa<AttributedType>(ToTy->getUnderlyingType()));
}

TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplateName) {
constexpr auto TestCode = R"(
template <class T>
Expand Down

0 comments on commit 3b0eeb6

Please sign in to comment.