[ASTImporter] Add unit tests for UsingDecl and UsingShadowDecl

Patch by Kareem Khazem!

Differential Revision: https://reviews.llvm.org/D27181

llvm-svn: 319632
This commit is contained in:
Aleksei Sidorin 2017-12-03 16:04:07 +00:00
parent 0bf99c6954
commit 9d8ba2e1ae
1 changed files with 41 additions and 0 deletions

View File

@ -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