This revision was automatically updated to reflect the committed changes. Closed by commit rG47a9eb2117aa: [clang-format] Fix break being added to macro define with ColumnLimit: 0 (authored by futuarmo, committed by curdeius).
Changed prior to commit: https://reviews.llvm.org/D116859?vs=399394&id=399906#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116859/new/ https://reviews.llvm.org/D116859 Files: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -4804,6 +4804,13 @@ Style); } +TEST_F(FormatTest, FormatsMacrosWithZeroColumnWidth) { + FormatStyle ZeroColumn = getLLVMStyleWithColumns(0); + + verifyFormat("#define A LOOOOOOOOOOOOOOOOOOONG() LOOOOOOOOOOOOOOOOOOONG()", + ZeroColumn); +} + TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) { verifyFormat("#define A \\\n" " f({ \\\n" @@ -19600,15 +19607,13 @@ TEST_F(FormatTest, CountsUTF8CharactersProperly) { verifyFormat("\"ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ...\"", getLLVMStyleWithColumns(35)); - verifyFormat("\"ä¸ äº ä¸ å äº å ä¸ å « ä¹ å\"", - getLLVMStyleWithColumns(31)); + verifyFormat("\"ä¸ äº ä¸ å äº å ä¸ å « ä¹ å\"", getLLVMStyleWithColumns(31)); verifyFormat("// ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ...", getLLVMStyleWithColumns(36)); verifyFormat("// ä¸ äº ä¸ å äº å ä¸ å « ä¹ å", getLLVMStyleWithColumns(32)); verifyFormat("/* ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ... */", getLLVMStyleWithColumns(39)); - verifyFormat("/* ä¸ äº ä¸ å äº å ä¸ å « ä¹ å */", - getLLVMStyleWithColumns(35)); + verifyFormat("/* ä¸ äº ä¸ å äº å ä¸ å « ä¹ å */", getLLVMStyleWithColumns(35)); } TEST_F(FormatTest, SplitsUTF8Strings) { @@ -19628,21 +19633,20 @@ "\"поÑÑ,\"", format("\"ÐднаждÑ, в ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ,\"", getLLVMStyleWithColumns(13))); + EXPECT_EQ("\"ä¸ äº ä¸ \"\n" + "\"å äºå \"\n" + "\"ä¸ å « ä¹ \"\n" + "\"å\"", + format("\"ä¸ äº ä¸ å äºå ä¸ å « ä¹ å\"", getLLVMStyleWithColumns(11))); EXPECT_EQ( - "\"ä¸ äº ä¸ \"\n" - "\"å äºå \"\n" - "\"ä¸ å « ä¹ \"\n" - "\"å\"", - format("\"ä¸ äº ä¸ å äºå ä¸ å « ä¹ å\"", getLLVMStyleWithColumns(11))); - EXPECT_EQ("\"ä¸\t\"\n" - "\"äº \t\"\n" - "\"ä¸ å \"\n" - "\"äº\t\"\n" - "\"å \t\"\n" - "\"ä¸ \"\n" - "\"å «ä¹å\tqq\"", - format("\"ä¸\täº \tä¸ å äº\tå \tä¸ å «ä¹å\tqq\"", - getLLVMStyleWithColumns(11))); + "\"ä¸\t\"\n" + "\"äº \t\"\n" + "\"ä¸ å \"\n" + "\"äº\t\"\n" + "\"å \t\"\n" + "\"ä¸ \"\n" + "\"å «ä¹å\tqq\"", + format("\"ä¸\täº \tä¸ å äº\tå \tä¸ å «ä¹å\tqq\"", getLLVMStyleWithColumns(11))); // UTF8 character in an escape sequence. EXPECT_EQ("\"aaaaaa\"\n" @@ -19687,16 +19691,16 @@ format("/* ÐлÑжÑ, поднимаеÑÑÑ Ð¼ÐµÐ´Ð»ÐµÐ½Ð½Ð¾ в гоÑÑ\n" " * ÐоÑадка, везÑÑÐ°Ñ Ñ Ð²Ð¾ÑоÑÑÑ Ð²Ð¾Ð·. */", getLLVMStyleWithColumns(13))); - EXPECT_EQ( - "/* ä¸äºä¸\n" - " * åäºå ä¸\n" - " * å « ä¹\n" - " * å */", - format("/* ä¸äºä¸ åäºå ä¸ å « ä¹ å */", getLLVMStyleWithColumns(9))); + EXPECT_EQ("/* ä¸äºä¸\n" + " * åäºå ä¸\n" + " * å « ä¹\n" + " * å */", + format("/* ä¸äºä¸ åäºå ä¸ å « ä¹ å */", getLLVMStyleWithColumns(9))); EXPECT_EQ("/* ð£ð®ð¼ð½ ð£ð¬ð²ð¯\n" " * ððªð¥ð\n" " * ðð¿ð±-ð */", - format("/* ð£ð®ð¼ð½ ð£ð¬ð²ð¯ ððªð¥ð ðð¿ð±-ð */", getLLVMStyleWithColumns(12))); + format("/* ð£ð®ð¼ð½ ð£ð¬ð²ð¯ ððªð¥ð ðð¿ð±-ð */", + getLLVMStyleWithColumns(12))); } #endif // _MSC_VER Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -485,7 +485,8 @@ // different LineFormatter would be used otherwise. if (Previous.ClosesTemplateDeclaration) return Style.AlwaysBreakTemplateDeclarations != FormatStyle::BTDS_No; - if (Previous.is(TT_FunctionAnnotationRParen)) + if (Previous.is(TT_FunctionAnnotationRParen) && + State.Line->Type != LT_PreprocessorDirective) return true; if (Previous.is(TT_LeadingJavaAnnotation) && Current.isNot(tok::l_paren) && Current.isNot(TT_LeadingJavaAnnotation))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits