This revision was automatically updated to reflect the committed changes. Closed by commit rL359687: [clang-format] Fix bug that misses some function-like macro usages (authored by owenpan, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D61297?vs=197275&id=197553#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61297/new/ https://reviews.llvm.org/D61297 Files: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -1335,10 +1335,15 @@ // See if the following token should start a new unwrapped line. StringRef Text = FormatTok->TokenText; nextToken(); - if (Line->Tokens.size() == 1 && - // JS doesn't have macros, and within classes colons indicate fields, - // not labels. - Style.Language != FormatStyle::LK_JavaScript) { + + // JS doesn't have macros, and within classes colons indicate fields, not + // labels. + if (Style.Language == FormatStyle::LK_JavaScript) + break; + + TokenCount = Line->Tokens.size(); + if (TokenCount == 1 || + (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) { if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) { Line->Tokens.begin()->Tok->MustBreakBefore = true; parseLabel(); Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -2584,6 +2584,12 @@ verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), " "(n, buffers))\n", getChromiumStyle(FormatStyle::LK_Cpp)); + + // See PR41483 + EXPECT_EQ("/**/ FOO(a)\n" + "FOO(b)", + format("/**/ FOO(a)\n" + "FOO(b)")); } TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -1335,10 +1335,15 @@ // See if the following token should start a new unwrapped line. StringRef Text = FormatTok->TokenText; nextToken(); - if (Line->Tokens.size() == 1 && - // JS doesn't have macros, and within classes colons indicate fields, - // not labels. - Style.Language != FormatStyle::LK_JavaScript) { + + // JS doesn't have macros, and within classes colons indicate fields, not + // labels. + if (Style.Language == FormatStyle::LK_JavaScript) + break; + + TokenCount = Line->Tokens.size(); + if (TokenCount == 1 || + (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) { if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) { Line->Tokens.begin()->Tok->MustBreakBefore = true; parseLabel(); Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -2584,6 +2584,12 @@ verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), " "(n, buffers))\n", getChromiumStyle(FormatStyle::LK_Cpp)); + + // See PR41483 + EXPECT_EQ("/**/ FOO(a)\n" + "FOO(b)", + format("/**/ FOO(a)\n" + "FOO(b)")); } TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits