This matches 'using namespace' declarations.
Differential Revision: http://reviews.llvm.org/D4517
llvm-svn: 213152
/// matches \code using X::x \endcode
const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
+/// \brief Matches using namespace declarations.
+///
+/// Given
+/// \code
+/// namespace X { int x; }
+/// using namespace X;
+/// \endcode
+/// usingDirectiveDecl()
+/// matches \code using namespace X \endcode
+const internal::VariadicDynCastAllOfMatcher<Decl, UsingDirectiveDecl>
+ usingDirectiveDecl;
+
/// \brief Matches unresolved using value declarations.
///
/// Given
declRefExpr(throughUsingDecl(anything()))));
}
+TEST(UsingDirectiveDeclaration, MatchesUsingNamespace) {
+ EXPECT_TRUE(matches("namespace X { int x; } using namespace X;",
+ usingDirectiveDecl()));
+ EXPECT_FALSE(
+ matches("namespace X { int x; } using X::x;", usingDirectiveDecl()));
+}
+
TEST(SingleDecl, IsSingleDecl) {
StatementMatcher SingleDeclStmt =
declStmt(hasSingleDecl(varDecl(hasInitializer(anything()))));