[PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

Samuel Benzaquen via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 09:57:28 PDT 2016


sbenza added inline comments.

================
Comment at: include/clang/AST/DeclCXX.h:1830
@@ -1829,2 +1829,3 @@
   unsigned size_overridden_methods() const;
+  const ArrayRef<const CXXMethodDecl *> overridden_methods() const;
 
----------------
Return type should have have toplevel `const`.

================
Comment at: lib/AST/ASTContext.cpp:1262
@@ -1261,2 +1261,3 @@
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
+      = OverriddenMethods.find(Method->getCanonicalDecl());
----------------
I would invert the calls here.
That is, make overridden_methods_begin/_end call overridden_methods() instead, and have overridden_methods() be the one that does the lookup.
This way we have a single place where the lookup happens. It would also make overridden_methods() faster.


http://reviews.llvm.org/D19324





More information about the cfe-commits mailing list