Closed by commit rL213152 (authored by d0k).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D4517
Files:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
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<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
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()))));
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<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
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()))));
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits