[PATCH] D58830: [ASTImporter] Import member expr with explicit template args
Gabor Marton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 05:37:35 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355596: [ASTImporter] Import member expr with explicit template args (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58830/new/
https://reviews.llvm.org/D58830
Files:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7129,15 +7129,19 @@
DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
+ TemplateArgumentListInfo ToTAInfo, *ResInfo = nullptr;
if (E->hasExplicitTemplateArgs()) {
- // FIXME: handle template arguments
- return make_error<ImportError>(ImportError::UnsupportedConstruct);
+ if (Error Err =
+ ImportTemplateArgumentListInfo(E->getLAngleLoc(), E->getRAngleLoc(),
+ E->template_arguments(), ToTAInfo))
+ return std::move(Err);
+ ResInfo = &ToTAInfo;
}
return MemberExpr::Create(
Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
- ToMemberNameInfo, nullptr, ToType, E->getValueKind(), E->getObjectKind());
+ ToMemberNameInfo, ResInfo, ToType, E->getValueKind(), E->getObjectKind());
}
ExpectedStmt
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2604,6 +2604,56 @@
EXPECT_TRUE(LambdaRec->getDestructor());
}
+TEST_P(ImportFunctions,
+ CallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ struct X {
+ template <typename T>
+ void foo(){}
+ };
+ void f() {
+ X x;
+ x.foo<int>();
+ }
+ )",
+ Lang_CXX);
+ auto *FromD = FirstDeclMatcher<FunctionDecl>().match(
+ FromTU, functionDecl(hasName("f")));
+ auto *ToD = Import(FromD, Lang_CXX);
+ EXPECT_TRUE(ToD);
+ EXPECT_TRUE(MatchVerifier<FunctionDecl>().match(
+ ToD, functionDecl(hasName("f"), hasDescendant(declRefExpr()))));
+}
+
+TEST_P(ImportFunctions,
+ DependentCallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ struct X {
+ template <typename T>
+ void foo(){}
+ };
+ template <typename T>
+ void f() {
+ X x;
+ x.foo<T>();
+ }
+ void g() {
+ f<int>();
+ }
+ )",
+ Lang_CXX);
+ auto *FromD = FirstDeclMatcher<FunctionDecl>().match(
+ FromTU, functionDecl(hasName("g")));
+ auto *ToD = Import(FromD, Lang_CXX);
+ EXPECT_TRUE(ToD);
+ Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+ EXPECT_TRUE(MatchVerifier<TranslationUnitDecl>().match(
+ ToTU, translationUnitDecl(hasDescendant(
+ functionDecl(hasName("f"), hasDescendant(declRefExpr()))))));
+}
+
struct ImportFriendFunctions : ImportFunctions {};
TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58830.189700.patch
Type: text/x-patch
Size: 2896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190307/5be0ee21/attachment.bin>
More information about the llvm-commits
mailing list