Skip to content

Commit 3b171cb

Browse files
authored
[clang-format] Fix a bug in ContinuationIndenter (#78921)
Fixes #76991.
1 parent 4beb723 commit 3b171cb

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
@@ -740,7 +740,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
740740

741741
if (!DryRun) {
742742
Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces,
743-
State.Column + Spaces + PPColumnCorrection);
743+
State.Column + Spaces + PPColumnCorrection,
744+
/*IsAligned=*/false, State.Line->InMacroBody);
744745
}
745746

746747
// 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
@@ -21215,6 +21215,13 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
2121521215
"});",
2121621216
Style);
2121721217

21218+
Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
21219+
verifyFormat("#define FOO \\\n"
21220+
" int foo[][2] = { \\\n"
21221+
" {0, 1} \\\n"
21222+
" };",
21223+
Style);
21224+
2121821225
Style.Cpp11BracedListStyle = false;
2121921226
verifyFormat("struct test demo[] = {\n"
2122021227
" { 56, 23, \"hello\" },\n"

0 commit comments

Comments
 (0)