[clang] f6cdb2c - [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 24 01:33:29 PDT 2021
Author: Balázs Kéri
Date: 2021-03-24T09:43:58+01:00
New Revision: f6cdb2c0a714f8921688de08858f34d8c776f0e6
URL: https://github.com/llvm/llvm-project/commit/f6cdb2c0a714f8921688de08858f34d8c776f0e6
DIFF: https://github.com/llvm/llvm-project/commit/f6cdb2c0a714f8921688de08858f34d8c776f0e6.diff
LOG: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D99188
Added:
Modified:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c4f36b50db9d3..ef7a3ea8a66c2 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@ namespace clang {
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 @@ ExpectedType ASTNodeImporter::VisitAutoType(const AutoType *T) {
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());
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 40383bcabc3f0..fdbf811c94dc1 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -631,6 +631,15 @@ TEST_P(ImportType, ImportDependentTemplateSpecialization) {
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;
More information about the cfe-commits
mailing list