From: Daniel Jasper Date: Wed, 12 Sep 2012 21:14:15 +0000 (+0000) Subject: Rename isA to isSameOrDerivedFrom. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63d88728d862f8a69b3291e533d193d1d8513f5a;p=clang Rename isA to isSameOrDerivedFrom. There are two evils we can choose from: - Name overlap between isA-matcher and llvm::isa<>() - Bad name for what the isA-matcher currently does After some discussion we have agreed to go with the latter evil. Review: http://llvm-reviews.chandlerc.com/D40 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163740 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 91a3ecfd49..19fac18ef2 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1139,14 +1139,17 @@ inline internal::Matcher isDerivedFrom(StringRef BaseName) { /// \brief Similar to \c isDerivedFrom(), but also matches classes that directly /// match \c Base. -inline internal::Matcher isA(internal::Matcher Base) { +inline internal::Matcher isSameOrDerivedFrom( + internal::Matcher Base) { return anyOf(Base, isDerivedFrom(Base)); } -/// \brief Overloaded method as shortcut for \c isA(hasName(...)). -inline internal::Matcher isA(StringRef BaseName) { +/// \brief Overloaded method as shortcut for +/// \c isSameOrDerivedFrom(hasName(...)). +inline internal::Matcher isSameOrDerivedFrom( + StringRef BaseName) { assert(!BaseName.empty()); - return isA(hasName(BaseName)); + return isSameOrDerivedFrom(hasName(BaseName)); } /// \brief Matches AST nodes that have child AST nodes that match the diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 55e22e927a..8b41c969ba 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -106,7 +106,7 @@ TEST(DeclarationMatcher, ClassIsDerived) { EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX)); EXPECT_TRUE(notMatches("", IsDerivedFromX)); - DeclarationMatcher IsAX = recordDecl(isA("X")); + DeclarationMatcher IsAX = recordDecl(isSameOrDerivedFrom("X")); EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX)); EXPECT_TRUE(matches("class X {};", IsAX));