diff options
author | Gabor Marton <martongabesz@gmail.com> | 2019-03-07 13:38:20 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2019-03-07 13:38:20 +0000 |
commit | 5caba3069e8185b2c8225080c95755ea906b624e (patch) | |
tree | 81783633e8eb5b5a407319e49bc65116334543cc /clang/unittests/AST/ASTImporterTest.cpp | |
parent | e7ec39c1234fdc09fd6e0cbf0c7dbabf410a3c32 (diff) | |
download | bcm5719-llvm-5caba3069e8185b2c8225080c95755ea906b624e.tar.gz bcm5719-llvm-5caba3069e8185b2c8225080c95755ea906b624e.zip |
[ASTImporter] Import member expr with explicit template args
Summary:
Member expressions with explicit template arguments were not imported
correctly: the DeclRefExpr was missing. This patch fixes.
Reviewers: a_sidorin, shafik, a.sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58830
llvm-svn: 355596
Diffstat (limited to 'clang/unittests/AST/ASTImporterTest.cpp')
-rw-r--r-- | clang/unittests/AST/ASTImporterTest.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 00e12d75bc8..ebab02f5002 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -2604,6 +2604,56 @@ TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) { 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) { |