[PATCH] D54402: Extract method to allow re-use

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 11 15:19:37 PST 2018


aaron.ballman added a comment.

Generally LGTM but this has no test coverage. What are your plans for how you want to see this proceed? Do you intend to commit everything in one batch once all of the reviews are accepted, or do piecemeal commits?



================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:565
+template <typename T>
+void processAcceptableMatchers(ArrayRef<ArgKind> AcceptedTypes, T func) {
 
----------------
I'd prefer `T` to be named `Callable` and `func` to be `Func`. Also, I think it should be `Callable &&Func`.


================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:595
     if (!RetKinds.empty() && MaxSpecificity > 0) {
-      std::string Decl;
-      llvm::raw_string_ostream OS(Decl);
-
-      if (IsPolymorphic) {
-        OS << "Matcher<T> " << Name << "(Matcher<T>";
-      } else {
-        OS << "Matcher<" << RetKinds << "> " << Name << "(";
-        for (const std::vector<ArgKind> &Arg : ArgsKinds) {
-          if (&Arg != &ArgsKinds[0])
-            OS << ", ";
-
-          bool FirstArgKind = true;
-          std::set<ASTNodeKind> MatcherKinds;
-          // Two steps. First all non-matchers, then matchers only.
-          for (const ArgKind &AK : Arg) {
-            if (AK.getArgKind() == ArgKind::AK_Matcher) {
-              MatcherKinds.insert(AK.getMatcherKind());
-            } else {
-              if (!FirstArgKind) OS << "|";
-              FirstArgKind = false;
-              OS << AK.asString();
+      func(Name, Matcher, RetKinds, ArgsKinds, MaxSpecificity);
+    }
----------------
Then you can use `std::forward<Callable>(Func)(...);` because we can't use `std::invoke()` yet.


Repository:
  rC Clang

https://reviews.llvm.org/D54402





More information about the cfe-commits mailing list