Add matcher for NamespaceDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179027 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Jasper 2013-04-08 16:44:05 +00:00
Родитель b3c881752b
Коммит abe922342d
2 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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) {