From 4c05f1427134a524e1c84ccd57f59a96ffdffe59 Mon Sep 17 00:00:00 2001 From: Aleksei Sidorin Date: Wed, 14 Feb 2018 11:18:00 +0000 Subject: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl Also minor refactoring in related functions was done. Differential Revision: https://reviews.llvm.org/D43012 llvm-svn: 325116 --- clang/unittests/AST/ASTImporterTest.cpp | 40 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'clang/unittests/AST/ASTImporterTest.cpp') diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 41134f96efe..feadd94dded 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -542,20 +542,32 @@ TEST(ImportExpr, ImportCXXDependentScopeMemberExpr) { TEST(ImportType, ImportTypeAliasTemplate) { MatchVerifier Verifier; - testImport("template " - "struct dummy { static const int i = K; };" - "template using dummy2 = dummy;" - "int declToImport() { return dummy2<3>::i; }", - Lang_CXX11, "", Lang_CXX11, Verifier, - functionDecl( - hasBody( - compoundStmt( - has( - returnStmt( - has( - implicitCastExpr( - has( - declRefExpr()))))))))); + testImport( + "template " + "struct dummy { static const int i = K; };" + "template using dummy2 = dummy;" + "int declToImport() { return dummy2<3>::i; }", + Lang_CXX11, "", Lang_CXX11, Verifier, + functionDecl( + hasBody(compoundStmt( + has(returnStmt(has(implicitCastExpr(has(declRefExpr()))))))), + unless(hasAncestor(translationUnitDecl(has(typeAliasDecl())))))); +} + +const internal::VariadicDynCastAllOfMatcher + varTemplateSpecializationDecl; + +TEST(ImportDecl, ImportVarTemplate) { + MatchVerifier Verifier; + testImport( + "template " + "T pi = T(3.1415926535897932385L);" + "void declToImport() { pi; }", + Lang_CXX11, "", Lang_CXX11, Verifier, + functionDecl( + hasBody(has(declRefExpr(to(varTemplateSpecializationDecl())))), + unless(hasAncestor(translationUnitDecl(has(varDecl( + hasName("pi"), unless(varTemplateSpecializationDecl())))))))); } TEST(ImportType, ImportPackExpansion) { -- cgit v1.2.3