This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Mark pragma region lines as StringLiterals
ClosedPublic

Authored by thieta on Oct 20 2022, 4:34 AM.

Details

Summary

In our code-base we auto-generate pragma regions the regions
look like method signatures like:

#pragma region MYREGION(Foo: bar)

The problem here was that the rest of the line after region
was not marked as stringliteral as in the case of pragma mark
so clang-format tried to change the formatting based on the
method signature.

Added test and mark it similar as pragma mark.

Diff Detail

Event Timeline

thieta created this revision.Oct 20 2022, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 4:34 AM
thieta requested review of this revision.Oct 20 2022, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 4:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you add a test to TokenAnnotatorTest.cpp?

clang/unittests/Format/FormatTest.cpp
19973–19974

Redundant?

thieta updated this revision to Diff 470092.Oct 24 2022, 2:17 AM

Added TokenAnnotatorTest and removed reduntant FormatTests

Can you add a test to TokenAnnotatorTest.cpp?

Thanks for the review. Fixed it.

Can you run git-clang-format?

clang/lib/Format/TokenAnnotator.cpp
1340

Over 80 columns.

clang/unittests/Format/TokenAnnotatorTest.cpp
9 ↗(On Diff #470092)

Extraneous.

thieta updated this revision to Diff 470380.Oct 24 2022, 11:18 PM

git clang-format
removed accidental include

thieta marked 3 inline comments as done.Oct 24 2022, 11:19 PM
This revision is now accepted and ready to land.Oct 24 2022, 11:46 PM
This revision was landed with ongoing or failed builds.Oct 25 2022, 12:59 AM
This revision was automatically updated to reflect the committed changes.
owenpan added a project: Restricted Project.Oct 25 2022, 1:32 AM
HazardyKnusperkeks added inline comments.
clang/lib/Format/TokenAnnotator.cpp
1344

This shouldn't be here. There is no closing brace for this, or am I missing something?

clang/unittests/Format/TokenAnnotatorTest.cpp
653 ↗(On Diff #470395)

Maybe you can add that in a additional commit.

thieta added inline comments.Oct 25 2022, 1:24 PM
clang/lib/Format/TokenAnnotator.cpp
1344

No you are right it was a miss in the rebase. But it's fixed on main now.

owenpan added inline comments.Oct 26 2022, 12:13 AM
clang/lib/Format/TokenAnnotator.cpp
1344

Probably caused by https://github.com/llvm/llvm-project/issues/58161, which was fixed in 37e754e5801c.