Add matcher for NamespaceDecls.

llvm-svn: 179027
This commit is contained in:
Daniel Jasper 2013-04-08 16:44:05 +00:00
parent b5aa7e54d9
commit 9fcdc461ed
2 changed files with 23 additions and 3 deletions

View File

@ -129,7 +129,8 @@ typedef internal::Matcher<NestedNameSpecifierLoc> NestedNameSpecifierLocMatcher;
/// \endcode
///
/// Usable as: Any Matcher
inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher> anything() {
inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>
anything() {
return internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>();
}
@ -157,6 +158,17 @@ const internal::VariadicAllOfMatcher<Decl> decl;
/// \endcode
const internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl> namedDecl;
/// \brief Matches a declaration of a namespace.
///
/// Given
/// \code
/// namespace {}
/// namespace test {}
/// \endcode
/// namespaceDecl()
/// matches "namespace {}" and "namespace test {}"
const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl> namespaceDecl;
/// \brief Matches C++ class declarations.
///
/// Example matches \c X, \c Z

View File

@ -337,14 +337,22 @@ TEST(DeclarationMatcher, hasDeclContext) {
" class D {};"
" }"
"}",
recordDecl(hasDeclContext(namedDecl(hasName("M"))))));
recordDecl(hasDeclContext(namespaceDecl(hasName("M"))))));
EXPECT_TRUE(notMatches(
"namespace N {"
" namespace M {"
" class D {};"
" }"
"}",
recordDecl(hasDeclContext(namedDecl(hasName("N"))))));
recordDecl(hasDeclContext(namespaceDecl(hasName("N"))))));
EXPECT_TRUE(matches("namespace {"
" namespace M {"
" class D {};"
" }"
"}",
recordDecl(hasDeclContext(namespaceDecl(
hasName("M"), hasDeclContext(namespaceDecl()))))));
}
TEST(ClassTemplate, DoesNotMatchClass) {