Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -657,7 +657,8 @@ ++Column; break; case '\t': - Column += Style.TabWidth - Column % Style.TabWidth; + Column += + Style.TabWidth - (Style.TabWidth ? Column % Style.TabWidth : 0); break; case '\\': if (i + 1 == e || (Text[i + 1] != '\r' && Text[i + 1] != '\n')) Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -815,19 +815,24 @@ Text.append(Spaces, ' '); break; case FormatStyle::UT_Always: { - unsigned FirstTabWidth = - Style.TabWidth - WhitespaceStartColumn % Style.TabWidth; - // Insert only spaces when we want to end up before the next tab. - if (Spaces < FirstTabWidth || Spaces == 1) { + if (Style.TabWidth) { + unsigned FirstTabWidth = + Style.TabWidth - WhitespaceStartColumn % Style.TabWidth; + + // Insert only spaces when we want to end up before the next tab. + if (Spaces < FirstTabWidth || Spaces == 1) { + Text.append(Spaces, ' '); + break; + } + // Align to the next tab. + Spaces -= FirstTabWidth; + Text.append("\t"); + + Text.append(Spaces / Style.TabWidth, '\t'); + Text.append(Spaces % Style.TabWidth, ' '); + } else if (Spaces == 1) { Text.append(Spaces, ' '); - break; } - // Align to the next tab. - Spaces -= FirstTabWidth; - Text.append("\t"); - - Text.append(Spaces / Style.TabWidth, '\t'); - Text.append(Spaces % Style.TabWidth, ' '); break; } case FormatStyle::UT_ForIndentation: @@ -837,14 +842,16 @@ // the first one. if (Indentation > Spaces) Indentation = Spaces; - unsigned Tabs = Indentation / Style.TabWidth; - Text.append(Tabs, '\t'); - Spaces -= Tabs * Style.TabWidth; + if (Style.TabWidth) { + unsigned Tabs = Indentation / Style.TabWidth; + Text.append(Tabs, '\t'); + Spaces -= Tabs * Style.TabWidth; + } } Text.append(Spaces, ' '); break; case FormatStyle::UT_ForContinuationAndIndentation: - if (WhitespaceStartColumn == 0) { + if (WhitespaceStartColumn == 0 && Style.TabWidth) { unsigned Tabs = Spaces / Style.TabWidth; Text.append(Tabs, '\t'); Spaces -= Tabs * Style.TabWidth; Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -1596,7 +1596,7 @@ TEST_F(FormatTest, BreakInheritanceStyle) { FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle(); StyleWithInheritanceBreakBeforeComma.BreakInheritanceList = - FormatStyle::BILS_BeforeComma; + FormatStyle::BILS_BeforeComma; verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreakBeforeComma); verifyFormat("class MyClass\n" @@ -1614,7 +1614,7 @@ FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle(); StyleWithInheritanceBreakAfterColon.BreakInheritanceList = - FormatStyle::BILS_AfterColon; + FormatStyle::BILS_AfterColon; verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreakAfterColon); verifyFormat("class MyClass : public X, public Y {};", @@ -2086,8 +2086,8 @@ Style.NamespaceMacros.push_back("TESTSUITE"); verifyFormat("namespace A { namespace B {\n" - "}} // namespace A::B", - Style); + "}} // namespace A::B", + Style); EXPECT_EQ("namespace out { namespace in {\n" "}} // namespace out::in", @@ -4450,28 +4450,28 @@ "SomeClass::Constructor() :\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaaaa(aaaaaaaaaaaa) {}", - Style); + Style); verifyFormat("Constructor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) :\n" " aaaaaaaaaa(aaaaaa) {}", - Style); + Style); verifyFormat("Constructor() :\n" " aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaaaaaaaaaaaa() {}", - Style); + Style); verifyFormat("Constructor() :\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}", - Style); + Style); verifyFormat("Constructor(int Parameter = 0) :\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}", - Style); + Style); verifyFormat("Constructor() :\n" " aaaaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {\n" "}", @@ -4479,7 +4479,7 @@ verifyFormat("Constructor() :\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {}", - Style); + Style); // Here a line could be saved by splitting the second initializer onto two // lines, but that is not desirable. @@ -4487,7 +4487,7 @@ " aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaa(aaaaaaaaaaa),\n" " aaaaaaaaaaaaaaaaaaaaat(aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}", - Style); + Style); FormatStyle OnePerLine = Style; OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true; @@ -4521,10 +4521,10 @@ OnePerLine.BinPackParameters = false; verifyFormat( "Constructor() :\n" - " aaaaaaaaaaaaaaaaaaaaaaaa(\n" - " aaaaaaaaaaa().aaa(),\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}", - OnePerLine); + " aaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaa().aaa(),\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}", + OnePerLine); OnePerLine.ColumnLimit = 60; verifyFormat("Constructor() :\n" " aaaaaaaaaaaaaaaaaaaa(a),\n" @@ -4537,7 +4537,7 @@ format("Constructor() :\n" " // Comment forcing unwanted break.\n" " aaaa(aaaa) {}", - Style)); + Style)); Style.ColumnLimit = 0; verifyFormat("SomeClass::Constructor() :\n" @@ -4547,7 +4547,7 @@ " a(a) {}", Style); verifyFormat("SomeClass::Constructor() :\n" - " a(a), b(b), c(c) {}", + " a(a), b(b), c(c) {}", Style); verifyFormat("SomeClass::Constructor() :\n" " a(a) {\n" @@ -4558,12 +4558,12 @@ Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None; verifyFormat("SomeClass::Constructor() :\n" - " a(a), b(b), c(c) {\n" - "}", + " a(a), b(b), c(c) {\n" + "}", Style); verifyFormat("SomeClass::Constructor() :\n" " a(a) {\n" - "}", + "}", Style); Style.ColumnLimit = 80; @@ -4579,19 +4579,19 @@ // `ConstructorInitializerIndentWidth` actually applies to InheritanceList as well Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon; verifyFormat("class SomeClass\n" - " : public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" - " public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", - Style); + " : public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", + Style); Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma; verifyFormat("class SomeClass\n" - " : public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" - " , public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", - Style); + " : public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " , public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", + Style); Style.BreakInheritanceList = FormatStyle::BILS_AfterColon; verifyFormat("class SomeClass :\n" - " public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" - " public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", - Style); + " public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};", + Style); } #ifndef EXPENSIVE_CHECKS @@ -4779,9 +4779,9 @@ " bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}"); verifyGoogleFormat( "template \n" - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" - "aaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaa(\n" - " aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);"); + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + "aaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);"); FormatStyle Style = getLLVMStyle(); Style.PointerAlignment = FormatStyle::PAS_Left; @@ -5156,9 +5156,9 @@ " aaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();"); verifyFormat( "aaaaaaa->aaaaaaa\n" - " ->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" - " ->aaaaaaaa(aaaaaaaaaaaaaaa);"); + " ->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " ->aaaaaaaa(aaaaaaaaaaaaaaa);"); verifyFormat( "aaaaaaa->aaaaaaa\n" " ->aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" @@ -5517,8 +5517,8 @@ " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); verifyFormat( "aaaa(aaaaaaaaa, aaaaaaaaa,\n" - " aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" - " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + " aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa ? aaaa(aaaaaa)\n" " : aaaaaaaaaaaaa);"); @@ -5662,9 +5662,9 @@ Style); verifyFormat( "aaaa(aaaaaaaa, aaaaaaaaaa,\n" - " aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);", - Style); + " aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);", + Style); verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa ? aaaa(aaaaaa) :\n" " aaaaaaaaaaaaa);", @@ -6562,20 +6562,20 @@ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None; verifyFormat( "template struct s {};\n" - "extern s<\n" + "extern s<\n" " aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa>\n" - " y;", - Style); + " y;", + Style); Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All; verifyFormat( "template struct t {};\n" - "extern t<\n" + "extern t<\n" " aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa>\n" - " y;", - Style); + " y;", + Style); } TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) { @@ -6604,10 +6604,10 @@ verifyFormat( "aaaaaaaaaaaaaaaaaa(aaaaaaaa,\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" - " aaaaaaaaaaaaaaaaaaaaa);", - getLLVMStyleWithColumns(74)); + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaa);", + getLLVMStyleWithColumns(74)); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" @@ -7077,12 +7077,12 @@ getLLVMStyleWithColumns(70)); verifyFormat( "template ::value &&\n" - " (sizeof(T) > 1 || sizeof(T) < 8)>::type,\n" - " class U>\n" - "void F();", - getLLVMStyleWithColumns(70)); + " class = typename std::enable_if<\n" + " std::is_integral::value &&\n" + " (sizeof(T) > 1 || sizeof(T) < 8)>::type,\n" + " class U>\n" + "void F();", + getLLVMStyleWithColumns(70)); verifyFormat( "template bbbbbbbbbbbb = [&]() { return true; },\n" - " aaaaa aaaaaaaaa);"); + " std::function bbbbbbbbbbbb = [&]() { return true; },\n" + " aaaaa aaaaaaaaa);"); // Lambdas with return types. verifyFormat("int c = []() -> int { return 2; }();\n"); @@ -12822,77 +12895,77 @@ verifyFormat("[]() -> foo<5 < 2> { return {}; };"); verifyFormat("[]() -> foo<2 ? 1 : 0> { return {}; };"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 + 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 + 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 - 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 - 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 / 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 / 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 * 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 * 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 % 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 % 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 << 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 << 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<~5> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<~5> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 | 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 | 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 || 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 || 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 & 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 & 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 && 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 && 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 == 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 == 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 != 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 != 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 >= 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 >= 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 <= 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 <= 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<5 < 2> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<5 < 2> { return {}; }};\n" + "} // namespace bar"); verifyFormat("namespace bar {\n" - "// broken:\n" - "auto foo{[]() -> foo<2 ? 1 : 0> { return {}; }};\n" - "} // namespace bar"); + "// broken:\n" + "auto foo{[]() -> foo<2 ? 1 : 0> { return {}; }};\n" + "} // namespace bar"); verifyFormat("[]() -> a<1> {};"); verifyFormat("[]() -> a<1> { ; };"); verifyFormat("[]() -> a<1> { ; }();"); @@ -12965,11 +13038,11 @@ // A lambda with a very long line forces arg0 to be pushed out irrespective of // the BinPackArguments value (as long as the code is wide enough). verifyFormat("something->SomeFunction(\n" - " a,\n" - " [this] {\n" + " a,\n" + " [this] {\n" " D0000000000000000000000000000000000000000000000000000000000001();\n" - " },\n" - " b);\n"); + " },\n" + " b);\n"); // A multi-line lambda is pulled up as long as the introducer fits on the previous // line and there are no further args. @@ -13552,22 +13625,22 @@ // Don't reflow comments within disabled regions. EXPECT_EQ( "// clang-format off\n" - "// long long long long long long line\n" - "/* clang-format on */\n" - "/* long long long\n" - " * long long long\n" - " * line */\n" - "int i;\n" - "/* clang-format off */\n" - "/* long long long long long long line */\n", - format("// clang-format off\n" - "// long long long long long long line\n" - "/* clang-format on */\n" - "/* long long long long long long line */\n" - "int i;\n" - "/* clang-format off */\n" - "/* long long long long long long line */\n", - getLLVMStyleWithColumns(20))); + "// long long long long long long line\n" + "/* clang-format on */\n" + "/* long long long\n" + " * long long long\n" + " * line */\n" + "int i;\n" + "/* clang-format off */\n" + "/* long long long long long long line */\n", + format("// clang-format off\n" + "// long long long long long long line\n" + "/* clang-format on */\n" + "/* long long long long long long line */\n" + "int i;\n" + "/* clang-format off */\n" + "/* long long long long long long line */\n", + getLLVMStyleWithColumns(20))); } TEST_F(FormatTest, DoNotCrashOnInvalidInput) { @@ -13923,34 +13996,34 @@ TEST_F(FormatTest, GuessedLanguageWithInlineAsmClobbers) { EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" - " asm (\"mov %[e], %[d]\"\n" - " : [d] \"=rm\" (d)\n" - " [e] \"rm\" (*e));\n" - "}")); + " asm (\"mov %[e], %[d]\"\n" + " : [d] \"=rm\" (d)\n" + " [e] \"rm\" (*e));\n" + "}")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" - " _asm (\"mov %[e], %[d]\"\n" - " : [d] \"=rm\" (d)\n" - " [e] \"rm\" (*e));\n" - "}")); + " _asm (\"mov %[e], %[d]\"\n" + " : [d] \"=rm\" (d)\n" + " [e] \"rm\" (*e));\n" + "}")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" - " __asm (\"mov %[e], %[d]\"\n" - " : [d] \"=rm\" (d)\n" - " [e] \"rm\" (*e));\n" - "}")); + " __asm (\"mov %[e], %[d]\"\n" + " : [d] \"=rm\" (d)\n" + " [e] \"rm\" (*e));\n" + "}")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" - " __asm__ (\"mov %[e], %[d]\"\n" - " : [d] \"=rm\" (d)\n" - " [e] \"rm\" (*e));\n" - "}")); + " __asm__ (\"mov %[e], %[d]\"\n" + " : [d] \"=rm\" (d)\n" + " [e] \"rm\" (*e));\n" + "}")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" - " asm (\"mov %[e], %[d]\"\n" - " : [d] \"=rm\" (d),\n" - " [e] \"rm\" (*e));\n" - "}")); + " asm (\"mov %[e], %[d]\"\n" + " : [d] \"=rm\" (d),\n" + " [e] \"rm\" (*e));\n" + "}")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "void f() {\n" " asm volatile (\"mov %[e], %[d]\"\n"