[cfe-commits] [PATCH] Rename isA to isSameOrDerivedFrom
Daniel Jasper
reviews at llvm-reviews.chandlerc.com
Wed Sep 12 04:45:19 PDT 2012
Hi chandlerc, klimek,
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.
http://llvm-reviews.chandlerc.com/D40
Files:
include/clang/ASTMatchers/ASTMatchers.h
unittests/ASTMatchers/ASTMatchersTest.cpp
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1139,14 +1139,17 @@
/// \brief Similar to \c isDerivedFrom(), but also matches classes that directly
/// match \c Base.
-inline internal::Matcher<CXXRecordDecl> isA(internal::Matcher<NamedDecl> Base) {
+inline internal::Matcher<CXXRecordDecl> isSameOrDerivedFrom(
+ internal::Matcher<NamedDecl> Base) {
return anyOf(Base, isDerivedFrom(Base));
}
-/// \brief Overloaded method as shortcut for \c isA(hasName(...)).
-inline internal::Matcher<CXXRecordDecl> isA(StringRef BaseName) {
+/// \brief Overloaded method as shortcut for
+/// \c isSameOrDerivedFrom(hasName(...)).
+inline internal::Matcher<CXXRecordDecl> 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
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -106,7 +106,7 @@
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40.1.patch
Type: text/x-patch
Size: 1639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120912/85bccd1a/attachment.bin>
More information about the cfe-commits
mailing list