This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG7a38b3bfeb56: [clang-format] Respect ColumnLimit 0 line breaks in inline asm (authored by rymiel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150848/new/ https://reviews.llvm.org/D150848 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 @@ -4612,6 +4612,24 @@ format("__asm {\n" "}\n" "int i;")); + + auto Style = getLLVMStyleWithColumns(0); + const StringRef Code1{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));"}; + const StringRef Code2{"asm(\"xyz\"\n" + " : \"=a\"(a), \"=d\"(b)\n" + " : \"a\"(data));"}; + const StringRef Code3{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n" + " : \"a\"(data));"}; + + Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline; + verifyFormat(Code1, Style); + EXPECT_EQ(Code2, format(Code2, Style)); + EXPECT_EQ(Code3, format(Code3, Style)); + + Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always; + EXPECT_EQ(Code2, format(Code1, Style)); + EXPECT_EQ(Code2, format(Code2, Style)); + EXPECT_EQ(Code2, format(Code3, Style)); } TEST_F(FormatTest, FormatTryCatch) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -357,7 +357,8 @@ if (Current.MustBreakBefore || (Current.is(TT_InlineASMColon) && (Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always || - Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline))) { + (Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline && + Style.ColumnLimit > 0)))) { return true; } if (CurrentState.BreakBeforeClosingBrace &&
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -4612,6 +4612,24 @@ format("__asm {\n" "}\n" "int i;")); + + auto Style = getLLVMStyleWithColumns(0); + const StringRef Code1{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));"}; + const StringRef Code2{"asm(\"xyz\"\n" + " : \"=a\"(a), \"=d\"(b)\n" + " : \"a\"(data));"}; + const StringRef Code3{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n" + " : \"a\"(data));"}; + + Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline; + verifyFormat(Code1, Style); + EXPECT_EQ(Code2, format(Code2, Style)); + EXPECT_EQ(Code3, format(Code3, Style)); + + Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always; + EXPECT_EQ(Code2, format(Code1, Style)); + EXPECT_EQ(Code2, format(Code2, Style)); + EXPECT_EQ(Code2, format(Code3, Style)); } TEST_F(FormatTest, FormatTryCatch) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -357,7 +357,8 @@ if (Current.MustBreakBefore || (Current.is(TT_InlineASMColon) && (Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always || - Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline))) { + (Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline && + Style.ColumnLimit > 0)))) { return true; } if (CurrentState.BreakBeforeClosingBrace &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits