[PATCH] Filter the toplevel matchers by kind.

Manuel Klimek klimek at google.com
Fri Nov 21 13:01:21 PST 2014


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

================
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;
+
----------------
Either \c both false and true, or none :)

================
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;
+
----------------
I'd spend the extra 6 characters and call it matchesWithoutKindCheck.

================
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;
+}
----------------
Shouldn't every matcher already do that?

http://reviews.llvm.org/D6361






More information about the cfe-commits mailing list