This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Respect ColumnLimit 0 line breaks in inline asm
ClosedPublic

Authored by rymiel on May 18 2023, 12:29 AM.

Details

Summary

Previously, using ColumnLimit: 0 with extended inline asm with the
BreakBeforeInlineASMColon: OnlyMultiline option (the default style),
the formatter would act as if in Always mode, meaning a line break was
added before every colon in an extended inline assembly block.

This patch respects the already existing line breaks, and doesn't add
any new ones, if in ColumnLimit 0 mode.

Behaviour with Always stays as expected, with a break before every colon
regardless of any existing line breaks.

Behaviour with Never was broken before, and remains broken with this patch,
it is just never respected in ColumnLimit 0 mode.

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

Diff Detail

Event Timeline

rymiel created this revision.May 18 2023, 12:29 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 18 2023, 12:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rymiel requested review of this revision.May 18 2023, 12:29 AM
This revision is now accepted and ready to land.May 18 2023, 12:54 AM
owenpan accepted this revision.May 24 2023, 10:05 PM
owenpan added inline comments.
clang/lib/Format/ContinuationIndenter.cpp
361

FWIW.

clang/unittests/Format/FormatTest.cpp
4617–4650

FWIW, it's easier to read IMO.

rymiel updated this revision to Diff 530486.Jun 12 2023, 6:19 AM

Apply suggestions from review

rymiel marked 2 inline comments as done.Jun 12 2023, 6:20 AM
rymiel retitled this revision from [clang-format] Respect ColumnLimit 0 lines breaks in inline asm to [clang-format] Respect ColumnLimit 0 line breaks in inline asm.
owenpan accepted this revision.Jun 12 2023, 11:25 AM
This revision was landed with ongoing or failed builds.Jun 23 2023, 7:35 AM
This revision was automatically updated to reflect the committed changes.
owenpan added inline comments.Jun 25 2023, 12:13 AM
clang/unittests/Format/FormatTest.cpp
4626–4627

We have verifyNoChange now. See D153109.

4630–4632
rymiel marked 2 inline comments as done.Jun 26 2023, 2:20 AM
rymiel added inline comments.
clang/unittests/Format/FormatTest.cpp
4626–4627

Sorry, this patch was so old and I forgot that refactor happened, thanks for reminding me, i pushed https://github.com/llvm/llvm-project/commit/6e39b0ddf08ab5cd44fed2d16e9669d64aa733ef