This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] [PR52595] clang-format does not recognize rvalue references to array
ClosedPublic

Authored by MyDeveloperDay on Nov 24 2021, 2:09 AM.

Details

Summary

https://bugs.llvm.org/show_bug.cgi?id=52595

missing space between T(&&) but not between T (& due to && being incorrectly thought of as UnaryOperator rather than PointerOrReference

int operator()(T (&)[N]) { return 0; }
int operator()(T(&&)[N]) { return 1; }

Existing Unit tests are changed because actually I think they are originally incorrect, and are inconsistent with the (&) cases that are 4 or 5 lines above them.

Diff Detail

Event Timeline

MyDeveloperDay requested review of this revision.Nov 24 2021, 2:09 AM
MyDeveloperDay created this revision.
MyDeveloperDay retitled this revision from [clang-format] [PR52595] to [clang-format] [PR52595] clang-format does not recognize rvalue references to array.
MyDeveloperDay edited the summary of this revision. (Show Details)
MyDeveloperDay added inline comments.
clang/unittests/Format/FormatTest.cpp
21891

this test should be consistent with

verifyFormat("operator&(int (&)(), class Foo);", Style);
curdeius added inline comments.Nov 24 2021, 2:24 AM
clang/unittests/Format/FormatTest.cpp
9678

Nit: these are not &/&& operators but references so the test name seems incorrect.

21891

Should we test

verifyFormat("operator&&(int (&)(), class Foo);", Style);

here, and

verifyFormat("operator&(int (&&)(), class Foo);", Style);

above as well?

21954

Ditto for combinations of &+(&&) and &&+(&).

21995

Ditto.

MyDeveloperDay added inline comments.Nov 24 2021, 3:03 AM
clang/unittests/Format/FormatTest.cpp
9678

oh yes sorry that was my bad so I could just run this one test through the debugger, I just needed a unique name, I should change that.

21891

yes I'll add those, nice suggestion

MyDeveloperDay marked 3 inline comments as done.

Add more test combinations

This revision is now accepted and ready to land.Nov 25 2021, 12:56 AM
lichray added inline comments.Nov 25 2021, 1:26 AM
clang/lib/Format/TokenAnnotator.cpp
317

Code does not match comment.