r319632 - [ASTImporter] Add unit tests for UsingDecl and UsingShadowDecl
Aleksei Sidorin via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 3 08:04:07 PST 2017
Author: a.sidorin
Date: Sun Dec 3 08:04:07 2017
New Revision: 319632
URL: http://llvm.org/viewvc/llvm-project?rev=319632&view=rev
Log:
[ASTImporter] Add unit tests for UsingDecl and UsingShadowDecl
Patch by Kareem Khazem!
Differential Revision: https://reviews.llvm.org/D27181
Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp
Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=319632&r1=319631&r2=319632&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Sun Dec 3 08:04:07 2017
@@ -583,5 +583,46 @@ TEST(ImportExpr, ImportCXXPseudoDestruct
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
More information about the cfe-commits
mailing list