This patch adds isDirectlyDerivedFrom AST-matcher which is similar to isDerivedFrom but only matches against direct base classes.
Details
Diff Detail
- Repository
 - rL LLVM
 
Event Timeline
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 2637 ↗ | (On Diff #211091) | /*Directly=*/false  | 
| clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | ||
| 342 ↗ | (On Diff #211091) | I think these tests are ~enough, given the implementation.  | 
| clang/docs/LibASTMatchersReference.html | ||
|---|---|---|
| 5277 ↗ | (On Diff #211148) | Did you manually change this? This should be generated from the code, but I don't see this text anywhere in the code comments?  | 
Thanks for the note, updated the diff with autogenerated LibASTMatcherReference.html.
So, I did like the more exhaustive doc, I thought you'd move it to the code so it also shows up in the generated doc page :) (sorry for not being clearer here)
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 2637 ↗ | (On Diff #211261) | If you say /*Directly=*/false, you should  | 
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 2672 ↗ | (On Diff #211261) | 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.  | 
Thanks for the comments!
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 2672 ↗ | (On Diff #211261) | 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.  | 
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 2682 ↗ | (On Diff #211508) | You should register this in Registry.cpp as an overload, like we do for isDerivedFrom() and isSameOrDerivedFrom().  | 
| 2672 ↗ | (On Diff #211261) | 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).  |