[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 24 08:05:35 PDT 2019


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2672
+                       BaseName, 1) {
+  assert(!BaseName.empty());
+  return isDirectlyDerivedFrom(hasName(BaseName))
----------------
AntonBikineev wrote:
> aaron.ballman wrote:
> > I don't think this assertion is reasonable -- we should instead test this as a predicate and return false if the base name is empty.
> It's done in the same way as for existing isDerivedFrom and isSameOrDerivedFrom matchers. Maybe it would make sense to change all of them, but I guess it should rather be a separate commit.
I'm fine with doing it in a follow-up commit, but it should be done (it shouldn't assert on invalid input, only on thought-to-be impossible situations, generally speaking).


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2682
+/// \endcode
+AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDirectlyDerivedFrom,
+                       internal::Matcher<NamedDecl>, Base, 0) {
----------------
You should register this in Registry.cpp as an overload, like we do for `isDerivedFrom()` and `isSameOrDerivedFrom()`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65092





More information about the cfe-commits mailing list