Index: include/clang/ASTMatchers/ASTMatchersInternal.h =================================================================== --- include/clang/ASTMatchers/ASTMatchersInternal.h +++ include/clang/ASTMatchers/ASTMatchersInternal.h @@ -672,10 +672,22 @@ /// matcher matches on it. bool matchesSpecialized(const QualType &Node, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) const { - /// FIXME: Add other ways to convert... if (Node.isNull()) return false; - return matchesDecl(Node->getAsTagDecl(), Finder, Builder); + + if (auto *TD = Node->getAsTagDecl()) + return matchesDecl(TD, Finder, Builder); + else if (auto *TT = Node->getAs()) + return matchesDecl(TT->getDecl(), Finder, Builder); + else if (auto *TTP = Node->getAs()) + return matchesDecl(TTP->getDecl(), Finder, Builder); + else if (auto *OCIT = Node->getAs()) + return matchesDecl(OCIT->getDecl(), Finder, Builder); + else if (auto *UUT = Node->getAs()) + return matchesDecl(UUT->getDecl(), Finder, Builder); + else if (auto *ICNT = Node->getAs()) + return matchesDecl(ICNT->getDecl(), Finder, Builder); + return false; } /// \brief Gets the TemplateDecl from a TemplateSpecializationType Index: unittests/ASTMatchers/ASTMatchersTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -924,6 +924,15 @@ varDecl(hasType(namedDecl(hasName("S")))))); } +TEST(TypeMatcher, MatchesDeclTypes) { + EXPECT_TRUE(matches("typedef int I; void f(I i);", + parmVarDecl(hasType(namedDecl(hasName("I")))))); + + // FIXME: when we support ObjCInterfaceDecl, and TemplateTypeParmDecl, add + // testing code here. Explore whether we should add testing code for + // UnresolvedUsingType and InjectedClassNameType. +} + TEST(Matcher, BindMatchedNodes) { DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x"));