[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 30 10:03:10 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though please wait a bit for @njames93 to speak up if they still have concerns.



================
Comment at: clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp:61
+          hasBody(allOf(hasDescendant(returns(true)),
+                        unless(anyOf(hasDescendant(breakStmt()),
+                                     hasDescendant(returnsButNotTrue))))))
----------------
mgehre wrote:
> aaron.ballman wrote:
> > Should we reject other ways to break out of the loop, like `goto` or `throw`?
> I think throw statements still can be transformed. We cannot transform `break` because the loop is gone and we cannot transform `goto` because we cannot jump from the lambda into its caller.
> But we can keep `throw` statements because exceptions can propagate from the lambda through the algorithm back into the original caller. If we could not allow `throw` statements, we would also have to disallow any other kind of call statements.
Ah, good point on `throw`, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77572/new/

https://reviews.llvm.org/D77572





More information about the cfe-commits mailing list