Skip to content

Commit 75f6a79

Browse files
[clang-format] Fix aligning with linebreaks #2
This amends c5243c6 to fix formatting continued function calls with BinPacking = false. Differential Revision: https://reviews.llvm.org/D106773
1 parent 92b758c commit 75f6a79

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
347347
if (ScopeStart > Start + 1 &&
348348
Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
349349
Changes[ScopeStart - 1].Tok->is(tok::l_paren))
350-
return true;
350+
return Style.BinPackArguments;
351351

352352
// Ternary operator
353353
if (Changes[i].Tok->is(TT_ConditionalExpr))

clang/unittests/Format/FormatTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16419,6 +16419,37 @@ TEST_F(FormatTest, AlignWithLineBreaks) {
1641916419
"}",
1642016420
Style);
1642116421
// clang-format on
16422+
16423+
Style = getLLVMStyleWithColumns(120);
16424+
Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
16425+
Style.ContinuationIndentWidth = 4;
16426+
Style.IndentWidth = 4;
16427+
16428+
// clang-format off
16429+
verifyFormat("void SomeFunc() {\n"
16430+
" newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n"
16431+
" seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16432+
" newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n"
16433+
" seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16434+
" newWatcher.max = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n"
16435+
" seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16436+
"}",
16437+
Style);
16438+
// clang-format on
16439+
16440+
Style.BinPackArguments = false;
16441+
16442+
// clang-format off
16443+
verifyFormat("void SomeFunc() {\n"
16444+
" newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(\n"
16445+
" FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16446+
" newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(\n"
16447+
" FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16448+
" newWatcher.max = ToLegacyTimestamp(GetMaxAge(\n"
16449+
" FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n"
16450+
"}",
16451+
Style);
16452+
// clang-format on
1642216453
}
1642316454

1642416455
TEST_F(FormatTest, AlignWithInitializerPeriods) {

0 commit comments

Comments
 (0)