[PATCH] D150848: [clang-format] Respect ColumnLimit 0 lines breaks in inline asm
Emilia Kond via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 12 06:19:40 PDT 2023
rymiel updated this revision to Diff 530486.
rymiel added a comment.
Apply suggestions from review
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
@@ -4617,6 +4617,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 &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150848.530486.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230612/ebaeaa27/attachment.bin>
More information about the cfe-commits
mailing list