[PATCH] D65877: [libTooling] In Transformer, generalize `applyFirst` to admit rules with incompatible matchers.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 13:38:29 PDT 2019

ymandel marked 2 inline comments as done.
ymandel added inline comments.

Comment at: clang/lib/Tooling/Refactoring/Transformer.cpp:127
+    if (!hasValidKind(Cases[I].Matcher))
+      return std::vector<DynTypedMatcher>();
+    Buckets[Cases[I].Matcher.getSupportedKind()].emplace_back(I, Cases[I]);
gribozavr wrote:
> Returning an empty vector is a valid API choice, but why not assert instead? If an empty vector is returned, unsupported matchers are silently ignored instead of being diagnosed.
Good point. I generally dislike assertions, but at this point the caller is passing a malformed-rule and it is not the place for returning errors.  If we plug this support into a UI, we can add filters on the front end that fail nicely and return error messages rather than die.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list