Index: clang/docs/ClangFormatStyleOptions.rst =================================================================== --- clang/docs/ClangFormatStyleOptions.rst +++ clang/docs/ClangFormatStyleOptions.rst @@ -1382,6 +1382,20 @@ +**BreakBeforeInlineASMColon** (``bool``) + If ``true``, colons in ASM parameters will be placed after line breaks. + + .. code-block:: c++ + + true: + asm volatile("loooooooooooooooooooooooooooooooooooooooooooooong", + : + : val); + + false: + asm volatile("loooooooooooooooooooooooooooooooooooooooooooooong", + : : val); + **BreakBeforeStructInitialization** (``bool``) If ``true``, struct left brace will be placed after line breaks. Index: clang/include/clang/Format/Format.h =================================================================== --- clang/include/clang/Format/Format.h +++ clang/include/clang/Format/Format.h @@ -1160,6 +1160,19 @@ /// \endcode BraceWrappingFlags BraceWrapping; + /// If ``true``, colons in ASM parameters will be placed after line breaks. + /// \code + /// true: + /// asm volatile("loooooooooooooooooooooooooooooooooooooooooooooong", + /// : + /// : val); + /// + /// false: + /// asm volatile("loooooooooooooooooooooooooooooooooooooooooooooong", + /// : : val); + /// \endcode + bool BreakBeforeInlineASMColon; + /// If ``true``, struct left brace will be placed after line breaks. /// \code /// true: @@ -2448,6 +2461,7 @@ BinPackParameters == R.BinPackParameters && BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators && BreakBeforeBraces == R.BreakBeforeBraces && + BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon && BreakBeforeStructInitialization == R.BreakBeforeStructInitialization && BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators && BreakConstructorInitializers == R.BreakConstructorInitializers && Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -334,7 +334,7 @@ auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack); return (LambdaBodyLength > getColumnLimit(State)); } - if (Current.MustBreakBefore || Current.is(TT_InlineASMColon)) + if (Current.MustBreakBefore || (Current.is(TT_InlineASMColon) && Style.BreakBeforeInlineASMColon)) return true; if (State.Stack.back().BreakBeforeClosingBrace && Current.closesBlockOrBlockTypeList(Style)) Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -513,6 +513,9 @@ Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma; + IO.mapOptional("BreakBeforeInlineASMColon", + Style.BreakBeforeInlineASMColon); + IO.mapOptional("BreakBeforeStructInitialization", Style.BreakBeforeStructInitialization); Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -5046,6 +5046,20 @@ format(Input, Style)); } +TEST_F(FormatTest, BreakBeforeInlineASMColon) { + FormatStyle Style = getLLVMStyle(); + Style.ColumnLimit = 80; + Style.BreakBeforeInlineASMColon = false; + verifyFormat("asm volatile(\"loooooooooooooooooooooooooooooooooooooooooooooong\",\n" + ": : val);", + Style); + Style.BreakBeforeInlineASMColon = true; + verifyFormat("asm volatile(\"loooooooooooooooooooooooooooooooooooooooooooooong\",\n" + ":" + ": val);", + Style); +} + TEST_F(FormatTest, BreakBeforeStructInitialization) { FormatStyle Style = getLLVMStyle(); Style.ColumnLimit = 80;