This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fixed handling of requires clauses followed by attributes
ClosedPublic

Authored by HazardyKnusperkeks on Feb 15 2022, 2:16 PM.

Diff Detail

Event Timeline

HazardyKnusperkeks requested review of this revision.Feb 15 2022, 2:16 PM
HazardyKnusperkeks created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2022, 2:16 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Quuxplusone added inline comments.
clang/lib/Format/UnwrappedLineParser.cpp
3019–3020

Nit: For this pattern, consider bool LambdaThisTimeAllowed = std::exchange(LambdaNextTimeAllowed, false);

3102

This seems like an overuse of fallthrough; how about simply

LambdaNextTimeAllowed = true;
nextToken();
break;

?

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

+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.

clang/lib/Format/UnwrappedLineParser.cpp
3019–3020

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.

3102

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.

+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.

Just put Fixes https://github.com/llvm/llvm-project/issues/123456. in the description please so that the issues gets automatically closed when this patch lands.

HazardyKnusperkeks edited the summary of this revision. (Show Details)Feb 16 2022, 2:50 AM
HazardyKnusperkeks marked 2 inline comments as done.
JohelEGP accepted this revision.Feb 16 2022, 5:01 AM

Thank you.

This revision is now accepted and ready to land.Feb 16 2022, 5:01 AM
curdeius accepted this revision.Feb 16 2022, 5:12 AM

LGTM. Maybe you can add a minimal test in FormatTest.cpp though.

Formatting Test added.

curdeius accepted this revision.Feb 16 2022, 7:40 AM

Formatting Test added.

Thanks!