[PATCH] D157780: [ASTImporter] Add import of MacroQualifiedType
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 16 03:03:41 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b0eeb6cdbd7: [clang][ASTImporter] Add import of 'MacroQualifiedType' (authored by dingfei <fding at feysh.com>).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157780/new/
https://reviews.llvm.org/D157780
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ 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<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>
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ 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
//----------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157780.550687.patch
Type: text/x-patch
Size: 2390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230816/6b64bf08/attachment.bin>
More information about the cfe-commits
mailing list