[PATCH] Filter the toplevel matchers by kind.

Samuel Benzaquen sbenza at google.com
Fri Nov 21 13:55:28 PST 2014


================
Comment at: include/clang/AST/ASTTypeTraits.h:393-395
@@ -376,2 +392,5 @@
 } // end namespace clang
 
+
+
+namespace llvm {
----------------
klimek wrote:
> Is all that whitespace intentional?
Not really. Fixed.

================
Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:292-295
@@ -291,1 +291,6 @@
 
+  /// \brief Check whether this matcher could ever match a node of kind \p Kind.
+  /// \return \c false if this matcher will never match such a node. Otherwise,
+  /// return true.
+  bool canMatchNodesOfKind(ast_type_traits::ASTNodeKind Kind) const;
+
----------------
klimek wrote:
> Either \c both false and true, or none :)
\c ALL the keywords!

================
Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:309-311
@@ +308,5 @@
+  /// kind of this matcher.
+  bool matchesNoKindCheck(const ast_type_traits::DynTypedNode &DynNode,
+                          ASTMatchFinder *Finder,
+                          BoundNodesTreeBuilder *Builder) const;
+
----------------
klimek wrote:
> I'd spend the extra 6 characters and call it matchesWithoutKindCheck.
What about SkipKindCheck ?

================
Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:187-191
@@ +186,7 @@
+  }
+  // Delete all bindings when a matcher does not match.
+  // This prevents unexpected exposure of bound nodes in unmatches
+  // branches of the match tree.
+  Builder->removeBindings([](const BoundNodesMap &) { return true; });
+  return false;
+}
----------------
klimek wrote:
> Shouldn't every matcher already do that?
Do what? Delete the bindings?
This is where it happens, right?
The MatcherInterface implementations don't delete anything.

I pretty much copied matches() and modified it. That stayed the same.

http://reviews.llvm.org/D6361






More information about the cfe-commits mailing list