diff options
| author | Daniel Jasper <djasper@google.com> | 2012-09-29 15:55:18 +0000 | 
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2012-09-29 15:55:18 +0000 | 
| commit | 0c30337f6b5decf94e13249a4b1a68ab5bc24ea2 (patch) | |
| tree | 5c72adc1e4910dfe73019cd9ed9b83758ca35fed /clang | |
| parent | 6743e0469914b34322efed11617574b394c91705 (diff) | |
| download | bcm5719-llvm-0c30337f6b5decf94e13249a4b1a68ab5bc24ea2.tar.gz bcm5719-llvm-0c30337f6b5decf94e13249a4b1a68ab5bc24ea2.zip | |
Fix refersToDeclaration()-matcher and add missing test case. This was
broken as of r164656 as TemplateArgument::getAsDecl() now asserts
instead of returning NULL for other template arugment kinds.
llvm-svn: 164896
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 4 | ||||
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 6 | 
2 files changed, 8 insertions, 2 deletions
| diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 3015b0841f2..6507433e332 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -342,8 +342,8 @@ AST_MATCHER_P(TemplateArgument, refersToType,  ///     \c B::next  AST_MATCHER_P(TemplateArgument, refersToDeclaration,                internal::Matcher<Decl>, InnerMatcher) { -  if (const Decl *Declaration = Node.getAsDecl()) -    return InnerMatcher.matches(*Declaration, Finder, Builder); +  if (Node.getKind() == TemplateArgument::Declaration) +    return InnerMatcher.matches(*Node.getAsDecl(), Finder, Builder);    return false;  } diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 69e61f296ff..b49d082501b 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1236,6 +1236,12 @@ TEST(Matcher, MatchesDeclarationReferenceTemplateArgument) {        "A<&B::next> a;",        classTemplateSpecializationDecl(hasAnyTemplateArgument(            refersToDeclaration(fieldDecl(hasName("next"))))))); + +  EXPECT_TRUE(notMatches( +      "template <typename T> struct A {};" +      "A<int> a;", +      classTemplateSpecializationDecl(hasAnyTemplateArgument( +          refersToDeclaration(decl())))));  }  TEST(Matcher, MatchesSpecificArgument) { | 

