This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Further improve requires clause detection
ClosedPublic

Authored by HazardyKnusperkeks on Jun 23 2022, 11:11 PM.

Details

Summary

If there is a typeish token before the requires, it can't be a requires expression.

Fixes https://github.com/llvm/llvm-project/issues/56176

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 11:11 PM
HazardyKnusperkeks requested review of this revision.Jun 23 2022, 11:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 11:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan added inline comments.Jun 24 2022, 12:14 AM
clang/lib/Format/UnwrappedLineParser.cpp
3148–3154

It's harder to understand with the default case at the top without a break. See below.

3170–3173

How about this instead?

curdeius accepted this revision.Jun 24 2022, 1:16 AM

LGTM with Owen's suggestion.

clang/lib/Format/UnwrappedLineParser.cpp
3170–3173

👍

clang/unittests/Format/TokenAnnotatorTest.cpp
429
This revision is now accepted and ready to land.Jun 24 2022, 1:16 AM
HazardyKnusperkeks marked 4 inline comments as done.
HazardyKnusperkeks added inline comments.
clang/lib/Format/UnwrappedLineParser.cpp
3170–3173

Didn't want to duplicate the call.

owenpan accepted this revision.Jun 24 2022, 4:27 PM
This revision was automatically updated to reflect the committed changes.
HazardyKnusperkeks marked an inline comment as done.