Lines Matching defs:Style

49   auto Style = getLLVMStyle();
50 Style.KeepEmptyLines.AtStartOfFile = false;
51 verifyFormat("int i;", " \n\t \v \f int i;", Style);
390 FormatStyle Style = getLLVMStyle();
391 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
392 Style.MaxEmptyLinesToKeep = 2;
393 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
394 Style.BraceWrapping.AfterClass = true;
395 Style.BraceWrapping.AfterFunction = true;
396 Style.KeepEmptyLines.AtStartOfBlock = false;
412 Style);
1761 FormatStyle Style = getLLVMStyle();
1762 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1763 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
1769 Style);
1775 Style);
1784 Style);
1796 Style);
1798 Style.BraceWrapping.BeforeElse = true;
1808 Style);
1822 Style);
1852 FormatStyle Style = getLLVMStyle();
1853 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1854 Style.BraceWrapping.AfterFunction = true;
1864 Style);
1865 // verifyFormat("#define AAA N { //", Style);
1888 FormatStyle Style = getLLVMStyleWithColumns(60);
1889 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
1890 Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_WithoutElse;
1891 Style.BreakBeforeBraces = FormatStyle::BS_Allman;
1903 Style);
2028 FormatStyle Style = getLLVMStyle();
2029 EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
2030 EXPECT_EQ(Style.ReferenceAlignment, FormatStyle::RAS_Pointer);
2031 verifyFormat("int *f1(int *a, int &b, int &&c);", Style);
2032 verifyFormat("int &f2(int &&c, int *a, int &b);", Style);
2033 verifyFormat("int &&f3(int &b, int &&c, int *a);", Style);
2034 verifyFormat("int *f1(int &a) const &;", Style);
2035 verifyFormat("int *f1(int &a) const & = 0;", Style);
2036 verifyFormat("int *a = f1();", Style);
2037 verifyFormat("int &b = f2();", Style);
2038 verifyFormat("int &&c = f3();", Style);
2039 verifyFormat("int f3() { return sizeof(Foo &); }", Style);
2040 verifyFormat("int f4() { return sizeof(Foo &&); }", Style);
2041 verifyFormat("void f5() { int f6(Foo &, Bar &); }", Style);
2042 verifyFormat("void f5() { int f6(Foo &&, Bar &&); }", Style);
2043 verifyFormat("for (auto a = 0, b = 0; const auto &c : {1, 2, 3})", Style);
2044 verifyFormat("for (auto a = 0, b = 0; const int &c : {1, 2, 3})", Style);
2045 verifyFormat("for (auto a = 0, b = 0; const Foo &c : {1, 2, 3})", Style);
2046 verifyFormat("for (auto a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
2047 verifyFormat("for (int a = 0, b = 0; const auto &c : {1, 2, 3})", Style);
2048 verifyFormat("for (int a = 0, b = 0; const int &c : {1, 2, 3})", Style);
2049 verifyFormat("for (int a = 0, b = 0; const Foo &c : {1, 2, 3})", Style);
2050 verifyFormat("for (int a = 0, b++; const auto &c : {1, 2, 3})", Style);
2051 verifyFormat("for (int a = 0, b++; const int &c : {1, 2, 3})", Style);
2052 verifyFormat("for (int a = 0, b++; const Foo &c : {1, 2, 3})", Style);
2053 verifyFormat("for (auto x = 0; auto &c : {1, 2, 3})", Style);
2054 verifyFormat("for (auto x = 0; int &c : {1, 2, 3})", Style);
2055 verifyFormat("for (int x = 0; auto &c : {1, 2, 3})", Style);
2056 verifyFormat("for (int x = 0; int &c : {1, 2, 3})", Style);
2057 verifyFormat("for (f(); auto &c : {1, 2, 3})", Style);
2058 verifyFormat("for (f(); int &c : {1, 2, 3})", Style);
2062 Style);
2064 Style.AlignConsecutiveDeclarations.Enabled = true;
2065 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;
2074 Style);
2075 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = false;
2084 Style);
2086 Style.PointerAlignment = FormatStyle::PAS_Left;
2087 verifyFormat("int* f1(int* a, int& b, int&& c);", Style);
2088 verifyFormat("int& f2(int&& c, int* a, int& b);", Style);
2089 verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
2090 verifyFormat("int* f1(int& a) const& = 0;", Style);
2091 verifyFormat("int* a = f1();", Style);
2092 verifyFormat("int& b = f2();", Style);
2093 verifyFormat("int&& c = f3();", Style);
2094 verifyFormat("int f3() { return sizeof(Foo&); }", Style);
2095 verifyFormat("int f4() { return sizeof(Foo&&); }", Style);
2096 verifyFormat("void f5() { int f6(Foo&, Bar&); }", Style);
2097 verifyFormat("void f5() { int f6(Foo&&, Bar&&); }", Style);
2098 verifyFormat("for (auto a = 0, b = 0; const auto& c : {1, 2, 3})", Style);
2099 verifyFormat("for (auto a = 0, b = 0; const int& c : {1, 2, 3})", Style);
2100 verifyFormat("for (auto a = 0, b = 0; const Foo& c : {1, 2, 3})", Style);
2101 verifyFormat("for (auto a = 0, b = 0; const Foo* c : {1, 2, 3})", Style);
2102 verifyFormat("for (int a = 0, b = 0; const auto& c : {1, 2, 3})", Style);
2103 verifyFormat("for (int a = 0, b = 0; const int& c : {1, 2, 3})", Style);
2104 verifyFormat("for (int a = 0, b = 0; const Foo& c : {1, 2, 3})", Style);
2105 verifyFormat("for (int a = 0, b = 0; const Foo* c : {1, 2, 3})", Style);
2106 verifyFormat("for (int a = 0, b++; const auto& c : {1, 2, 3})", Style);
2107 verifyFormat("for (int a = 0, b++; const int& c : {1, 2, 3})", Style);
2108 verifyFormat("for (int a = 0, b++; const Foo& c : {1, 2, 3})", Style);
2109 verifyFormat("for (int a = 0, b++; const Foo* c : {1, 2, 3})", Style);
2110 verifyFormat("for (auto x = 0; auto& c : {1, 2, 3})", Style);
2111 verifyFormat("for (auto x = 0; int& c : {1, 2, 3})", Style);
2112 verifyFormat("for (int x = 0; auto& c : {1, 2, 3})", Style);
2113 verifyFormat("for (int x = 0; int& c : {1, 2, 3})", Style);
2114 verifyFormat("for (f(); auto& c : {1, 2, 3})", Style);
2115 verifyFormat("for (f(); int& c : {1, 2, 3})", Style);
2119 Style);
2120 verifyFormat("[](decltype(foo)& Bar) {}", Style);
2122 Style.AlignConsecutiveDeclarations.Enabled = true;
2123 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;
2132 Style);
2133 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = false;
2142 Style);
2144 Style.PointerAlignment = FormatStyle::PAS_Right;
2145 Style.ReferenceAlignment = FormatStyle::RAS_Left;
2146 verifyFormat("int *f1(int *a, int& b, int&& c);", Style);
2147 verifyFormat("int& f2(int&& c, int *a, int& b);", Style);
2148 verifyFormat("int&& f3(int& b, int&& c, int *a);", Style);
2149 verifyFormat("int *a = f1();", Style);
2150 verifyFormat("int& b = f2();", Style);
2151 verifyFormat("int&& c = f3();", Style);
2152 verifyFormat("int f3() { return sizeof(Foo&); }", Style);
2153 verifyFormat("int f4() { return sizeof(Foo&&); }", Style);
2154 verifyFormat("void f5() { int f6(Foo&, Bar&); }", Style);
2155 verifyFormat("void f5() { int f6(Foo&&, Bar&&); }", Style);
2156 verifyFormat("for (auto a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
2157 verifyFormat("for (int a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
2158 verifyFormat("for (int a = 0, b++; const Foo *c : {1, 2, 3})", Style);
2160 Style.AlignConsecutiveDeclarations.Enabled = true;
2161 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;
2170 Style);
2171 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = false;
2180 Style);
2182 Style.PointerAlignment = FormatStyle::PAS_Left;
2183 Style.ReferenceAlignment = FormatStyle::RAS_Middle;
2184 verifyFormat("int* f1(int* a, int & b, int && c);", Style);
2185 verifyFormat("int & f2(int && c, int* a, int & b);", Style);
2186 verifyFormat("int && f3(int & b, int && c, int* a);", Style);
2187 verifyFormat("int* a = f1();", Style);
2188 verifyFormat("int & b = f2();", Style);
2189 verifyFormat("int && c = f3();", Style);
2190 verifyFormat("int f3() { return sizeof(Foo &); }", Style);
2191 verifyFormat("int f4() { return sizeof(Foo &&); }", Style);
2192 verifyFormat("void f5() { int f6(Foo &, Bar &); }", Style);
2193 verifyFormat("void f5() { int f6(Foo &&, Bar &&); }", Style);
2194 verifyFormat("for (auto a = 0, b = 0; const auto & c : {1, 2, 3})", Style);
2195 verifyFormat("for (auto a = 0, b = 0; const int & c : {1, 2, 3})", Style);
2196 verifyFormat("for (auto a = 0, b = 0; const Foo & c : {1, 2, 3})", Style);
2197 verifyFormat("for (auto a = 0, b = 0; const Foo* c : {1, 2, 3})", Style);
2198 verifyFormat("for (int a = 0, b++; const auto & c : {1, 2, 3})", Style);
2199 verifyFormat("for (int a = 0, b++; const int & c : {1, 2, 3})", Style);
2200 verifyFormat("for (int a = 0, b++; const Foo & c : {1, 2, 3})", Style);
2201 verifyFormat("for (int a = 0, b++; const Foo* c : {1, 2, 3})", Style);
2202 verifyFormat("for (auto x = 0; auto & c : {1, 2, 3})", Style);
2203 verifyFormat("for (auto x = 0; int & c : {1, 2, 3})", Style);
2204 verifyFormat("for (int x = 0; auto & c : {1, 2, 3})", Style);
2205 verifyFormat("for (int x = 0; int & c : {1, 2, 3})", Style);
2206 verifyFormat("for (f(); auto & c : {1, 2, 3})", Style);
2207 verifyFormat("for (f(); int & c : {1, 2, 3})", Style);
2211 Style);
2213 Style.AlignConsecutiveDeclarations.Enabled = true;
2214 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;
2223 Style);
2224 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = false;
2233 Style);
2235 Style.PointerAlignment = FormatStyle::PAS_Middle;
2236 Style.ReferenceAlignment = FormatStyle::RAS_Right;
2237 verifyFormat("int * f1(int * a, int &b, int &&c);", Style);
2238 verifyFormat("int &f2(int &&c, int * a, int &b);", Style);
2239 verifyFormat("int &&f3(int &b, int &&c, int * a);", Style);
2240 verifyFormat("int * a = f1();", Style);
2241 verifyFormat("int &b = f2();", Style);
2242 verifyFormat("int &&c = f3();", Style);
2243 verifyFormat("int f3() { return sizeof(Foo &); }", Style);
2244 verifyFormat("int f4() { return sizeof(Foo &&); }", Style);
2245 verifyFormat("void f5() { int f6(Foo &, Bar &); }", Style);
2246 verifyFormat("void f5() { int f6(Foo &&, Bar &&); }", Style);
2247 verifyFormat("for (auto a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
2248 verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
2249 verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
2251 Style.AlignConsecutiveDeclarations.Enabled = true;
2252 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;
2261 Style);
2262 Style.AlignConsecutiveDeclarations.AlignFunctionPointers = false;
2271 Style);
2275 // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
2374 FormatStyle Style = getLLVMStyle();
2375 EXPECT_EQ(Style.AllowShortBlocksOnASingleLine, FormatStyle::SBS_Never);
2376 EXPECT_EQ(Style.AllowShortLoopsOnASingleLine, false);
2388 Style);
2401 Style);
2446 Style.SpaceBeforeParens =
2459 Style);
2713 FormatStyle Style = getLLVMStyle();
2714 Style.IndentCaseLabels = true;
2715 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
2716 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
2717 Style.BraceWrapping.AfterCaseLabel = true;
2718 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
2738 Style);
2739 Style.BraceWrapping.AfterCaseLabel = false;
2759 Style);
2760 Style.IndentCaseLabels = false;
2761 Style.IndentCaseBlocks = true;
2785 Style);
2786 Style.IndentCaseLabels = true;
2787 Style.IndentCaseBlocks = true;
2811 Style);
2824 FormatStyle Style = getLLVMStyle();
2825 EXPECT_TRUE(Style.AllowShortEnumsOnASingleLine);
2826 EXPECT_FALSE(Style.BraceWrapping.AfterEnum);
2827 verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
2828 verifyFormat("typedef enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
2829 Style.AllowShortEnumsOnASingleLine = false;
2835 Style);
2841 Style);
2845 Style);
2849 Style);
2850 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
2851 Style.BraceWrapping.AfterEnum = true;
2858 Style);
2865 Style);
2869 FormatStyle Style = getLLVMStyle();
2870 EXPECT_TRUE(Style.AllowShortCompoundRequirementOnASingleLine);
2875 Style);
2881 Style);
2882 Style.AllowShortCompoundRequirementOnASingleLine = false;
2889 Style);
2899 Style);
2903 FormatStyle Style = getLLVMStyle();
2904 Style.AllowShortCaseLabelsOnASingleLine = true;
2921 Style);
2944 Style);
2976 Style);
2987 Style);
2998 Style);
3004 Style);
3019 Style);
3020 Style.ColumnLimit = 21;
3024 Style);
3035 Style);
3036 Style.ColumnLimit = 80;
3037 Style.AllowShortCaseLabelsOnASingleLine = false;
3038 Style.IndentCaseLabels = true;
3051 Style);
3052 Style.AllowShortCaseLabelsOnASingleLine = true;
3053 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
3054 Style.BraceWrapping.AfterCaseLabel = true;
3055 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
3076 Style);
3132 FormatStyle Style = getLLVMStyle();
3133 Style.IndentGotoLabels = false;
3144 Style);
3150 Style);
3156 Style);
3161 Style);
3170 Style);
3172 Style.ColumnLimit = 15;
3176 Style);
3180 Style = getLLVMStyle();
3181 Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Allman;
3189 Style);
3197 Style);
3201 FormatStyle Style = getLLVMStyleWithColumns(20);
3202 Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
3203 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
3208 "if(foo){bar();}", Style);
3214 "if(foo){bar();}else{baz();}", Style);
3218 "if(foo&&bar){baz();}", Style);
3224 "if(foo){bar();}else if(baz){quux();}", Style);
3232 "if(foo){bar();}else if(baz){quux();}else{foobar();}", Style);
3240 "while(1){foo();}", Style);
3245 "switch(foo){case bar:return;}", Style);
3251 "try{foo();}catch(...){bar();}", Style);
3256 "do{foo();}while(bar&&baz);", Style);
3265 "void f(){if(a1&&a2&&a3){quux();}}", Style);
3271 "if(foo&&bar&&baz){quux();}", Style);
3281 Style);
3289 "if(foo){bar();}else if(baz||quux){foobar();}", Style);
3300 Style);
3306 "for(int i=0;i<10;++i){foo();}", Style);
3312 "foreach(int i, list){foo();}", Style);
3313 Style.ColumnLimit =
3318 "foreach(int i, list){foo();}", Style);
3319 Style.ColumnLimit =
3326 "while(foo||bar||baz){quux();}", Style);
3333 "switch(foo=barbaz){case quux:return;}", Style);
3341 "try{foo();}catch(Exception&bar){baz();}", Style);
3342 Style.ColumnLimit =
3349 "try{foo();}catch(Exception&bar){baz();}", Style);
3350 Style.ColumnLimit =
3353 Style.BraceWrapping.BeforeElse = true;
3366 Style);
3368 Style.BraceWrapping.BeforeCatch = true;
3375 "try{foo();}catch(...){baz();}", Style);
3377 Style.BraceWrapping.AfterFunction = true;
3378 Style.BraceWrapping.AfterStruct = false;
3379 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
3380 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
3381 Style.ColumnLimit = 80;
3382 verifyFormat("void shortfunction() { bar(); }", Style);
3383 verifyFormat("struct T shortfunction() { return bar(); }", Style);
3384 verifyFormat("struct T {};", Style);
3386 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
3391 Style);
3396 Style);
3397 verifyFormat("struct T {};", Style);
3399 Style.BraceWrapping.AfterFunction = false;
3400 Style.BraceWrapping.AfterStruct = true;
3401 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
3402 verifyFormat("void shortfunction() { bar(); }", Style);
3403 verifyFormat("struct T shortfunction() { return bar(); }", Style);
3407 Style);
3409 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
3413 Style);
3417 Style);
3421 Style);
3425 FormatStyle Style = getLLVMStyle();
3426 Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
3431 Style);
3432 Style.BraceWrapping.BeforeWhile = true;
3437 Style);
3953 FormatStyle Style = getLLVMStyleWithColumns(40);
3962 Style);
3963 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
3964 Style.BraceWrapping.AfterEnum = true;
3974 Style);
4034 FormatStyle Style = getLLVMStyle();
4035 Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
4041 Style);
4046 Style);
4047 Style.BitFieldColonSpacing = FormatStyle::BFCS_Before;
4053 Style);
4054 Style.BitFieldColonSpacing = FormatStyle::BFCS_After;
4060 Style);
4184 FormatStyle Style = getLLVMStyle();
4185 Style.NamespaceIndentation = FormatStyle::NI_All;
4198 Style);
4304 Style.NamespaceIndentation = FormatStyle::NI_Inner;
4317 Style);
4319 Style.NamespaceIndentation = FormatStyle::NI_None;
4325 Style);
4333 Style);
4347 FormatStyle Style = getLLVMStyle();
4348 Style.NamespaceMacros.push_back("TESTSUITE");
4353 Style);
4358 Style);
4361 Style.NamespaceIndentation = FormatStyle::NI_All;
4365 Style);
4371 Style);
4377 Style);
4379 Style.NamespaceIndentation = FormatStyle::NI_Inner;
4385 Style);
4391 Style);
4397 Style);
4400 Style.NamespaceIndentation = FormatStyle::NI_None;
4401 Style.CompactNamespaces = true;
4404 Style);
4412 Style);
4420 Style);
4427 Style);
4432 Style);
4433 Style.NamespaceMacros.push_back("FOOBAR");
4438 Style);
4442 FormatStyle Style = getLLVMStyle();
4443 Style.CompactNamespaces = true;
4444 Style.NamespaceMacros.push_back("TESTSUITE");
4448 Style);
4456 Style);
4465 Style);
4477 Style);
4479 Style.ColumnLimit = 41;
4486 Style);
4488 Style.ColumnLimit = 40;
4496 Style);
4507 Style);
4512 Style);
4514 Style.ColumnLimit = 80;
4523 Style);
4532 Style);
4534 Style.NamespaceIndentation = FormatStyle::NI_All;
4543 Style);
4553 Style);
4571 Style);
4593 Style);
4595 Style.NamespaceIndentation = FormatStyle::NI_Inner;
4604 Style);
4615 Style);
4617 Style.CompactNamespaces = true;
4618 Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
4619 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
4620 Style.BraceWrapping.BeforeLambdaBody = true;
4623 Style);
4630 Style);
4646 FormatStyle Style = getLLVMStyle();
4647 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
4648 Style.BraceWrapping.AfterFunction = true;
4649 verifyFormat("extern \"C\" int foo() {}", Style);
4650 verifyFormat("extern \"C\" int foo();", Style);
4656 Style);
4658 Style.BraceWrapping.AfterExternBlock = true;
4659 Style.BraceWrapping.SplitEmptyRecord = false;
4662 Style);
4667 Style);
4671 FormatStyle Style = getLLVMStyle();
4672 Style.IndentWidth = 2;
4674 Style.IndentExternBlock = FormatStyle::IEBS_Indent;
4677 Style);
4681 Style);
4683 Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
4686 Style);
4690 Style);
4692 Style.BreakBeforeBraces = FormatStyle::BS_Allman;
4697 Style);
4699 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
4700 Style.BraceWrapping.AfterExternBlock = true;
4701 Style.IndentExternBlock = FormatStyle::IEBS_Indent;
4705 Style);
4709 Style);
4711 Style.BraceWrapping.AfterExternBlock = false;
4712 Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
4715 Style);
4719 Style);
4721 Style.BraceWrapping.AfterExternBlock = true;
4725 Style);
4730 Style);
4732 Style.IndentExternBlock = FormatStyle::IEBS_Indent;
4736 Style);
4741 Style);
4783 auto Style = getLLVMStyleWithColumns(0);
4791 Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
4792 verifyFormat(Code1, Style);
4793 verifyNoChange(Code2, Style);
4794 verifyNoChange(Code3, Style);
4796 Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
4797 verifyFormat(Code2, Code1, Style);
4798 verifyNoChange(Code2, Style);
4799 verifyFormat(Code2, Code3, Style);
4861 FormatStyle Style = getLLVMStyle();
4862 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
4863 Style.BraceWrapping.AfterFunction = true;
4864 Style.BraceWrapping.BeforeCatch = true;
4871 Style);
4880 Style);
4887 Style);
4896 Style);
4935 FormatStyle Style = getLLVMStyle();
4938 Style.BreakBeforeBraces = BraceStyle;
4944 Style);
4946 Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
4953 Style);
4960 Style);
4967 Style);
4968 Style.BreakBeforeBraces = FormatStyle::BS_Allman;
4977 Style);
4978 Style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
4987 Style);
4988 Style.BreakBeforeBraces = FormatStyle::BS_GNU;
4997 Style);
4998 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
4999 Style.BraceWrapping.BeforeCatch = true;
5006 Style);
5079 auto Style = getLLVMStyleWithColumns(60);
5080 Style.BinPackArguments = true;
5081 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
5082 Style.BracedInitializerIndentWidth = 6;
5089 Style);
5094 Style);
5099 Style);
5104 Style);
5109 Style);
5114 Style);
5120 Style);
5124 Style);
5128 Style);
5133 Style);
5140 Style);
5146 Style);
5152 Style);
5161 Style);
5168 Style);
5175 Style);
5182 Style);
5189 Style);
5196 Style);
5203 Style);
5210 Style);
5215 Style);
5225 Style);
5237 Style);
5254 Style);
5257 Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
5260 Style);
5747 FormatStyle Style = getLLVMStyle();
5748 Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
5749 verifyFormat("#define true ((foo)1)", Style);
5750 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
5751 verifyFormat("#define false((foo)0)", Style);
6012 FormatStyle Style = getLLVMStyle();
6013 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
6014 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
6015 Style.BraceWrapping.AfterFunction = true;
6022 Style);
6047 Style = getLLVMStyle();
6048 Style.StatementMacros.push_back("FOO");
6052 Style);
6055 Style);
6058 Style);
6061 Style);
6064 Style);
6069 Style);
6072 Style);
6076 Style);
6080 Style);
6083 Style);
6102 FormatStyle Style = getLLVMStyleWithColumns(40);
6103 Style.IndentPPDirectives = FormatStyle::PPDIS_None;
6115 Style);
6116 Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
6120 Style);
6132 Style);
6143 Style);
6151 Style);
6157 Style);
6164 Style);
6173 Style);
6179 Style);
6185 Style);
6192 Style);
6198 Style);
6203 Style);
6212 Style);
6221 Style);
6236 Style);
6255 Style);
6269 Style);
6296 verifyFormat(Expected, ToFormat, Style);
6297 verifyNoChange(Expected, Style);
6323 verifyFormat(Expected, ToFormat, Style);
6324 verifyNoChange(Expected, Style);
6346 verifyFormat(Expected, ToFormat, Style);
6347 verifyNoChange(Expected, Style);
6351 FormatStyle Tabbed = Style;
6378 Style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
6391 Style);
6402 Style);
6433 verifyFormat(Expected, ToFormat, Style);
6434 verifyNoChange(Expected, Style);
6463 verifyFormat(Expected, ToFormat, Style);
6464 verifyNoChange(Expected, Style);
6472 Style);
6476 FormatStyle Style = getLLVMStyle();
6477 Style.AlignConsecutiveAssignments.Enabled = true;
6478 Style.AlignConsecutiveDeclarations.Enabled = true;
6495 Style);
6515 Style);
6522 Style);
6542 Style);
6571 Style);
6583 Style);
6600 Style);
6616 Style);
6967 FormatStyle Style = getGoogleStyle();
6968 Style.ColumnLimit = 45;
6975 Style);
7006 FormatStyle Style = getLLVMStyle();
7007 Style.SpaceInEmptyBlock = true;
7008 verifyFormat("void f() { }", "void f() {}", Style);
7009 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
7010 verifyFormat("{ }", Style);
7011 verifyFormat("while (true) { }", "while (true) {}", Style);
7012 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
7013 Style.BraceWrapping.BeforeElse = false;
7014 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
7021 Style);
7022 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
7027 Style);
7028 Style.BraceWrapping.BeforeElse = true;
7032 Style);
7034 Style = getLLVMStyle(FormatStyle::LK_CSharp);
7035 Style.SpaceInEmptyBlock = true;
7036 verifyFormat("Event += () => { };", Style);
7040 FormatStyle Style = getLLVMStyle();
7041 Style.MacroBlockBegin = "^[A-Z_]+_BEGIN$";
7042 Style.MacroBlockEnd = "^[A-Z_]+_END$";
7046 Style);
7052 Style);
7057 Style);
7059 Style.RemoveBracesLLVM = true;
7064 Style);
7256 FormatStyle Style = getLLVMStyle();
7257 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
7268 Style);
7273 Style);
7278 Style);
7283 Style);
7289 Style);
7292 Style);
7296 Style);
7301 Style);
7305 Style);
7317 Style);
7319 Style.ColumnLimit = 60;
7323 Style);
7325 Style.ColumnLimit = 80;
7326 Style.IndentWidth = 4;
7327 Style.TabWidth = 4;
7328 Style.UseTab = FormatStyle::UT_Always;
7329 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
7330 Style.AlignOperands = FormatStyle::OAS_DontAlign;
7337 Style);
7339 Style = getLLVMStyleWithColumns(20);
7340 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
7341 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
7342 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7343 Style.ContinuationIndentWidth = 2;
7352 Style);
7360 Style);
7364 FormatStyle Style = getLLVMStyle();
7365 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
7366 Style.AlignOperands = FormatStyle::OAS_AlignAfterOperator;
7377 Style);
7382 Style);
7387 Style);
7392 Style);
7398 Style);
7401 Style);
7405 Style);
7410 Style);
7414 Style);
7421 Style);
7424 Style);
7428 Style);
7430 Style.ColumnLimit = 60;
7434 Style);
7437 Style.ColumnLimit = 80;
7444 Style);
7446 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7453 Style);
7455 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
7462 Style);
7475 FormatStyle Style = getLLVMStyle();
7476 Style.AlignOperands = FormatStyle::OAS_DontAlign;
7480 Style);
7481 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7491 Style);
7496 Style);
7500 Style);
7502 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
7507 Style);
7511 FormatStyle Style = getLLVMStyle();
7512 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7516 Style);
7520 FormatStyle Style = getLLVMStyleWithColumns(40);
7521 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7522 Style.BinPackArguments = false;
7529 Style);
7539 Style);
7553 Style);
7555 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
7569 Style);
7573 auto Style = getLLVMStyleWithColumns(45);
7574 EXPECT_EQ(Style.BreakBeforeBinaryOperators, FormatStyle::BOS_None);
7584 Style);
7586 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
7595 Style);
7597 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
7606 Style);
7738 FormatStyle Style = getLLVMStyleWithColumns(60);
7739 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
7740 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
7744 Style.AllowAllParametersOfDeclarationOnNextLine = i & 1;
7745 Style.AllowAllArgumentsOnNextLine = i & 2;
7747 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7748 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
7751 Style);
7752 verifyFormat("Constructor() : a(a), b(b) {}", Style);
7754 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7758 Style);
7759 verifyFormat("Constructor() : a(a), b(b) {}", Style);
7761 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7764 Style);
7767 Style);
7772 Style);
7774 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
7775 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7778 Style);
7780 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7784 Style);
7786 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7789 Style);
7792 Style);
7797 Style);
7799 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
7800 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7803 Style);
7805 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7809 Style);
7811 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7814 Style);
7817 Style);
7822 Style);
7828 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
7829 Style.AllowAllParametersOfDeclarationOnNextLine = true;
7830 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7835 Style);
7837 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7843 Style);
7845 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7851 Style);
7853 Style.AllowAllParametersOfDeclarationOnNextLine = false;
7854 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7860 Style);
7862 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
7864 Style.AllowAllParametersOfDeclarationOnNextLine = true;
7869 Style);
7871 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7877 Style);
7879 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7885 Style);
7887 Style.AllowAllParametersOfDeclarationOnNextLine = false;
7888 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7894 Style);
7896 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
7897 Style.AllowAllParametersOfDeclarationOnNextLine = true;
7902 Style);
7904 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
7910 Style);
7912 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
7918 Style);
7920 Style.AllowAllParametersOfDeclarationOnNextLine = false;
7921 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7927 Style);
7929 Style = getLLVMStyleWithColumns(0);
7930 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
7931 verifyFormat("Foo(Bar bar, Baz baz) : bar(bar), baz(baz) {}", Style);
7934 Style);
7938 FormatStyle Style = getLLVMStyleWithColumns(60);
7939 Style.BinPackArguments = false;
7942 Style.AllowAllParametersOfDeclarationOnNextLine = i & 1;
7943 Style.PackConstructorInitializers =
7946 Style.AllowAllArgumentsOnNextLine = true;
7951 Style);
7952 Style.AllowAllArgumentsOnNextLine = false;
7958 Style);
7960 Style.AllowAllArgumentsOnNextLine = true;
7965 Style);
7966 Style.AllowAllArgumentsOnNextLine = false;
7972 Style);
7976 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
7977 Style.AllowAllArgumentsOnNextLine = false;
7978 Style.AllowAllParametersOfDeclarationOnNextLine = true;
7981 Style);
7982 Style.AllowAllParametersOfDeclarationOnNextLine = false;
7986 Style);
7992 FormatStyle Style = getLLVMStyleWithColumns(35);
7995 Style.AllowAllArgumentsOnNextLine = false;
7996 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
8001 Input, Style);
8002 Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
8007 Input, Style);
8010 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
8015 Input, Style);
8016 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
8023 Input, Style);
8027 Style.AllowAllArgumentsOnNextLine = true;
8028 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
8033 Input, Style);
8036 Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
8041 Input, Style);
8042 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
8047 Input, Style);
8057 FormatStyle Style = getLLVMStyle();
8058 EXPECT_FALSE(Style.BreakFunctionDefinitionParameters);
8059 Style.BreakFunctionDefinitionParameters = true;
8067 Input, Style);
8070 Style.AllowAllParametersOfDeclarationOnNextLine = false;
8071 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
8082 Input, Style);
8086 FormatStyle Style = getLLVMStyle();
8087 Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Never;
8089 Style.ColumnLimit = 40;
8092 Style);
8095 Style);
8100 Style);
8101 Style.ColumnLimit = 80;
8102 verifyFormat("asm volatile(\"string\", : : val);", Style);
8103 verifyFormat("asm volatile(\"string\", : val1 : val2);", Style);
8105 Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
8109 Style);
8113 Style);
8115 Style.ColumnLimit = 40;
8121 Style);
8127 Style);
8131 Style);
8135 Style);
8139 FormatStyle Style = getLLVMStyle();
8140 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
8144 getStyleWithColumns(Style, 45));
8147 getStyleWithColumns(Style, 44));
8150 getStyleWithColumns(Style, 43));
8154 getStyleWithColumns(Style, 50));
8159 Style);
8160 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
8164 Style);
8168 Style);
8170 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
8174 Style);
8178 Style);
8180 Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
8184 Style);
8190 Style);
8195 Style);
8199 Style);
8206 Style);
8211 Style);
8216 Style);
8220 getStyleWithColumns(Style, 60));
8224 Style);
8232 Style);
8234 FormatStyle OnePerLine = Style;
8281 Style);
8284 Style);
8292 Style);
8294 Style.ColumnLimit = 0;
8297 Style);
8300 Style);
8303 Style);
8309 Style);
8311 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
8315 Style);
8319 Style);
8321 Style.ColumnLimit = 80;
8322 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
8323 Style.ConstructorInitializerIndentWidth = 2;
8324 verifyFormat("SomeClass::Constructor() : a(a), b(b), c(c) {}", Style);
8328 Style);
8332 Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
8337 Style);
8338 Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
8343 Style);
8344 Style.BreakInheritanceList = FormatStyle::BILS_AfterColon;
8349 Style);
8350 Style.BreakInheritanceList = FormatStyle::BILS_AfterComma;
8355 Style);
8543 FormatStyle Style = getLLVMStyle();
8544 Style.PointerAlignment = FormatStyle::PAS_Left;
8547 Style);
8550 Style);
8584 FormatStyle Style = getLLVMStyleWithColumns(60);
8587 Style);
8624 FormatStyle Style = getGoogleStyleWithColumns(47);
8633 Style);
8652 Style);
8655 Style);
8658 Style);
8661 Style);
8664 Style);
8667 Style);
8669 Style.BreakBeforeBraces = FormatStyle::BS_Allman;
8674 Style);
8676 Style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
8681 Style);
8707 Style = getGoogleStyle();
8712 Style);
8716 Style);
8720 Style);
8724 Style);
8729 Style);
8733 Style);
8737 Style);
8741 Style);
9039 FormatStyle Style = getLLVMStyleWithColumns(15);
9040 Style.ExperimentalAutoDetectBinPacking = true;
9051 Style);
9059 Style);
9063 FormatStyle Style = getLLVMStyleWithColumns(80);
9064 Style.IndentExportBlock = true;
9073 Style);
9075 Style.IndentExportBlock = false;
9084 Style);
9088 FormatStyle Style = getLLVMStyleWithColumns(80);
9089 Style.IndentExportBlock = false;
9091 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
9094 Style);
9099 Style);
9108 Style);
9112 "export {}", Style);
9117 "export { int x; }", Style);
9119 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
9123 Style);
9129 Style);
9136 Style);
9141 Style);
9147 Style);
9149 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
9153 Style);
9158 Style);
9167 Style);
9169 verifyFormat("export {}", Style);
9174 "export { int x; }", Style);
9382 FormatStyle Style = getLLVMStyle();
9385 Style);
9387 Style.PenaltyBreakAssignment = 20;
9390 Style);
9445 FormatStyle Style = getLLVMStyle();
9446 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
9449 Style);
9452 Style);
9455 Style);
9459 Style);
9463 Style);
9467 Style);
9472 Style);
9474 Style.ColumnLimit = 30;
9479 Style);
9480 Style.ColumnLimit = 80;
9482 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
9483 Style.BinPackArguments = false;
9484 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
9489 Style);
9494 Style);
9499 Style);
9503 Style);
9507 Style);
9513 Style);
9519 Style);
9523 Style);
9527 Style);
9531 Style);
9533 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
9534 Style.BinPackArguments = false;
9535 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
9541 Style);
9547 Style);
9553 Style);
9557 Style);
9561 Style);
9569 Style);
9577 Style);
9586 Style);
9590 Style);
9597 Style);
9601 Style);
9605 Style);
9610 Style);
9611 Style.ColumnLimit = 60;
9616 Style);
9620 FormatStyle Style = getLLVMStyleWithColumns(40);
9623 Style);
9624 Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
9625 Style.AlignOperands = FormatStyle::OAS_DontAlign;
9628 Style);
9629 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
9630 Style.AlignOperands = FormatStyle::OAS_Align;
9633 Style);
9634 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
9635 Style.AlignOperands = FormatStyle::OAS_DontAlign;
9638 Style);
9779 FormatStyle Style = getLLVMStyleWithColumns(70);
9780 Style.AlignOperands = FormatStyle::OAS_Align;
9784 Style);
9788 Style);
9792 Style);
9796 Style);
9801 Style);
9805 Style);
9809 Style);
9815 Style);
9821 Style);
9827 Style);
9833 Style);
9839 Style);
9845 Style);
9852 Style);
9859 Style);
9866 Style);
9872 Style);
9879 Style);
9886 Style);
9893 Style);
9895 Style.AlignOperands = FormatStyle::OAS_DontAlign;
9896 Style.BreakBeforeTernaryOperators = false;
9904 Style);
9931 FormatStyle Style = getLLVMStyleWithColumns(70);
9932 Style.BreakBeforeTernaryOperators = false;
9937 Style);
9942 Style);
9946 Style);
9950 Style);
9954 Style);
9960 Style);
9965 Style);
9971 Style);
9979 Style);
9985 Style);
9989 Style);
9994 Style);
9999 Style);
10004 Style);
10011 Style);
10017 Style);
10023 Style);
10027 Style);
10031 Style);
10037 Style);
10041 Style);
10045 Style);
10049 Style);
10054 Style);
10058 Style);
10062 Style);
10068 Style);
10074 Style);
10080 Style);
10086 Style);
10092 Style);
10098 Style);
10105 Style);
10112 Style);
10119 Style);
10125 Style);
10132 Style);
10139 Style);
10146 Style);
10169 FormatStyle Style = getGoogleStyle();
10170 Style.PointerAlignment = FormatStyle::PAS_Left;
10171 Style.DerivePointerAlignment = false;
10175 Style);
10178 Style);
10179 verifyFormat("vector<int*> a, b;", Style);
10180 verifyFormat("for (int *p, *q; p != q; p = p->next) {\n}", Style);
10181 verifyFormat("/*comment*/ for (int *p, *q; p != q; p = p->next) {\n}", Style);
10182 verifyFormat("if (int *p, *q; p != q) {\n p = p->next;\n}", Style);
10184 Style);
10186 Style);
10189 Style);
10191 verifyFormat("if ([](int* p, int* q) {}()) {\n}", Style);
10192 verifyFormat("for ([](int* p, int* q) {}();;) {\n}", Style);
10193 verifyFormat("for (; [](int* p, int* q) {}();) {\n}", Style);
10194 verifyFormat("for (;; [](int* p, int* q) {}()) {\n}", Style);
10196 Style);
10266 FormatStyle Style = getLLVMStyle();
10267 Style.ColumnLimit = 60;
10270 Style.BreakAfterReturnType = FormatStyle::RTBS_None;
10281 Style);
10284 Style.BreakAfterReturnType = FormatStyle::RTBS_Automatic;
10295 Style);
10298 Style.BreakAfterReturnType = FormatStyle::RTBS_ExceptShortType;
10309 Style);
10313 Style.BreakAfterReturnType = FormatStyle::RTBS_All;
10314 Style.TypenameMacros = {"LIST"};
10317 Style);
10336 Style);
10340 Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
10350 Style);
10354 Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevel;
10367 Style);
10371 Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
10384 Style);
10390 Style);
10397 Style);
10408 Style);
10441 Style);
10470 Style);
10472 Style);
10475 Style);
10478 Style);
10479 Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
10486 Style);
10494 Style);
10500 Style);
10506 Style);
10512 Style);
10518 Style);
10524 Style);
10530 Style);
10532 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
10533 Style.BraceWrapping.AfterFunction = true;
10545 Style);
10561 Style);
10568 Style);
10581 Style);
10585 Style);
10588 Style);
10594 Style);
10615 Style = getGNUStyle();
10622 Style);
10628 Style);
10631 verifyFormat("void foo (int a, int b); // def", Style);
10632 verifyFormat("void foo (int a, int b); /* def */", Style);
10633 verifyFormat("void foo (int a, int b);", Style);
11109 auto Style = getLLVMStyle();
11110 Style.BreakTemplateDeclarations = FormatStyle::BTDS_Leave;
11114 Style);
11115 verifyFormat("template <typename T> class C {};", Style);
11119 Style);
11120 verifyFormat("template <typename T> void f();", Style);
11124 Style);
11125 verifyFormat("template <typename T> void f() {}", Style);
11130 Style);
11133 Style);
11137 Style);
11138 verifyFormat("template <typename T> C(T) noexcept;", Style);
11145 Style);
11150 Style);
11157 Style);
11162 Style);
11164 Style.RequiresClausePosition = FormatStyle::RCPS_WithPreceding;
11170 Style);
11175 Style);
11179 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
11180 Style.ColumnLimit = 60;
11185 Style);
11193 Style);
11201 Style);
11211 Style);
11220 Style);
11224 FormatStyle Style = getLLVMStyle();
11225 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
11226 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
11232 Style);
11233 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
11234 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
11240 Style);
11241 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
11242 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
11250 Style);
11251 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
11252 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
11260 Style);
11338 FormatStyle Style = getLLVMStyle();
11339 Style.SpaceBeforeAssignmentOperators = false;
11340 verifyFormat("bool b= a<1> == 1;", Style);
11341 verifyFormat("a<int> = 1;", Style);
11342 verifyFormat("a<int> >>= 1;", Style);
11439 FormatStyle Style = getLLVMStyle();
11440 EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
11441 verifyFormat("typedef bool *(Class::*Member)() const;", Style);
11442 verifyFormat("void f(int A::*p) { int A::*v = &A::B; }", Style);
11444 Style.PointerAlignment = FormatStyle::PAS_Left;
11445 verifyFormat("typedef bool* (Class::*Member)() const;", Style);
11446 verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
11448 Style.PointerAlignment = FormatStyle::PAS_Middle;
11449 verifyFormat("typedef bool * (Class::*Member)() const;", Style);
11450 verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
11821 FormatStyle Style = getLLVMStyle();
11822 Style.DerivePointerAlignment = true;
11828 EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
11832 Code, Style);
11834 Style.PointerAlignment = FormatStyle::PAS_Left;
11838 Code, Style);
11840 Style.PointerAlignment = FormatStyle::PAS_Middle;
11844 Code, Style);
12176 FormatStyle Style = getLLVMStyle();
12177 Style.PointerAlignment = FormatStyle::PAS_Left;
12180 Style);
12183 Style);
12186 Style);
12189 verifyFormat("int i = int{42} * 34;", Style);
12192 Style);
12195 Style);
12198 Style);
12201 Style.PointerAlignment = FormatStyle::PAS_Middle;
12204 Style);
12207 Style);
12210 Style);
12213 Style);
12216 Style);
12219 Style);
12221 Style.PointerAlignment = FormatStyle::PAS_Right;
12224 Style);
12227 Style);
12230 Style);
12233 Style);
12236 Style);
12239 Style);
12241 Style.PointerAlignment = FormatStyle::PAS_Left;
12242 verifyFormat("delete[] *ptr;", Style);
12243 verifyFormat("delete[] **ptr;", Style);
12244 verifyFormat("delete[] *(ptr);", Style);
12509 FormatStyle Style = getChromiumStyle(FormatStyle::LK_Cpp);
12513 Style);
12517 Style);
12521 Style);
12525 Style);
12529 Style);
12533 FormatStyle Style = getLLVMStyle();
12556 FormatStyle Style = getLLVMStyle();
12559 Style);
12562 Style);
12565 Style);
12569 FormatStyle Style = getLLVMStyle();
12574 verifyFormat("template <int *...PP> a;", Style);
12576 Style.PointerAlignment = FormatStyle::PAS_Left;
12577 verifyFormat("template <class... Ts> void Foo(Ts*... ts) {}", Style);
12579 verifyFormat("template <int*... PP> a;", Style);
12581 Style.PointerAlignment = FormatStyle::PAS_Middle;
12582 verifyFormat("template <int *... PP> a;", Style);
12950 FormatStyle Style = getLLVMStyle();
12951 EXPECT_EQ(Style.EmptyLineBeforeAccessModifier,
12963 Style);
12982 Style);
12990 Style);
13001 Style);
13002 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
13011 Style);
13031 Style);
13048 Style);
13071 Style);
13072 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
13083 Style);
13102 Style);
13111 Style);
13134 Style);
13135 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Leave;
13147 Style);
13156 Style);
13166 Style);
13174 Style);
13187 Style);
13198 Style);
13199 Style.AttributeMacros.push_back("FOO");
13200 Style.AttributeMacros.push_back("BAR");
13207 Style);
13254 FormatStyle Style = getLLVMStyle();
13255 EXPECT_EQ(Style.EmptyLineAfterAccessModifier, FormatStyle::ELAAMS_Never);
13266 Style);
13292 Style);
13294 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13308 Style);
13334 Style);
13337 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
13338 Style.MaxEmptyLinesToKeep = 0u;
13349 Style);
13375 Style);
13377 Style.MaxEmptyLinesToKeep = 1u;
13391 Style);
13403 Style);
13431 Style);
13433 Style.MaxEmptyLinesToKeep = 10u;
13447 Style);
13450 Style = getLLVMStyle();
13459 Style);
13478 Style);
13480 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13499 Style);
13510 Style);
13513 Style = getLLVMStyle();
13520 Style);
13534 Style);
13542 Style);
13558 Style);
13573 Style);
13592 Style);
13594 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13608 Style);
13616 Style);
13622 FormatStyle Style = getLLVMStyle();
13623 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
13624 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13630 Style);
13632 Style.MaxEmptyLinesToKeep = 10u;
13634 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
13635 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
13645 Style);
13648 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Leave;
13649 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
13650 Style.MaxEmptyLinesToKeep = 10u;
13656 Style);
13657 Style.MaxEmptyLinesToKeep = 3u;
13663 Style);
13664 Style.MaxEmptyLinesToKeep = 1u;
13670 Style); // Based on new lines in original document and not
13673 Style.MaxEmptyLinesToKeep = 10u;
13674 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
13675 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
13683 Style);
13685 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Leave;
13686 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13693 Style);
13695 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Leave;
13696 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
13702 Style); // test::messUp removes all new lines which changes
13705 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
13706 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
13716 Style);
13718 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
13719 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
13725 Style); // test::messUp removes all new lines which changes
13728 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
13729 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13739 Style);
13741 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
13742 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
13752 Style);
13754 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
13755 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
13765 Style);
13767 Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
13768 Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
13778 Style);
13862 FormatStyle Style = getLLVMStyle();
13863 Style.AlwaysBreakBeforeMultilineStrings = true;
13864 Style.ColumnLimit = 0;
13865 verifyFormat("#import \"abc.h\"", Style);
13966 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
13967 Style.ColumnLimit = 60;
13972 Style);
14851 FormatStyle Style = getLLVMStyleWithColumns(40);
14852 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
14853 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
14854 Style.BraceWrapping.AfterFunction = true;
14855 Style.BraceWrapping.SplitEmptyFunction = false;
14859 Style);
14864 Style);
14869 Style);
14871 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
14872 verifyFormat("int f() {}", Style);
14875 Style);
14880 Style);
14882 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
14886 Style);
14890 Style);
14895 Style);
14902 Style);
14904 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
14905 verifyFormat("int f() {}", Style);
14906 verifyFormat("int f() { return 0; }", Style);
14909 Style);
14914 Style);
14918 FormatStyle Style = getLLVMStyleWithColumns(40);
14919 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
14920 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
14921 Style.BraceWrapping.AfterFunction = true;
14922 Style.BraceWrapping.SplitEmptyFunction = true;
14923 Style.BraceWrapping.SplitEmptyRecord = false;
14925 verifyFormat("class C {};", Style);
14926 verifyFormat("struct C {};", Style);
14931 Style);
14944 Style);
14948 FormatStyle Style = getLLVMStyle();
14949 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
14955 Style);
14959 FormatStyle Style = getLLVMStyle();
14960 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
14961 Style.BraceWrapping.AfterClass = true;
14962 Style.BraceWrapping.SplitEmptyRecord = false;
14966 Style);
14969 Style);
14972 Style);
14977 Style);
14981 Style);
14983 Style.BraceWrapping.SplitEmptyRecord = true;
14984 Style.BraceWrapping.AfterStruct = true;
14988 Style);
14992 Style);
14996 Style);
15000 Style);
15005 Style);
15010 Style);
15015 Style);
15020 Style);
15025 Style);
15030 Style);
15036 Style);
15042 Style);
15046 Style);
15050 Style);
15053 Style);
15061 Style);
15065 FormatStyle Style = getLLVMStyle();
15066 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15067 Style.BraceWrapping.AfterStruct = true;
15068 Style.BraceWrapping.SplitEmptyRecord = false;
15072 Style);
15075 Style);
15078 Style);
15083 Style);
15087 Style);
15092 FormatStyle Style = getLLVMStyle();
15093 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15094 Style.BraceWrapping.AfterUnion = true;
15095 Style.BraceWrapping.SplitEmptyRecord = false;
15099 Style);
15102 Style);
15107 Style);
15111 Style);
15115 FormatStyle Style = getLLVMStyle();
15116 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15117 Style.BraceWrapping.AfterNamespace = true;
15118 Style.BraceWrapping.SplitEmptyNamespace = false;
15122 Style);
15125 Style);
15128 Style);
15131 Style);
15134 Style);
15139 Style);
15143 FormatStyle Style = getLLVMStyle();
15148 Style);
15152 Style);
15156 Style);
15160 Style);
15164 Style);
15168 Style);
15172 Style);
15174 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15175 Style.BraceWrapping.AfterClass = true;
15176 Style.BraceWrapping.AfterStruct = true;
15177 Style.BraceWrapping.AfterUnion = true;
15178 Style.BraceWrapping.AfterNamespace = true;
15183 Style);
15188 Style);
15193 Style);
15198 Style);
15203 Style);
15208 Style);
15213 Style);
15450 FormatStyle Style = getLLVMStyle();
15453 Style.IndentWrappedFunctionNames = false;
15458 Style);
15459 Style.IndentWrappedFunctionNames = true;
15464 Style);
15609 // Style::AlwaysBreakBeforeMultilineStrings.
15635 FormatStyle Style = getLLVMStyleWithColumns(12);
15636 Style.BreakStringLiterals = false;
15637 verifyFormat("\"some text other\";", Style);
15705 FormatStyle Style = getGoogleStyleWithColumns(15);
15706 verifyFormat("R\"x(raw literal)x\";", Style);
15707 verifyFormat("uR\"x(raw literal)x\";", Style);
15708 verifyFormat("LR\"x(raw literal)x\";", Style);
15709 verifyFormat("UR\"x(raw literal)x\";", Style);
15710 verifyFormat("u8R\"x(raw literal)x\";", Style);
15714 FormatStyle Style = getLLVMStyleWithColumns(20);
15720 format(" _T(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")", Style));
15725 "f(x, _T(\"aaaaaaaaaaaaaaa\"), z);", Style);
15735 " _T ( \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" )", Style);
15832 FormatStyle Style = getLLVMStyleWithColumns(25);
15833 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
15838 "someFunction(\"long long long long\", a);", Style);
15839 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
15845 Style);
15915 FormatStyle Style = getLLVMStyle();
15916 Style.Standard = FormatStyle::LS_Cpp03;
15918 "#define x(_a) printf(\"foo\"_a);", Style);
15922 FormatStyle Style = getLLVMStyle();
15924 verifyFormat("void foo() { MACRO(a * b); }", Style);
15925 verifyFormat("void foo() { MACRO(int *b); }", Style);
15928 verifyFormat("void foo() { MACRO(char8_t *b); }", Style);
15929 Style.Standard = FormatStyle::LS_Cpp17;
15931 verifyFormat("void foo() { MACRO(char8_t * b); }", Style);
18068 FormatStyle Style = getLLVMStyle();
18070 Style.PointerAlignment = FormatStyle::PAS_Left;
18071 Style.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
18072 verifyFormat("void* const* x = NULL;", Style);
18076 Style.PointerAlignment = FormatStyle::Pointers; \
18077 Style.SpaceAroundPointerQualifiers = FormatStyle::Qualifiers; \
18078 verifyFormat(Code, Style); \
18163 FormatStyle Style = getLLVMStyle();
18164 Style.AlignConsecutiveAssignments.Enabled = true;
18165 Style.AlignConsecutiveDeclarations.Enabled = true;
18170 Style);
18175 Style);
18179 Style);
18187 Style);
18189 Style.AlignConsecutiveMacros.Enabled = true;
18193 Style);
18197 Style);
18202 Style);
18206 Style);
18214 Style);
18231 Style);
18233 Style.AlignConsecutiveMacros.Enabled = false;
18234 Style.ColumnLimit = 20;
18245 Style);
18247 Style.AlignConsecutiveMacros.Enabled = true;
18257 Style);
18260 Style.MaxEmptyLinesToKeep = 10;
18261 Style.ReflowComments = FormatStyle::RCS_Never;
18262 Style.AlignConsecutiveMacros.AcrossComments = true;
18271 Style);
18281 Style);
18293 Style);
18305 Style);
18317 Style);
18320 Style.AlignConsecutiveMacros.AcrossComments = false;
18321 Style.AlignConsecutiveMacros.AcrossEmptyLines = true;
18330 Style);
18344 Style);
18356 Style);
18359 Style.AlignConsecutiveMacros.AcrossComments = true;
18365 Style);
18385 Style);
18405 Style);
20113 FormatStyle Style = getMozillaStyle();
20114 Style.AlignConsecutiveDeclarations.Enabled = true;
20117 "DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style);
20418 auto Style = getLLVMStyleWithColumns(120);
20420 EXPECT_EQ(Style.AlignConsecutiveAssignments,
20427 EXPECT_EQ(Style.AlignConsecutiveDeclarations,
20442 Style);
20452 Style);
20455 Style.AlignConsecutiveAssignments.Enabled = true;
20464 Style);
20474 Style);
20477 Style.AlignConsecutiveAssignments.Enabled = false;
20478 Style.AlignConsecutiveDeclarations.Enabled = true;
20487 Style);
20497 Style);
20500 Style.AlignConsecutiveAssignments.Enabled = true;
20501 Style.AlignConsecutiveDeclarations.Enabled = true;
20511 Style);
20521 Style);
20524 Style = getLLVMStyleWithColumns(20);
20525 Style.AlignConsecutiveAssignments.Enabled = true;
20526 Style.IndentWidth = 4;
20535 Style);
20541 Style);
20543 Style.ColumnLimit = 120;
20554 Style);
20557 Style.BinPackArguments = false;
20568 Style);
20573 auto Style = getLLVMStyleWithColumns(60);
20582 Style);
20584 Style.AlignConsecutiveAssignments.Enabled = true;
20585 Style.AlignConsecutiveDeclarations.Enabled = false;
20593 Style);
20595 Style.AlignConsecutiveAssignments.Enabled = false;
20596 Style.AlignConsecutiveDeclarations.Enabled = true;
20604 Style);
20606 Style.AlignConsecutiveAssignments.Enabled = true;
20607 Style.AlignConsecutiveDeclarations.Enabled = true;
20615 Style);
21618 auto Style = getLLVMStyle();
21619 Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
21623 Style);
21625 Style.AlignConsecutiveAssignments.Enabled = true;
21626 Style.AlignConsecutiveDeclarations.Enabled = true;
21632 Style);
21639 Style);
21647 Style);
21654 Style);
21661 Style);
21668 Style);
21675 Style);
21682 Style);
21691 Style);
21701 Style);
21707 Style);
21713 Style);
21719 Style);
21727 Style);
21729 Style.Cpp11BracedListStyle = false;
21735 Style);
21736 Style.Cpp11BracedListStyle = true;
21738 Style.ColumnLimit = 0;
21751 Style);
21753 Style.ColumnLimit = 80;
21759 Style);
21766 Style);
21773 Style);
21775 Style.ColumnLimit = 20;
21803 Style);
21805 Style = getLLVMStyleWithColumns(50);
21806 Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
21811 Style);
21820 Style);
21822 Style.ColumnLimit = 100;
21835 Style);
21837 Style = getLLVMStyleWithColumns(50);
21838 Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
21848 Style);
21849 Style.ColumnLimit = 100;
21850 Style.AlignConsecutiveAssignments.AcrossComments = true;
21851 Style.AlignConsecutiveDeclarations.AcrossComments = true;
21863 Style);
21876 Style);
21880 auto Style = getLLVMStyle();
21881 Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
21887 Style);
21894 Style);
21900 Style);
21906 Style);
21913 Style);
21919 Style);
21926 Style);
21932 Style);
21938 Style);
21944 Style);
21952 Style);
21961 Style);
21967 Style);
21973 Style);
21979 Style);
21987 Style);
21989 Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
21994 Style);
21996 Style.Cpp11BracedListStyle = false;
22002 Style);
22003 Style.Cpp11BracedListStyle = true;
22005 Style.ColumnLimit = 0;
22018 Style);
22020 Style.ColumnLimit = 80;
22026 Style);
22033 Style);
22040 Style);
22045 Style);
22047 Style.ColumnLimit = 20;
22077 Style));
22080 Style = getLLVMStyleWithColumns(50);
22081 Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
22086 Style);
22087 Style.ColumnLimit = 100;
22100 Style);
22102 Style.ColumnLimit = 25;
22111 Style);
22117 Style);
22119 Style.ColumnLimit = 120;
22127 Style);
22129 Style.SpacesInParens = FormatStyle::SIPO_Custom;
22130 Style.SpacesInParensOptions.Other = true;
22135 Style);
22189 auto Style = getLLVMStyleWithColumns(0);
22190 verifyFormat("#pragma region TEST(FOO : BAR)", Style);
22191 verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
22195 FormatStyle Style = getLLVMStyleWithColumns(20);
22205 Style);
22213 Style);
22217 Style);
22223 Style);
22231 Style);
22233 Style.PenaltyExcessCharacter = 90;
22234 verifyFormat("int a; // the comment", Style);
22237 "int a; // the comment aaa", Style);
22242 Style);
22246 Style);
22255 Style);
22261 Style);
22266 Style);
22274 Style);
22283 Style));
22292 Style));
22296 Style.ColumnLimit = 21;
22300 "// foo foo foo foo foo foo foo foo foo foo foo foo", Style);
22305 "int a = /* long block comment */ 42;", Style);
22309 FormatStyle Style = getLLVMStyle();
22310 Style.ColumnLimit = 8;
22311 Style.PenaltyExcessCharacter = 15;
22314 Style);
22315 Style.PenaltyBreakOpenParenthesis = 200;
22319 Style);
22323 FormatStyle Style = getLLVMStyle();
22324 Style.ColumnLimit = 5;
22325 Style.PenaltyExcessCharacter = 150;
22329 Style);
22330 Style.PenaltyBreakOpenParenthesis = 100'000;
22335 Style);
22339 FormatStyle Style = getLLVMStyle();
22340 Style.ColumnLimit = 4;
22341 Style.PenaltyExcessCharacter = 100;
22350 Style);
22351 Style.PenaltyBreakOpenParenthesis = 1250;
22365 Style);
22369 auto Style = getLLVMStyle();
22370 EXPECT_EQ(Style.PenaltyBreakBeforeMemberAccess, 150u);
22372 Style.ColumnLimit = 60;
22373 Style.PenaltyBreakBeforeMemberAccess = 110;
22378 Style);
22380 Style.ColumnLimit = 13;
22383 Style);
22387 FormatStyle Style = getLLVMStyle();
22388 Style.ColumnLimit = 20;
22389 Style.PenaltyExcessCharacter = 100;
22392 Style);
22393 Style.PenaltyBreakScopeResolution = 10;
22396 Style);
22416 auto Style = getLLVMStyle();
22417 Style.KeepEmptyLines.AtStartOfFile = false;
22419 "\xef\xbb\xbf\n#include <iostream>", Style);
22534 FormatStyle Style = getLLVMStyle();
22536 Style.ConstructorInitializerIndentWidth = 4;
22541 Style);
22543 Style.ConstructorInitializerIndentWidth = 2;
22548 Style);
22550 Style.ConstructorInitializerIndentWidth = 0;
22555 Style);
22556 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
22560 Style);
22565 Style);
22567 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
22571 Style);
22575 FormatStyle Style = getLLVMStyle();
22576 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
22577 Style.ConstructorInitializerIndentWidth = 4;
22582 Style);
22585 Style);
22587 Style.ColumnLimit = 0;
22590 Style);
22593 Style);
22598 Style);
22604 Style);
22606 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
22611 Style);
22614 Style);
22616 Style.ColumnLimit = 80;
22617 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
22618 Style.ConstructorInitializerIndentWidth = 2;
22623 Style);
22625 Style.ConstructorInitializerIndentWidth = 0;
22630 Style);
22632 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
22633 Style.ConstructorInitializerIndentWidth = 4;
22634 verifyFormat("SomeClass::Constructor() : aaaaaaaa(aaaaaaaa) {}", Style);
22637 Style);
22641 Style);
22642 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
22645 Style);
22648 Style);
22652 Style);
22654 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
22655 Style.ConstructorInitializerIndentWidth = 4;
22656 Style.ColumnLimit = 60;
22661 Style);
22662 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
22667 Style);
22671 FormatStyle Style = getLLVMStyle();
22672 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
22673 Style.ConstructorInitializerIndentWidth = 4;
22677 Style);
22684 Style);
22685 Style.ConstructorInitializerIndentWidth = 2;
22692 Style);
22693 Style.ConstructorInitializerIndentWidth = 0;
22702 Style);
22703 Style.ConstructorInitializerIndentWidth = 4;
22720 Style);
22739 Style);
22748 FormatStyle Style = getWebKitStyle();
22760 Style);
22771 Style);
22788 Style);
22791 verifyFormat("void f() { return; }", Style);
22794 verifyFormat("void f() { }", "void f() {}", Style);
22795 verifyFormat("while (true) { }", "while (true) {}", Style);
22800 "while (true) { continue; }", Style);
22811 Style);
22816 Style);
22821 "SomeClass::Constructor():a(a){}", Style);
22828 Style);
22835 Style);
22842 Style);
22847 Style);
22852 "ASSERT ( aaaa\n||bbbb);", Style);
22861 Style);
22865 "if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) { i++; }", Style);
22868 verifyFormat("#define aNumber 10", Style);
22874 Style);
22881 Style);
22886 Style);
22899 Style);
22905 Style);
22907 verifyFormat("[self.a b:c c:d];", Style);
22912 Style);
23230 auto Style = getGoogleStyle();
23231 Style.BinPackArguments = false;
23238 Style);
23670 Style = getLLVMStyleWithColumns(60);
23680 Style);
23681 Style.LambdaBodyIndentation = FormatStyle::LBI_OuterScope;
23691 Style);
23700 Style);
23707 Style);
23714 Style);
23721 Style);
23730 Style);
23739 Style);
23745 Style);
23751 Style);
23758 Style);
23771 Style);
23778 Style);
23792 Style);
23793 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
23800 Style);
23801 Style.PackConstructorInitializers = FormatStyle::PCIS_Never;
23809 Style);
23810 Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
23825 Style);
23842 Style);
23843 Style.BinPackArguments = false;
23860 Style);
23861 Style.BinPackArguments = true;
23862 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
23863 Style.BraceWrapping.BeforeLambdaBody = true;
23881 Style);
24269 FormatStyle Style = getLLVMStyle();
24275 Style);
24281 Style);
24357 FormatStyle Style = getLLVMStyle();
24358 Style.SpaceAfterTemplateKeyword = false;
24359 verifyFormat("template<int> void foo();", Style);
24569 FormatStyle Style = getLLVMStyle();
24570 Style.Language = FormatStyle::LK_TableGen;
24571 verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
24605 FormatStyle Style = getLLVMStyle();
24606 Style.Standard = FormatStyle::LS_Cpp03;
24608 verifyFormat("auto c = u8 'a';", "auto c = u8'a';", Style);
24908 FormatStyle Style = getLLVMStyle();
24909 Style.PointerAlignment = FormatStyle::PAS_Left;
24910 verifyFormat("_Atomic(uint64_t)* s(InitValue);", Style);
24911 verifyFormat("_Atomic(uint64_t)* s{InitValue};", Style);
24912 verifyFormat("_Atomic(int)* a;", Style);
24913 verifyFormat("_Atomic(int*)* a;", Style);
24914 verifyFormat("vector<_Atomic(uint64_t)* attr> x;", Style);
24916 Style.SpacesInParens = FormatStyle::SIPO_Custom;
24917 Style.SpacesInParensOptions.InCStyleCasts = true;
24918 verifyFormat("x = ( _Atomic(uint64_t) )*a;", Style);
24919 Style.SpacesInParensOptions.InCStyleCasts = false;
24920 Style.SpacesInParensOptions.Other = true;
24921 verifyFormat("x = (_Atomic( uint64_t ))*a;", Style);
24922 verifyFormat("x = (_Atomic( uint64_t ))&a;", Style);
24949 FormatStyle Style = getLLVMStyle();
24950 Style.ColumnLimit = 40;
24956 Style);
24960 Style);
24962 Style.ContinuationIndentWidth = 2;
24966 Style);
24979 FormatStyle Style = getLLVMStyle();
24980 verifyFormat("[]() -> auto { return Val; }", Style);
24981 verifyFormat("[]() -> auto * { return Val; }", Style);
24982 verifyFormat("[]() -> auto & { return Val; }", Style);
24983 verifyFormat("auto foo() -> auto { return Val; }", Style);
24984 verifyFormat("auto foo() -> auto * { return Val; }", Style);
24985 verifyFormat("auto foo() -> auto & { return Val; }", Style);
25076 FormatStyle Style = getLLVMStyle();
25077 Style.PointerAlignment = FormatStyle::PAS_Right;
25078 verifyFormat("Foo::operator*();", Style);
25079 verifyFormat("Foo::operator void *();", Style);
25080 verifyFormat("Foo::operator void **();", Style);
25081 verifyFormat("Foo::operator void *&();", Style);
25082 verifyFormat("Foo::operator void *&&();", Style);
25083 verifyFormat("Foo::operator void const *();", Style);
25084 verifyFormat("Foo::operator void const **();", Style);
25085 verifyFormat("Foo::operator void const *&();", Style);
25086 verifyFormat("Foo::operator void const *&&();", Style);
25087 verifyFormat("Foo::operator()(void *);", Style);
25088 verifyFormat("Foo::operator*(void *);", Style);
25089 verifyFormat("Foo::operator*();", Style);
25090 verifyFormat("Foo::operator**();", Style);
25091 verifyFormat("Foo::operator&();", Style);
25092 verifyFormat("Foo::operator<int> *();", Style);
25093 verifyFormat("Foo::operator<Foo> *();", Style);
25094 verifyFormat("Foo::operator<int> **();", Style);
25095 verifyFormat("Foo::operator<Foo> **();", Style);
25096 verifyFormat("Foo::operator<int> &();", Style);
25097 verifyFormat("Foo::operator<Foo> &();", Style);
25098 verifyFormat("Foo::operator<int> &&();", Style);
25099 verifyFormat("Foo::operator<Foo> &&();", Style);
25100 verifyFormat("Foo::operator<int> *&();", Style);
25101 verifyFormat("Foo::operator<Foo> *&();", Style);
25102 verifyFormat("Foo::operator<int> *&&();", Style);
25103 verifyFormat("Foo::operator<Foo> *&&();", Style);
25104 verifyFormat("operator*(int (*)(), class Foo);", Style);
25106 verifyFormat("Foo::operator&();", Style);
25107 verifyFormat("Foo::operator void &();", Style);
25108 verifyFormat("Foo::operator void const &();", Style);
25109 verifyFormat("Foo::operator()(void &);", Style);
25110 verifyFormat("Foo::operator&(void &);", Style);
25111 verifyFormat("Foo::operator&();", Style);
25112 verifyFormat("operator&(int (&)(), class Foo);", Style);
25113 verifyFormat("operator&&(int (&)(), class Foo);", Style);
25115 verifyFormat("Foo::operator&&();", Style);
25116 verifyFormat("Foo::operator**();", Style);
25117 verifyFormat("Foo::operator void &&();", Style);
25118 verifyFormat("Foo::operator void const &&();", Style);
25119 verifyFormat("Foo::operator()(void &&);", Style);
25120 verifyFormat("Foo::operator&&(void &&);", Style);
25121 verifyFormat("Foo::operator&&();", Style);
25122 verifyFormat("operator&&(int (&&)(), class Foo);", Style);
25123 verifyFormat("operator const nsTArrayRight<E> &()", Style);
25125 Style);
25126 verifyFormat("operator void **()", Style);
25127 verifyFormat("operator const FooRight<Object> &()", Style);
25128 verifyFormat("operator const FooRight<Object> *()", Style);
25129 verifyFormat("operator const FooRight<Object> **()", Style);
25130 verifyFormat("operator const FooRight<Object> *&()", Style);
25131 verifyFormat("operator const FooRight<Object> *&&()", Style);
25133 Style.PointerAlignment = FormatStyle::PAS_Left;
25134 verifyFormat("Foo::operator*();", Style);
25135 verifyFormat("Foo::operator**();", Style);
25136 verifyFormat("Foo::operator void*();", Style);
25137 verifyFormat("Foo::operator void**();", Style);
25138 verifyFormat("Foo::operator void*&();", Style);
25139 verifyFormat("Foo::operator void*&&();", Style);
25140 verifyFormat("Foo::operator void const*();", Style);
25141 verifyFormat("Foo::operator void const**();", Style);
25142 verifyFormat("Foo::operator void const*&();", Style);
25143 verifyFormat("Foo::operator void const*&&();", Style);
25144 verifyFormat("Foo::operator/*comment*/ void*();", Style);
25145 verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
25146 verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
25147 verifyFormat("Foo::operator()(void*);", Style);
25148 verifyFormat("Foo::operator*(void*);", Style);
25149 verifyFormat("Foo::operator*();", Style);
25150 verifyFormat("Foo::operator<int>*();", Style);
25151 verifyFormat("Foo::operator<Foo>*();", Style);
25152 verifyFormat("Foo::operator<int>**();", Style);
25153 verifyFormat("Foo::operator<Foo>**();", Style);
25154 verifyFormat("Foo::operator<Foo>*&();", Style);
25155 verifyFormat("Foo::operator<int>&();", Style);
25156 verifyFormat("Foo::operator<Foo>&();", Style);
25157 verifyFormat("Foo::operator<int>&&();", Style);
25158 verifyFormat("Foo::operator<Foo>&&();", Style);
25159 verifyFormat("Foo::operator<int>*&();", Style);
25160 verifyFormat("Foo::operator<Foo>*&();", Style);
25161 verifyFormat("operator*(int (*)(), class Foo);", Style);
25163 verifyFormat("Foo::operator&();", Style);
25164 verifyFormat("Foo::operator void&();", Style);
25165 verifyFormat("Foo::operator void const&();", Style);
25166 verifyFormat("Foo::operator/*comment*/ void&();", Style);
25167 verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
25168 verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
25169 verifyFormat("Foo::operator()(void&);", Style);
25170 verifyFormat("Foo::operator&(void&);", Style);
25171 verifyFormat("Foo::operator&();", Style);
25172 verifyFormat("operator&(int (&)(), class Foo);", Style);
25173 verifyFormat("operator&(int (&&)(), class Foo);", Style);
25174 verifyFormat("operator&&(int (&&)(), class Foo);", Style);
25176 verifyFormat("Foo::operator&&();", Style);
25177 verifyFormat("Foo::operator void&&();", Style);
25178 verifyFormat("Foo::operator void const&&();", Style);
25179 verifyFormat("Foo::operator/*comment*/ void&&();", Style);
25180 verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
25181 verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
25182 verifyFormat("Foo::operator()(void&&);", Style);
25183 verifyFormat("Foo::operator&&(void&&);", Style);
25184 verifyFormat("Foo::operator&&();", Style);
25185 verifyFormat("operator&&(int (&&)(), class Foo);", Style);
25186 verifyFormat("operator const nsTArrayLeft<E>&()", Style);
25188 Style);
25189 verifyFormat("operator void**()", Style);
25190 verifyFormat("operator const FooLeft<Object>&()", Style);
25191 verifyFormat("operator const FooLeft<Object>*()", Style);
25192 verifyFormat("operator const FooLeft<Object>**()", Style);
25193 verifyFormat("operator const FooLeft<Object>*&()", Style);
25194 verifyFormat("operator const FooLeft<Object>*&&()", Style);
25197 verifyFormat("operator Vector<String>&();", Style);
25198 verifyFormat("operator const Vector<String>&();", Style);
25199 verifyFormat("operator foo::Bar*();", Style);
25200 verifyFormat("operator const Foo<X>::Bar<Y>*();", Style);
25202 Style);
25204 Style.PointerAlignment = FormatStyle::PAS_Middle;
25205 verifyFormat("Foo::operator*();", Style);
25206 verifyFormat("Foo::operator void *();", Style);
25207 verifyFormat("Foo::operator()(void *);", Style);
25208 verifyFormat("Foo::operator*(void *);", Style);
25209 verifyFormat("Foo::operator*();", Style);
25210 verifyFormat("operator*(int (*)(), class Foo);", Style);
25212 verifyFormat("Foo::operator&();", Style);
25213 verifyFormat("Foo::operator void &();", Style);
25214 verifyFormat("Foo::operator void const &();", Style);
25215 verifyFormat("Foo::operator()(void &);", Style);
25216 verifyFormat("Foo::operator&(void &);", Style);
25217 verifyFormat("Foo::operator&();", Style);
25218 verifyFormat("operator&(int (&)(), class Foo);", Style);
25220 verifyFormat("Foo::operator&&();", Style);
25221 verifyFormat("Foo::operator void &&();", Style);
25222 verifyFormat("Foo::operator void const &&();", Style);
25223 verifyFormat("Foo::operator()(void &&);", Style);
25224 verifyFormat("Foo::operator&&(void &&);", Style);
25225 verifyFormat("Foo::operator&&();", Style);
25226 verifyFormat("operator&&(int (&&)(), class Foo);", Style);
25230 FormatStyle Style = getLLVMStyle();
25232 verifyFormat("foo(operator+, -42);", Style);
25233 verifyFormat("foo(operator++, -42);", Style);
25234 verifyFormat("foo(operator--, -42);", Style);
25235 verifyFormat("foo(-42, operator--);", Style);
25236 verifyFormat("foo(-42, operator, );", Style);
25237 verifyFormat("foo(operator, , -42);", Style);
25241 FormatStyle Style = getLLVMStyle();
25242 Style.WhitespaceSensitiveMacros.push_back("FOO");
25245 verifyNoChange("FOO(1+2 )\n", Style);
25246 verifyNoChange("FOO(a:b:c)\n", Style);
25250 verifyNoChange("FOO(String-ized&Messy+But(: :Still)=Intentional);", Style);
25251 verifyNoChange("FOO(String-ized&Messy+But\\(: :Still)=Intentional);", Style);
25252 verifyNoChange("FOO(String-ized&Messy+But,: :Still=Intentional);", Style);
25255 Style);
25256 Style.AlignConsecutiveAssignments.Enabled = true;
25259 Style);
25261 Style.ColumnLimit = 21;
25262 verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style);
25266 auto Style = getLLVMStyle();
25267 Style.SkipMacroDefinitionBody = true;
25269 verifyFormat("#define A", "#define A", Style);
25270 verifyFormat("#define A a aa", "#define A a aa", Style);
25271 verifyNoChange("#define A b", Style);
25272 verifyNoChange("#define A ( args )", Style);
25273 verifyNoChange("#define A ( args ) = func ( args )", Style);
25274 verifyNoChange("#define A ( args ) { int a = 1 ; }", Style);
25279 Style);
25281 verifyNoChange("#define A x:", Style);
25282 verifyNoChange("#define A a. b", Style);
25291 Style);
25294 Style.ColumnLimit = 10;
25295 verifyFormat("#define A a a a a", " # define A a a a a ", Style);
25296 verifyNoChange("#define A a a a a", Style);
25298 Style.ColumnLimit = 15;
25303 "#define A //a very long comment", Style);
25304 Style.ColumnLimit = 0;
25310 Style);
25315 Style);
25316 Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
25321 Style);
25322 Style.AlignEscapedNewlines = FormatStyle::ENAS_Right;
25327 Style);
25330 Style.IndentPPDirectives = FormatStyle::PPDIS_None;
25334 Style);
25341 Style);
25342 Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
25346 Style);
25353 Style);
25354 Style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
25358 Style);
25365 Style);
25367 Style.IndentPPDirectives = FormatStyle::PPDIS_None;
25375 Style);
25379 Style);
25380 verifyNoChange("/* */ #define A a // a a", Style);
25388 Style);
25397 Style);
25403 Style);
25409 FormatStyle Style = getLLVMStyleWithColumns(80);
25414 Style);
25420 Style);
25430 Style);
25448 Style);
25470 Style);
25474 FormatStyle Style = getLLVMStyle();
25479 Style);
25484 Style);
25491 Style);
25500 Style);
25505 Style);
25509 Style);
25512 Style);
25517 Style);
25521 Style);
25525 Style);
25528 Style);
25530 Style.AttributeMacros.push_back("UNLIKELY");
25531 Style.AttributeMacros.push_back("LIKELY");
25534 Style);
25539 Style);
25545 Style);
25551 Style);
25557 Style);
25562 Style);
25566 Style);
25570 Style);
25573 Style);
25599 FormatStyle Style = getLLVMStyle();
25603 Style);
25606 FormatStyle Style = getGNUStyle();
25611 Style);
25614 FormatStyle Style = getMozillaStyle();
25619 Style);
25622 FormatStyle Style = getGoogleStyle();
25626 Style);
25629 FormatStyle Style = getChromiumStyle(FormatStyle::LanguageKind::LK_Cpp);
25633 Style);
25636 FormatStyle Style = getMicrosoftStyle(FormatStyle::LanguageKind::LK_Cpp);
25641 Style);
25644 FormatStyle Style = getWebKitStyle();
25648 Style);
25657 FormatStyle Style = getLLVMStyle();
25658 Style.RequiresExpressionIndentation = FormatStyle::REI_Keyword;
25677 Style);
25684 Style);
25790 Style);
25797 Style);
25805 Style);
25812 Style);
25829 Style);
25843 Style);
25858 Style);
25866 Style);
25875 Style);
25886 Style);
25894 Style);
25901 Style);
25908 Style);
25916 Style);
25928 Style);
25940 Style);
25966 Style.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Allowed;
25974 Style);
25986 Style);
25988 verifyFormat("template <typename T> concept True = true;", Style);
25994 Style);
26008 Style);
26010 Style.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Never;
26017 Style);
26027 Style);
26029 verifyFormat("template <typename T> concept True = true;", Style);
26035 Style);
26048 Style);
26069 auto Style = getLLVMStyle();
26070 EXPECT_EQ(Style.RequiresClausePosition, FormatStyle::RCPS_OwnLine);
26071 EXPECT_EQ(Style.IndentRequiresClause, true);
26075 Style.RequiresExpressionIndentation = FormatStyle::REI_Keyword;
26080 Style);
26089 Style);
26098 Style);
26103 Style);
26113 Style);
26124 Style);
26131 Style);
26139 Style);
26147 Style);
26152 Style);
26154 Style.IndentRequiresClause = false;
26160 Style);
26168 Style);
26176 Style);
26178 Style.RequiresClausePosition = FormatStyle::RCPS_OwnLineWithBrace;
26179 Style.IndentRequiresClause = true;
26184 Style);
26193 Style);
26202 Style);
26207 Style);
26217 Style);
26227 Style);
26234 Style);
26241 Style);
26248 Style);
26253 Style);
26258 Style);
26260 Style.RequiresClausePosition = FormatStyle::RCPS_SingleLine;
26261 Style.IndentRequiresClause = false;
26268 Style);
26270 auto ColumnStyle = Style;
26310 Style.RequiresClausePosition = FormatStyle::RCPS_WithFollowing;
26328 Style);
26346 Style.IndentRequiresClause = true;
26361 Style);
26379 Style.RequiresClausePosition = FormatStyle::RCPS_WithPreceding;
26395 Style);
26429 auto Style = getLLVMStyle();
26444 Style);
26446 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
26461 Style);
26463 Style = getLLVMStyle();
26464 Style.ConstructorInitializerIndentWidth = 4;
26465 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
26466 Style.PackConstructorInitializers = FormatStyle::PCIS_Never;
26473 Style);
26484 auto Style = getLLVMStyle();
26485 EXPECT_EQ(Style.RequiresExpressionIndentation, FormatStyle::REI_OuterScope);
26494 Style);
26504 Style);
26515 Style);
26523 Style);
26531 Style);
26539 Style);
26541 Style.RequiresExpressionIndentation = FormatStyle::REI_Keyword;
26550 Style);
26561 Style);
26572 Style);
26580 Style);
26589 Style);
26597 Style);
26601 FormatStyle Style = getLLVMStyle();
26608 verifyFormat(Source, Style);
26610 Style.AlignConsecutiveDeclarations.Enabled = true;
26616 Source, Style);
26618 Style.StatementAttributeLikeMacros.push_back("emit");
26619 verifyFormat(Source, Style);
26621 Style.StatementAttributeLikeMacros = {};
26627 Source, Style);
26631 FormatStyle Style = getLLVMStyle();
26632 Style.IndentAccessModifiers = true;
26634 // Style.IndentWidth == 2, thus yielding a 4 spaces wide indentation.
26638 Style);
26643 Style);
26649 Style);
26654 Style);
26667 Style);
26669 Style.AllowShortEnumsOnASingleLine = false;
26674 Style);
26676 // also proves that the result is Style.AccessModifierOffset agnostic.
26677 Style.IndentWidth = 3;
26682 Style);
26687 Style);
26688 Style.AttributeMacros.push_back("FOO");
26693 Style);
26697 auto Style = getLLVMStyleWithColumns(0);
26701 "the LLVM Style.\n"
26708 "some long lines, at least for the LLVM Style.\"\n"
26713 "least for the LLVM Style.\n"
26720 verifyNoChange(Code, Style);
26748 FormatStyle Style = getLLVMStyle();
26749 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
26750 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
26752 verifyFormat("export import foo;", Style);
26753 verifyFormat("export import foo:bar;", Style);
26754 verifyFormat("export import foo.bar;", Style);
26755 verifyFormat("export import foo.bar:baz;", Style);
26756 verifyFormat("export import :bar;", Style);
26757 verifyFormat("export module foo:bar;", Style);
26758 verifyFormat("export module foo;", Style);
26759 verifyFormat("export module foo.bar;", Style);
26760 verifyFormat("export module foo.bar:baz;", Style);
26761 verifyFormat("export import <string_view>;", Style);
26762 verifyFormat("export import <Foo/Bar>;", Style);
26764 verifyFormat("export type_name var;", Style);
26765 verifyFormat("template <class T> export using A = B<T>;", Style);
26766 verifyFormat("export using A = B;", Style);
26770 Style);
26774 Style);
26778 Style);
26781 verifyFormat("import bar;", Style);
26782 verifyFormat("import foo.bar;", Style);
26783 verifyFormat("import foo:bar;", Style);
26784 verifyFormat("import :bar;", Style);
26785 verifyFormat("import /* module partition */ :bar;", Style);
26786 verifyFormat("import <ctime>;", Style);
26787 verifyFormat("import \"header\";", Style);
26789 verifyFormat("module foo;", Style);
26790 verifyFormat("module foo:bar;", Style);
26791 verifyFormat("module foo.bar;", Style);
26792 verifyFormat("module;", Style);
26797 Style);
26799 verifyFormat("module :private;", Style);
26800 verifyFormat("import <foo/bar.h>;", Style);
26801 verifyFormat("import foo...bar;", Style);
26802 verifyFormat("import ..........;", Style);
26803 verifyFormat("module foo:private;", Style);
26804 verifyFormat("import a", Style);
26805 verifyFormat("module a", Style);
26806 verifyFormat("export import a", Style);
26807 verifyFormat("export module a", Style);
26809 verifyFormat("import", Style);
26810 verifyFormat("module", Style);
26811 verifyFormat("export", Style);
26817 FormatStyle Style = getLLVMStyle();
26821 Style);
26824 Style);
26827 Style);
26846 FormatStyle Style = getLLVMStyleWithColumns(40);
26850 Style);
26875 auto Style = getLLVMStyle();
26876 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
26883 Style);
26888 Style);
26892 auto Style = getLLVMStyle();
26894 verifyFormat("template <> struct S : Template<int (*)[]> {};", Style);
26895 verifyFormat("template <> struct S : Template<int (*)[10]> {};", Style);
26896 verifyFormat("struct Y : X<[] { return 0; }> {};", Style);
26897 verifyFormat("struct Y<[] { return 0; }> {};", Style);
26899 verifyFormat("struct Z : X<decltype([] { return 0; }){}> {};", Style);
26900 verifyFormat("template <int N> struct Foo<char[N]> {};", Style);
26904 auto Style = getLLVMStyleWithColumns(70);
26910 Style);
26916 Style);
26918 Style = getLLVMStyleWithColumns(60);
26925 Style);
26931 Style);
26933 Style = getLLVMStyleWithColumns(40);
26940 Style);
26948 Style);
26952 auto Style = getLLVMStyle();
26962 verifyFormat(Short, Style);
26971 verifyFormat(NoBreak, Medium, Style);
26991 Style);
26998 Style);
27000 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
27002 verifyFormat(Short, Style);
27012 Medium, Style);
27014 Style.AllowAllArgumentsOnNextLine = false;
27015 Style.AllowAllParametersOfDeclarationOnNextLine = false;
27017 verifyFormat(Short, Style);
27027 Medium, Style);
27029 Style.BinPackArguments = false;
27030 Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
27032 verifyFormat(Short, Style);
27052 Medium, Style);
27064 Style);
27066 verifyFormat("int a = (int)b;", Style);
27071 Style);
27073 verifyFormat("return (true);", Style);
27078 Style);
27080 verifyFormat("void foo();", Style);
27084 Style);
27086 verifyFormat("void foo() {}", Style);
27091 Style);
27093 verifyFormat("auto string = std::string();", Style);
27097 Style);
27099 verifyFormat("void (*functionPointer)() = nullptr;", Style);
27106 Style);
27110 auto Style = getLLVMStyle();
27115 Style);
27122 Style);
27124 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
27129 Style);
27136 Style);
27153 Style);
27155 Style.ContinuationIndentWidth = 2;
27168 Style);
27172 auto Style = getLLVMStyle();
27177 Style);
27184 Style);
27186 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
27191 Style);
27198 Style);
27202 auto Style = getLLVMStyleWithColumns(60);
27203 Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
27208 Style);
27213 Style);
27218 Style);
27224 Style);
27231 Style);
27237 Style);
27243 Style);
27252 Style);
27259 Style);
27266 Style);
27273 Style);
27280 Style);
27287 Style);
27294 Style);
27301 Style);
27307 Style);
27318 Style);
27330 Style);
27347 Style);
27361 auto Style = getLLVMStyle();
27362 Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
27363 Style.AlignConsecutiveAssignments.Enabled = true;
27364 Style.AlignConsecutiveDeclarations.Enabled = true;
27374 Style);
27380 Style);
27386 Style);
27392 Style);
27399 Style);
27405 Style);
27421 Style);
27425 auto Style = getLLVMStyle();
27426 Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
27427 Style.AlignConsecutiveAssignments.Enabled = true;
27428 Style.AlignConsecutiveDeclarations.Enabled = true;
27438 Style);
27444 Style);
27450 Style);
27456 Style);
27463 Style);
27469 Style);
27485 Style);
27495 FormatStyle Style = getLLVMStyle();
27496 Style.RemoveSemicolon = true;
27499 "int max(int a, int b) { return a > b ? a : b; };", Style);
27502 "int max(int a, int b) { return a > b ? a : b; };;", Style);
27510 Style);
27518 Style);
27522 Style);
27527 Style);
27532 Style);
27534 verifyIncompleteFormat("class C final [[deprecated(l]] {});", Style);
27536 verifyFormat("void main() {}", "void main() {};", Style);
27546 Style);
27554 Style);
27562 Style);
27564 Style.TypenameMacros.push_back("STRUCT");
27565 verifyFormat("STRUCT(T, B) { int i; };", Style);
27587 FormatStyle Style = getLLVMStyle();
27588 EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Leave);
27589 verifyNoChange(Code, Style);
27591 Style.BreakAfterAttributes = FormatStyle::ABS_Never;
27605 Code, Style);
27607 Style.BreakAfterAttributes = FormatStyle::ABS_Always;
27628 Code, Style);
27649 Style.BreakAfterAttributes = FormatStyle::ABS_Leave;
27650 verifyNoChange(CtrlStmtCode, Style);
27652 Style.BreakAfterAttributes = FormatStyle::ABS_Never;
27668 CtrlStmtCode, Style);
27670 Style.BreakAfterAttributes = FormatStyle::ABS_Always;
27692 CtrlStmtCode, Style);
27725 CtorDtorCode, Style);
27727 Style.BreakBeforeBraces = FormatStyle::BS_Linux;
27760 CtorDtorCode, Style);
27768 Style);
27770 Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
27773 Style);
27777 FormatStyle Style = getLLVMStyle();
27778 Style.InsertNewlineAtEOF = true;
27780 verifyNoChange("int i;\n", Style);
27781 verifyFormat("int i;\n", "int i;", Style);
27786 verifyFormat(Code.str() + '\n', Code, Style,
27791 FormatStyle Style = getLLVMStyle();
27792 Style.KeepEmptyLines.AtEndOfFile = true;
27795 verifyNoChange(Code, Style);
27796 verifyFormat(Code, "int i;\n\n\n", Style);
27824 FormatStyle Style = getLLVMStyle();
27825 EXPECT_EQ(Style.RemoveParentheses, FormatStyle::RPS_Leave);
27827 Style.RemoveParentheses = FormatStyle::RPS_MultipleParentheses;
27828 verifyFormat("#define Foo(...) foo((__VA_ARGS__))", Style);
27829 verifyFormat("int x __attribute__((aligned(16))) = 0;", Style);
27830 verifyFormat("decltype((foo->bar)) baz;", Style);
27832 "class __declspec((dllimport)) X {};", Style);
27833 verifyFormat("int x = (({ 0; }));", "int x = ((({ 0; })));", Style);
27838 Style);
27843 Style);
27848 Style);
27853 Style);
27858 Style);
27861 Style);
27862 verifyFormat("foo((a, b));", "foo(((a, b)));", Style);
27863 verifyFormat("foo((a, b));", "foo(((a), b));", Style);
27864 verifyFormat("foo((a, b));", "foo((a, (b)));", Style);
27865 verifyFormat("foo((a, b, c));", "foo((a, ((b)), c));", Style);
27866 verifyFormat("return (0);", "return (((0)));", Style);
27867 verifyFormat("return (({ 0; }));", "return ((({ 0; })));", Style);
27870 Style);
27872 Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
27873 verifyFormat("#define Return0 return (0);", Style);
27874 verifyFormat("return 0;", "return (0);", Style);
27875 verifyFormat("co_return 0;", "co_return ((0));", Style);
27876 verifyFormat("return 0;", "return (((0)));", Style);
27877 verifyFormat("return ({ 0; });", "return ((({ 0; })));", Style);
27880 Style);
27893 Style);
27930 Style);
27932 Style.ColumnLimit = 25;
27936 Style);
27940 auto Style = getLLVMStyleWithColumns(35);
27942 EXPECT_EQ(Style.AllowBreakBeforeNoexceptSpecifier, FormatStyle::BBNSS_Never);
27945 Style);
27952 Style);
27955 Style);
27957 Style.AllowBreakBeforeNoexceptSpecifier = FormatStyle::BBNSS_Always;
27960 Style);
27965 Style);
27969 Style);
27971 Style.AllowBreakBeforeNoexceptSpecifier = FormatStyle::BBNSS_OnlyWithParen;
27974 Style);
27979 Style);
27982 Style);
28026 auto Style = getLLVMStyle();
28027 Style.BreakAdjacentStringLiterals = false;
28028 verifyFormat(Code, Style);
28037 auto Style = getLLVMStyle();
28038 Style.ColumnLimit = 15;
28043 Style);
28045 Style.ColumnLimit = 25;
28051 Style);
28053 Style.ColumnLimit = 35;
28058 Style);
28060 Style.ColumnLimit = 80;
28061 Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
28067 Style);
28077 auto Style = getLLVMStyleWithColumns(60);
28078 EXPECT_EQ(Style.BreakBinaryOperations, FormatStyle::BBO_Never);
28083 Style);
28089 Style);
28094 Style);
28097 verifyFormat("const int result = lhs + rhs;", Style);
28101 Style);
28106 Style);
28110 Style);
28115 Style);
28117 Style.BreakBinaryOperations = FormatStyle::BBO_OnePerLine;
28122 Style);
28130 Style);
28135 Style);
28138 verifyFormat("const int result = lhs + rhs;", Style);
28143 Style);
28147 Style);
28154 Style);
28162 Style);
28165 verifyFormat("result = op1 + op2 * op3 - op4;", Style);
28173 Style);
28181 Style);
28187 Style);
28193 Style);
28200 Style);
28202 Style.BreakBinaryOperations = FormatStyle::BBO_RespectPrecedence;
28203 verifyFormat("result = op1 + op2 * op3 - op4;", Style);
28208 Style);
28214 Style);
28219 Style);
28225 Style);
28232 Style);
28234 Style.BreakBinaryOperations = FormatStyle::BBO_OnePerLine;
28235 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
28240 Style);
28245 Style);
28248 verifyFormat("const int result = lhs + rhs;", Style);
28253 Style);
28257 Style);
28264 Style);
28272 Style);
28275 verifyFormat("result = op1 + op2 * op3 - op4;", Style);
28283 Style);
28291 Style);
28297 Style);
28306 Style);
28313 Style);
28315 Style.BreakBinaryOperations = FormatStyle::BBO_RespectPrecedence;
28316 verifyFormat("result = op1 + op2 * op3 - op4;", Style);
28321 Style);
28327 Style);
28332 Style);
28338 Style);
28345 Style);
28349 auto Style = getLLVMStyle();
28350 Style.RemoveEmptyLinesInUnwrappedLines = true;
28356 Style);
28365 Style);
28375 Style);
28383 Style);
28391 Style);
28407 Style);
28415 Style);
28422 Style);
28426 auto Style = getLLVMStyle();
28427 Style.KeepFormFeed = true;
28436 Style);
28441 Style);
28446 Style);
28451 Style);
28456 verifyNoChange(FormFeed, Style);
28458 Style.LineEnding = FormatStyle::LE_LF;
28463 Style);
28469 Style.MaxEmptyLinesToKeep = 2;
28475 Style);
28481 Style);
28485 auto Style = getLLVMStyle();
28486 Style.AllowShortNamespacesOnASingleLine = true;
28487 Style.CompactNamespaces = true;
28488 Style.FixNamespaceComments = false;
28491 verifyFormat("namespace foo { class bar; }", Style);
28492 verifyFormat("namespace foo::bar { class baz; }", Style);
28493 verifyFormat("namespace { class bar; }", Style);
28498 Style);
28505 Style);
28508 verifyFormat("namespace foo {", Style);
28511 Style);
28514 Style);
28517 verifyFormat("namespace foo { namespace bar { class baz; } }", Style);
28521 Style.CompactNamespaces = false;
28525 Style);
28531 Style);
28533 Style.CompactNamespaces = true;
28539 Style);
28540 verifyFormat("namespace foo { template <T> struct bar; }", Style);
28541 verifyFormat("namespace foo { constexpr int num = 42; }", Style);
28544 Style.ColumnLimit = 64;
28549 Style);
28555 Style);
28561 Style);
28565 Style);
28570 Style);
28581 Style.FixNamespaceComments = true;
28587 Style);
28591 auto Style = getLLVMStyle();
28592 Style.FixNamespaceComments = false;
28593 Style.MaxEmptyLinesToKeep = 2;
28594 Style.WrapNamespaceBodyWithEmptyLines = FormatStyle::WNBWELS_Never;
28597 verifyFormat("namespace N {}", Style);
28610 Style);
28629 Style);
28631 Style.CompactNamespaces = true;
28643 Style);
28647 auto Style = getLLVMStyle();
28648 Style.FixNamespaceComments = false;
28649 Style.MaxEmptyLinesToKeep = 2;
28650 Style.WrapNamespaceBodyWithEmptyLines = FormatStyle::WNBWELS_Always;
28653 verifyFormat("namespace N {}", Style);
28664 Style);
28679 Style);
28705 Style);
28707 Style.CompactNamespaces = true;
28717 Style);