This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] fix nested angle brackets parse inside concept definition
ClosedPublic

Authored by predelnik on Apr 16 2022, 12:30 AM.

Details

Summary

Due to how parseBracedList always stopped on the first closing angle
bracket and was used in parsing angle bracketed expression inside concept
definition, nested brackets inside concepts were parsed incorrectly.

nextToken() call before calling parseBracedList is required because
we were processing opening angle bracket inside parseBracedList second
time leading to incorrect logic after my fix.

Fixes https://github.com/llvm/llvm-project/issues/54943
Fixes https://github.com/llvm/llvm-project/issues/54837

Diff Detail

Event Timeline

predelnik created this revision.Apr 16 2022, 12:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2022, 12:30 AM
predelnik requested review of this revision.Apr 16 2022, 12:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2022, 12:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
predelnik added a reviewer: Restricted Project.Apr 16 2022, 12:54 AM

Is there an issue report for this bug already?

Could you please add an annotator test as well?

Is there an issue report for this bug already?

I could create an issue if that is required.

Could you please add an annotator test as well?

Will look into that, thank you for reviewing.

predelnik updated this revision to Diff 423231.Apr 16 2022, 1:48 AM

Added annotator test, checked that it fails without a patch

I've created the issue here:
https://github.com/llvm/llvm-project/issues/54943
It also seems to fix the other issue I reported which was partially fixed before this change in master:
https://github.com/llvm/llvm-project/issues/54837

predelnik updated this revision to Diff 423234.Apr 16 2022, 6:04 AM
predelnik edited the summary of this revision. (Show Details)

Added issue links to commit message

As this is still on my todo list: Have you considered

concept X = Bar<5 < 4, 5 > 8>;
concept X = Bar<5 < 4, false>;

Or stuff like that?

HazardyKnusperkeks removed a reviewer: Restricted Project.Apr 21 2022, 2:40 AM

As this is still on my todo list: Have you considered

concept X = Bar<5 < 4, 5 > 8>;
concept X = Bar<5 < 4, false>;

Or stuff like that?

I think it would not work but would not make things much worse than before, have to check that though.
Looks like parseBracedList probably would not be enough for correct parsing of such expressions, is there any better approach?

I see now, would certainly like to help but it sounds like I might not be competent enough for this. I guess this review could be closed unless it's an acceptable half-measure, not sure.

No I think it is a step in the right direction. It will help in common cases, and I still don't know when I will have the time to work on that.
But you are very welcome to join the review, and of course adding patches. :)

This revision is now accepted and ready to land.Apr 21 2022, 11:33 AM
curdeius accepted this revision.Apr 21 2022, 11:58 AM

LGTM. Thank you!

Do you need help landing this?

curdeius edited the summary of this revision. (Show Details)May 11 2022, 2:57 AM

Probably, yes. I didn't know I have to do it myself, sorry.

Ok I've found it on a guide here at last https://llvm.org/docs/MyFirstTypoFix.html
Please land a patch for me, @curdeius, my author data is “Sergey Semushin predelnik@gmail.com”
Thank you.

This revision was landed with ongoing or failed builds.May 11 2022, 5:03 AM
This revision was automatically updated to reflect the committed changes.