This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Preserve AmpAmpTokenType in nested parentheses
ClosedPublic

Authored by rymiel on Jun 23 2023, 9:01 AM.

Details

Summary

When parsing a requires clause, the UnwrappedLineParser would delegate to
parseParens with an AmpAmpTokenType set to BinaryOperator. However,
parseParens would not carry this over into any nested parens, meaning it
could assign a different token type to an && in a requires clause.

This patch makes sure parseParens inherits its parameter when performing
a recursive call.

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

Diff Detail

Event Timeline

rymiel created this revision.Jun 23 2023, 9:01 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 23 2023, 9:01 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rymiel requested review of this revision.Jun 23 2023, 9:01 AM

@HazardyKnusperkeks I'm not sure why it didn't recurse already, given that you even documented that it doesn't, but I chose to trust in the Beyoncé rule.

@HazardyKnusperkeks I'm not sure why it didn't recurse already, given that you even documented that it doesn't, but I chose to trust in the Beyoncé rule.

Most likely I didn't thought about what you now fixed and wanted to limit the scope of my change. I'm trying to think of something you may broke, but I can't.
Declaring functions should not be possible, if one already set the binary operator, right? Lambdas would be possible, but they should be handled correctly, but I think you could add something with [](T&&){}(t) in a clause, to show that it is correctly parsed.

This revision is now accepted and ready to land.Jun 24 2023, 3:58 AM
rymiel updated this revision to Diff 534220.Jun 24 2023, 8:28 AM

Add annotator test cases involving a lambda

MyDeveloperDay accepted this revision.Jun 24 2023, 8:31 AM
owenpan accepted this revision.Jun 24 2023, 11:50 PM