Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0aed33

Browse files
authored
[clang-format] Align stuff containing multi-line comment (#195398)
Fixes #194717. Previously the information about the comment's scope could get lost. Then the program would not align it. new ```C++ foo fooNode(ConvertStdStringToUString(fieldNames[chIdx]), // asdf // foo1 foo2 foo12345 SomeFunctionAB(a123456789012345)); const size_t v1234567890123456789012345678901234; ``` old ```C++ foo fooNode(ConvertStdStringToUString(fieldNames[chIdx]), // asdf // foo1 foo2 foo12345 SomeFunctionAB(a123456789012345)); const size_t v1234567890123456789012345678901234; ```
1 parent 4a4a0ba commit a0aed33

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

clang/lib/Format/BreakableToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ void BreakableLineCommentSection::adaptStartOfLine(
11201120
/*Spaces=*/LineColumn,
11211121
/*StartOfTokenColumn=*/LineColumn,
11221122
/*AlignedTo=*/tokenAt(0).NewlinesBefore == 0 ? &tokenAt(0) : nullptr,
1123-
/*InPPDirective=*/false);
1123+
/*InPPDirective=*/false, /*IndentedFromColumn=*/StartColumn);
11241124
}
11251125
if (OriginalPrefix[LineIndex] != Prefix[LineIndex]) {
11261126
// Adjust the prefix if necessary.

clang/unittests/Format/AlignmentTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,13 @@ TEST_F(AlignmentTest, ConsecutiveDeclarations) {
12801280
verifyFormat("int a = method();\n"
12811281
"float const oneTwoThree = 133;",
12821282
Alignment);
1283+
verifyFormat(
1284+
"foo fooNode(ConvertStdStringToUString(fieldNames[chIdx]),\n"
1285+
" // asdf\n"
1286+
" // foo1 foo2 foo12345\n"
1287+
" SomeFunctionAB(a123456789012345));\n"
1288+
"const size_t v1234567890123456789012345678901234;",
1289+
Alignment);
12831290
verifyFormat("int i = 1, j = 10;\n"
12841291
"something = 2000;",
12851292
Alignment);

0 commit comments

Comments
 (0)