Skip to content

Commit 3b0eeb6

Browse files
committed
[clang][ASTImporter] Add import of 'MacroQualifiedType'
Add import of 'MacroQualifiedType'. Reviewed By: balazske Differential Revision: https://reviews.llvm.org/D157780
1 parent ec483c2 commit 3b0eeb6

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ namespace clang {
419419
ExpectedType VisitObjCInterfaceType(const ObjCInterfaceType *T);
420420
ExpectedType VisitObjCObjectType(const ObjCObjectType *T);
421421
ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
422+
ExpectedType VisitMacroQualifiedType(const MacroQualifiedType *T);
422423

423424
// Importing declarations
424425
Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
@@ -1701,6 +1702,17 @@ ASTNodeImporter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
17011702
return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
17021703
}
17031704

1705+
ExpectedType
1706+
ASTNodeImporter::VisitMacroQualifiedType(const MacroQualifiedType *T) {
1707+
ExpectedType ToUnderlyingTypeOrErr = import(T->getUnderlyingType());
1708+
if (!ToUnderlyingTypeOrErr)
1709+
return ToUnderlyingTypeOrErr.takeError();
1710+
1711+
IdentifierInfo *ToIdentifier = Importer.Import(T->getMacroIdentifier());
1712+
return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr,
1713+
ToIdentifier);
1714+
}
1715+
17041716
//----------------------------------------------------------------------------
17051717
// Import Declarations
17061718
//----------------------------------------------------------------------------

clang/unittests/AST/ASTImporterTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8638,6 +8638,24 @@ TEST_P(ImportInjectedClassNameType, ImportTypedefType) {
86388638
EXPECT_TRUE(ToCtx.hasSameType(ToInjTypedef, ToInjParmVar));
86398639
}
86408640

8641+
TEST_P(ASTImporterOptionSpecificTestBase, ImportMacroQualifiedType) {
8642+
Decl *From, *To;
8643+
std::tie(From, To) = getImportedDecl(
8644+
R"(
8645+
#define CDECL __attribute__((cdecl))
8646+
typedef void (CDECL *X)();
8647+
)",
8648+
Lang_CXX03, "", Lang_CXX03, "X");
8649+
8650+
auto *FromTy =
8651+
FirstDeclMatcher<MacroQualifiedType>().match(From, macroQualifiedType());
8652+
auto *ToTy =
8653+
FirstDeclMatcher<MacroQualifiedType>().match(To, macroQualifiedType());
8654+
8655+
EXPECT_TRUE(isa<AttributedType>(FromTy->getUnderlyingType()));
8656+
EXPECT_TRUE(isa<AttributedType>(ToTy->getUnderlyingType()));
8657+
}
8658+
86418659
TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplateName) {
86428660
constexpr auto TestCode = R"(
86438661
template <class T>

0 commit comments

Comments
 (0)