Skip to content

Commit bc3f566

Browse files
committed
[clang-format] Fix a bug in ContinuationIndenter
Fixes llvm#76991.
1 parent a464e05 commit bc3f566

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
738738

739739
if (!DryRun) {
740740
Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces,
741-
State.Column + Spaces + PPColumnCorrection);
741+
State.Column + Spaces + PPColumnCorrection,
742+
/*IsAligned=*/false, State.Line->InMacroBody);
742743
}
743744

744745
// If "BreakBeforeInheritanceComma" mode, don't break within the inheritance

clang/lib/Format/WhitespaceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class WhitespaceManager {
5555
/// this replacement. It is needed for determining how \p Spaces is turned
5656
/// into tabs and spaces for some format styles.
5757
void replaceWhitespace(FormatToken &Tok, unsigned Newlines, unsigned Spaces,
58-
unsigned StartOfTokenColumn, bool isAligned = false,
58+
unsigned StartOfTokenColumn, bool IsAligned = false,
5959
bool InPPDirective = false);
6060

6161
/// Adds information about an unchangeable token's whitespace.

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21203,6 +21203,13 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
2120321203
"});",
2120421204
Style);
2120521205

21206+
Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
21207+
verifyFormat("#define FOO \\\n"
21208+
" int foo[][2] = { \\\n"
21209+
" {0, 1} \\\n"
21210+
" };",
21211+
Style);
21212+
2120621213
Style.Cpp11BracedListStyle = false;
2120721214
verifyFormat("struct test demo[] = {\n"
2120821215
" { 56, 23, \"hello\" },\n"

0 commit comments

Comments
 (0)