[PATCH] D119893: [clang-format] Fixed handling of requires clauses followed by attributes

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 16 00:05:50 PST 2022


HazardyKnusperkeks added a comment.

In D119893#3325375 <https://reviews.llvm.org/D119893#3325375>, @curdeius wrote:

> +1 to Arthur's comments.
> Does it fix any of the recently created issues?

Yeah, I should have put that in the commit message, right? ;)

Maybe I would have discovered the bug myself, but this is from GitHub.



================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3018-3019
   do {
+    bool LambdaThisTimeAllowed = LambdaNextTimeAllowed;
+    LambdaNextTimeAllowed = false;
+
----------------
Quuxplusone wrote:
> Nit: For this pattern, consider `bool LambdaThisTimeAllowed = std::exchange(LambdaNextTimeAllowed, false);`
I was under the impression that exchange was C++17. If I'd known that it's 14 and I can use it, I'd done that in the first place.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3102
+      LambdaNextTimeAllowed = true;
+      LLVM_FALLTHROUGH;
+    case tok::numeric_constant:
----------------
Quuxplusone wrote:
> This seems like an overuse of fallthrough; how about simply
> ```
>     LambdaNextTimeAllowed = true;
>     nextToken();
>     break;
> ```
> ?
Can do. I'm just thinking if there is ever a change to what to do, not just `nextToken()`, I would have to change it only at 2 not 3 places. But probably that will never happen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119893



More information about the cfe-commits mailing list