Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6da2acf

Browse filesBrowse files
authored
[clang-format] Merge short inline function in macro definition body (#140366)
Fix #62356
1 parent 8231182 commit 6da2acf
Copy full SHA for 6da2acf

File tree

Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed

‎clang/lib/Format/UnwrappedLineFormatter.cpp

Copy file name to clipboardExpand all lines: clang/lib/Format/UnwrappedLineFormatter.cpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ class LineJoiner {
314314
const AnnotatedLine *Line = nullptr;
315315
for (auto J = I - 1; J >= AnnotatedLines.begin(); --J) {
316316
assert(*J);
317-
if ((*J)->InPPDirective || (*J)->isComment() ||
318-
(*J)->Level > TheLine->Level) {
317+
if (((*J)->InPPDirective && !(*J)->InMacroBody) ||
318+
(*J)->isComment() || (*J)->Level > TheLine->Level) {
319319
continue;
320320
}
321321
if ((*J)->Level < TheLine->Level ||

‎clang/unittests/Format/FormatTest.cpp

Copy file name to clipboardExpand all lines: clang/unittests/Format/FormatTest.cpp
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15093,6 +15093,13 @@ TEST_F(FormatTest, PullInlineFunctionDefinitionsIntoSingleLine) {
1509315093
"};",
1509415094
MergeInlineOnly);
1509515095

15096+
MergeInlineOnly.AlignEscapedNewlines = FormatStyle::ENAS_Left;
15097+
verifyFormat("#define Foo \\\n"
15098+
" struct S { \\\n"
15099+
" void foo() { return; } \\\n"
15100+
" }",
15101+
MergeInlineOnly);
15102+
1509615103
// Also verify behavior when BraceWrapping.AfterFunction = true
1509715104
MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
1509815105
MergeInlineOnly.BraceWrapping.AfterFunction = true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.