Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -714,6 +714,18 @@ /// matches \code using X::x \endcode const internal::VariadicDynCastAllOfMatcher 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 + usingDirectiveDecl; + /// \brief Matches unresolved using value declarations. /// /// Given Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp =================================================================== --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -3038,6 +3038,13 @@ 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()))));