[PATCH] Introduce clang-query tool.

Manuel Klimek klimek at google.com
Wed Nov 6 09:15:38 PST 2013


  lg with the nits fixed


================
Comment at: clang-query/QueryParser.h:22
@@ +21,3 @@
+/// \c InvalidQuery if a parse error occurs.
+QueryRef ParseQuery(const char *Line);
+
----------------
Here also StringRef...

================
Comment at: clang-query/Query.cpp:55-65
@@ +54,13 @@
+    CollectBoundNodes Collect(Matches);
+    if (Matcher.canConvertTo<Decl>()) {
+      DeclarationMatcher M = Matcher.convertTo<Decl>();
+      if (QS.BindRoot)
+        M = decl(M).bind("root");
+      Finder.addMatcher(decl(forEachDescendant(M)), &Collect);
+    } else if (Matcher.canConvertTo<Stmt>()) {
+      StatementMatcher M = Matcher.convertTo<Stmt>();
+      if (QS.BindRoot)
+        M = stmt(M).bind("root");
+      Finder.addMatcher(decl(forEachDescendant(M)), &Collect);
+    }
+    Finder.match(*AST->getASTContext().getTranslationUnitDecl(),
----------------
Yea, we really need addDynamicMatcher ...

================
Comment at: clang-query/Query.h:46
@@ +45,3 @@
+
+  static bool classof(const Query *Q) { return true; }
+
----------------
I kinda dislike the introduction of RTTI just for testing ... Since this is all in clang-query I think it's ok, as I cannot come up with a significantly better way right now.


http://llvm-reviews.chandlerc.com/D2098

BRANCH
  clangquery

ARCANIST PROJECT
  clang-tools-extra



More information about the cfe-commits mailing list