diff options
author | Aleksei Sidorin <a.sidorin@samsung.com> | 2017-12-03 16:04:07 +0000 |
---|---|---|
committer | Aleksei Sidorin <a.sidorin@samsung.com> | 2017-12-03 16:04:07 +0000 |
commit | 008134d00bbe515d1d885aa2e021d698d3d41a04 (patch) | |
tree | 223218d994868e568fec1e13524cd1b0771a9a2b /unittests | |
parent | 9a4191042eeaafcd1ecbb9a131fd0165a6aab8ad (diff) |
[ASTImporter] Add unit tests for UsingDecl and UsingShadowDecl
Patch by Kareem Khazem!
Differential Revision: https://reviews.llvm.org/D27181
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/AST/ASTImporterTest.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp index 86518e132d..64dd4fc953 100644 --- a/unittests/AST/ASTImporterTest.cpp +++ b/unittests/AST/ASTImporterTest.cpp @@ -583,5 +583,46 @@ TEST(ImportExpr, ImportCXXPseudoDestructorExpr) { callExpr(has(cxxPseudoDestructorExpr())))))))); } +TEST(ImportDecl, ImportUsingDecl) { + MatchVerifier<Decl> Verifier; + EXPECT_TRUE( + testImport( + "namespace foo { int bar; }" + "int declToImport(){ using foo::bar; }", + Lang_CXX, "", Lang_CXX, Verifier, + functionDecl( + has( + compoundStmt( + has( + declStmt( + has( + usingDecl())))))))); +} + +/// \brief Matches shadow declarations introduced into a scope by a +/// (resolved) using declaration. +/// +/// Given +/// \code +/// namespace n { int f; } +/// namespace declToImport { using n::f; } +/// \endcode +/// usingShadowDecl() +/// matches \code f \endcode +const internal::VariadicDynCastAllOfMatcher<Decl, + UsingShadowDecl> usingShadowDecl; + +TEST(ImportDecl, ImportUsingShadowDecl) { + MatchVerifier<Decl> Verifier; + EXPECT_TRUE( + testImport( + "namespace foo { int bar; }" + "namespace declToImport { using foo::bar; }", + Lang_CXX, "", Lang_CXX, Verifier, + namespaceDecl( + has( + usingShadowDecl())))); +} + } // end namespace ast_matchers } // end namespace clang |