aaron.ballman added inline comments.
================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2638
+ // Check if the node is a C++ struct/union/class.
+ if (const auto *RecordDecl = dyn_cast<CXXRecordDecl>(&Node))
+ return Finder->classIsDerivedFrom(RecordDecl, Base, Builder);
----------------
I'd prefer this be named `RD` so that it doesn't conflict with the name of the
`RecordDecl` type.
================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2642-2649
+ if (const auto *InterfaceDecl = dyn_cast<ObjCInterfaceDecl>(&Node)) {
+ // Check if any of the superclasses of the class match.
+ for (const ObjCInterfaceDecl *SuperClass = InterfaceDecl->getSuperClass();
+ SuperClass != nullptr; SuperClass = SuperClass->getSuperClass()) {
+ if (Base.matches(*SuperClass, Finder, Builder))
+ return true;
+ }
----------------
This should probably be done similar to how `classIsDerivedFrom()` works. For
instance, there's some type alias matching logic that this does not replicate,
but we probably want.
================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2667-2672
+ if (const auto *InterfaceDecl = dyn_cast<ObjCInterfaceDecl>(&Node)) {
+ return Matcher<ObjCInterfaceDecl>(M).matches(*InterfaceDecl, Finder,
+ Builder);
+ }
+
+ llvm_unreachable("Not a valid polymorphic type");
----------------
How about:
```
const auto *InterfaceDecl = cast<ObjCInterfaceDecl>(&Node);
return Matcher...
```
We can rely on `cast<>` to assert if the node is of an unexpected type. Same
suggestions below.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60543/new/
https://reviews.llvm.org/D60543
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits