[PATCH] D99188: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 23 07:32:06 PDT 2021
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99188
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
@@ -631,6 +631,15 @@
fieldDecl(hasType(dependentTemplateSpecializationType())))))));
}
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+ MatchVerifier<Decl> Verifier;
+ testImport("template <typename T>"
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType())));
+}
+
const internal::VariadicDynCastAllOfMatcher<Stmt, SizeOfPackExpr>
sizeOfPackExpr;
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@
ExpectedType VisitDecltypeType(const DecltypeType *T);
ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
ExpectedType VisitAutoType(const AutoType *T);
+ ExpectedType VisitDeducedTemplateSpecializationType(
+ const DeducedTemplateSpecializationType *T);
ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
// FIXME: DependentDecltypeType
ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@
ToTemplateArgs);
}
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+ const DeducedTemplateSpecializationType *T) {
+ // FIXME: Make sure that the "to" context supports C++17!
+ Expected<TemplateName> ToTemplateNameOrErr = import(T->getTemplateName());
+ if (!ToTemplateNameOrErr)
+ return ToTemplateNameOrErr.takeError();
+ ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+ if (!ToDeducedTypeOrErr)
+ return ToDeducedTypeOrErr.takeError();
+
+ return Importer.getToContext().getDeducedTemplateSpecializationType(
+ *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
const InjectedClassNameType *T) {
Expected<CXXRecordDecl *> ToDeclOrErr = import(T->getDecl());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99188.332673.patch
Type: text/x-patch
Size: 2239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210323/0364eb9e/attachment-0001.bin>
More information about the cfe-commits
mailing list