Skip to content

Commit c1ea05e

Browse files
authored
[clang-format] Don't break short macro call followed by l_paren (#121626)
Fixes #105658.
1 parent 44b83e8 commit c1ea05e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,9 @@ void UnwrappedLineParser::parseStructuralElement(
20442044
? FormatTok->NewlinesBefore > 0
20452045
: CommentsBeforeNextToken.front()->NewlinesBefore > 0;
20462046

2047-
if (FollowedByNewline && (Text.size() >= 5 || FunctionLike) &&
2047+
if (FollowedByNewline &&
2048+
(Text.size() >= 5 ||
2049+
(FunctionLike && FormatTok->isNot(tok::l_paren))) &&
20482050
tokenCanStartNewLine(*FormatTok) && Text == Text.upper()) {
20492051
if (PreviousToken->isNot(TT_UntouchableMacroFunc))
20502052
PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestandingMacro);

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5887,6 +5887,11 @@ TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
58875887
verifyFormat("SOME_WEIRD_LOG_MACRO << SomeThing;", "SOME_WEIRD_LOG_MACRO\n"
58885888
"<< SomeThing;");
58895889

5890+
verifyFormat("GGGG(ffff(xxxxxxxxxxxxxxxxxxxx)->yyyyyyyyyyyyyyyyyyyy)(foo);",
5891+
"GGGG(ffff(xxxxxxxxxxxxxxxxxxxx)->yyyyyyyyyyyyyyyyyyyy)\n"
5892+
"(foo);",
5893+
getLLVMStyleWithColumns(60));
5894+
58905895
verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
58915896
"(n, buffers))",
58925897
getChromiumStyle(FormatStyle::LK_Cpp));

0 commit comments

Comments
 (0)