[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 12:07:57 PDT 2020


jkorous added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher<CXXRecordDecl>,
+              InnerMatcher) {
----------------
aaron.ballman wrote:
> jkorous wrote:
> > Nit: while "[base specifier] `hasType`" sounds natural to me for some reason `hasClass` doesn't. English is not my first language though.
> I agree that `hasClass` seems unnatural here. Out of curiosity, could we modify the `hasName` matcher to work on base specifiers so you can write: `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more wordy version `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))`?
Wouldn't it be strange to treat `hasName` differently than all the other narrowing matchers? Honest question - I feel that `hasName` might be the most commonly used, just don't know if that's enough to justify this.
https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552





More information about the cfe-commits mailing list