summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Fix binary operator detection before lambdas.Daniel Jasper2014-05-081-0/+1
| | | | | | | | | | Before: bool foo = true&& [] { return false; }(); After: bool foo = true && [] { return false; }(); llvm-svn: 208288
* Enable alternative tokens by default for clang-format.Nikola Smiljanic2014-05-081-0/+45
| | | | | | Patch by Bobby Moretti. llvm-svn: 208269
* clang-format: Fix corner cases for comments in if conditions.Daniel Jasper2014-05-071-0/+17
| | | | | | | | | | | | Before: if ( // a x + 3) { .. After: if ( // a x + 3) { .. llvm-svn: 208175
* clang-format: Fix bad space before braced initializer.Daniel Jasper2014-05-071-0/+1
| | | | | | | | | | Before: new int {1}; After: new int{1}; llvm-svn: 208168
* Fixed one issue with castingDinesh Dwivedi2014-05-061-0/+2
| | | | | | | | | | | | Before: (void) SimplifyICmpOperands(Cond, LHS, RHS); After: (void)SimplifyICmpOperands(Cond, LHS, RHS); Differential Revision: http://reviews.llvm.org/D3615 llvm-svn: 208080
* clang-format: Understand functions with decltype return type.Daniel Jasper2014-05-051-0/+2
| | | | | | | | | | | | Before: decltype(long_name_forcing_break) f() {} After: decltype(long_name_forcing_break) f() {} llvm-svn: 207965
* Added some heuristics to identify c style castingDinesh Dwivedi2014-05-051-7/+12
| | | | | | | | | | | | | | Before: void f() { my_int a = (my_int) * b; } void f() { return P ? (my_int) * P : (my_int)0; } After: void f() { my_int a = (my_int)*b; } void f() { return P ? (my_int)*P : (my_int)0; } Differential Revision: http://reviews.llvm.org/D3576 llvm-svn: 207964
* clang-format: Improve understanding of decltype.Daniel Jasper2014-05-051-0/+3
| | | | | | | | | | Before: SomeFunction([](decltype(x), A * a) {}); After: SomeFunction([](decltype(x), A *a) {}); llvm-svn: 207961
* Fix bug in clang-format while merging short functionDinesh Dwivedi2014-05-051-0/+90
| | | | | | | | | | | | | | | | | | | | | Before: #ifdef _DEBUG int foo( int i = 0 ) #else int foo( int i = 5 ) #endif { return i; } After: #ifdef _DEBUG int foo( int i = 0 ) #else int foo( int i = 5 ) #endif { return i; } llvm-svn: 207958
* clang-format: Fix import statements with ColumnLimit: 0Daniel Jasper2014-05-051-0/+5
| | | | | | These used to interact badly with AlwaysBreakBeforeMultilineStrings. llvm-svn: 207955
* Fixes issue with Allman BreakBeforeBraces for Objective C @interfaceDinesh Dwivedi2014-05-021-0/+16
| | | | | | | | | | | | | | | | | | | Before: @interface BSApplicationController () { @private id _extraIvar; } @end After: @interface BSApplicationController () { @private id _extraIvar; } @end llvm-svn: 207849
* clang-format: Allow single-line function in WebKit style.Daniel Jasper2014-04-291-0/+3
| | | | | | | | | | | Before: void f() { return; } After: void f() { return; } llvm-svn: 207527
* clang-format: Improve binary operator detection.Daniel Jasper2014-04-281-0/+1
| | | | | | | | | | | | Before: *(int *)(p &~3UL) = 0; After: *(int *)(p & ~3UL) = 0; This fixes llvm.org/PR19464. llvm-svn: 207405
* clang-format: Fixes spaces in case statements.Daniel Jasper2014-04-281-0/+4
| | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19482. Before: switch (a) { case(B) : return; } After: switch (a) { case (B): return; } llvm-svn: 207402
* clang-format: Don't wrap after @interface.Daniel Jasper2014-04-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19450. Before: @interface BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate, BookmarkFolderCollectionViewDelegate, BookmarkMenuViewControllerDelegate, BookmarkSearchViewControllerDelegate> { } After: @interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> { } llvm-svn: 207400
* clang-format: Fix bug when aligning trailing /**/-comments in macros.Daniel Jasper2014-04-271-0/+11
| | | | | | | Previously this could lead to a column limit violation with the required escaped newlines. llvm-svn: 207351
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | | | | definition below all of the header #include lines, clang edition. If you want more details about this, you can see some of the commits to Debug.h in LLVM recently. This is just the clang section of a cleanup I've done for all uses of DEBUG_TYPE in LLVM. llvm-svn: 206849
* Fix alignment of trailing block comments.Alexander Kornienko2014-04-171-0/+24
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch ensures that the lines of the block comments retain relative column offsets. In order to do this WhitespaceManager::Changes representing continuation of block comments keep a pointer on the change representing the whitespace change before the block comment, and a relative column offset to this change, so that the correct column can be reconstructed at the end of alignment process. Fixes http://llvm.org/PR19325 Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D3408 llvm-svn: 206472
* clang-format: Respect BinPackParameters in Cpp11BracedListStyle.Daniel Jasper2014-04-171-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly for Chromium): Before: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; After: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; This fixes llvm.org/PR19359. I am not sure we'll want this in all cases in the long run, but I'll guess we'll get feedback on that. llvm-svn: 206458
* clang-format: Add special case to reduce indentaiton in streams.Daniel Jasper2014-04-161-0/+12
| | | | | | | | | | | | | | | | This is similar to how we treat assignments and seems to be generally desirable. Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 206384
* Fix assertion when breaking string literals with tab characters.Alexander Kornienko2014-04-151-1/+11
| | | | | | | | | | | | | | Summary: Fixes http://llvm.org/PR19368 Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D3379 llvm-svn: 206295
* clang-format: Basic support for C++1y.Daniel Jasper2014-04-151-0/+4
| | | | | | | | | | | Before: int bi{1 '000' 000}; After: int bi{1'000'000}; This fixes llvm.org/PR19342. llvm-svn: 206263
* clang-format: Fix regression caused by r206165.Daniel Jasper2014-04-141-0/+10
| | | | llvm-svn: 206173
* clang-format: Fix incorrect &&-detection in macros.Daniel Jasper2014-04-141-0/+1
| | | | | | | | | | | | Before: #define A(a, b) (a &&b) After: #define A(a, b) (a && b) This fixes llvm.org/PR19343. llvm-svn: 206165
* clang-format: Improve array literal formatting fix in r206161.Daniel Jasper2014-04-141-6/+15
| | | | | | | Instead of choosing based on the number of elements, simply respect the user's choice of where to wrap array literals. llvm-svn: 206162
* clang-format: With ColumnLimit=0, keep short array literals on a line.Daniel Jasper2014-04-141-0/+14
| | | | | | | | | | | | | | | | Before: NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ] copyItems:YES]; After: NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ] copyItems:YES]; This fixed llvm.org/PR19080. llvm-svn: 206161
* clang-format: Don't allow hanging indentation for operators on new linesDaniel Jasper2014-04-141-2/+11
| | | | | | | | | | | | | | | | Before: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... After: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... The same rule has already be implemented for BreakBeforeBinaryOperators set to false in r205527. llvm-svn: 206159
* Format code around VCS conflict markers.Manuel Klimek2014-04-141-0/+92
| | | | | | | | | | | | | | | | | | | | | Now correctly formats: { int a; void f() { callme(some(parameter1, <<<<<<< text by the vcs parameter2), ||||||| text by the vcs parameter2), parameter3, ======= text by the vcs parameter2, parameter3), >>>>>>> text by the vcs otherparameter); } } llvm-svn: 206157
* clang-format: Improve formatting of annotated variables.Daniel Jasper2014-04-141-6/+7
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 206155
* clang-format: Treat a trailing comment like a trailing comma in braced lists.Daniel Jasper2014-04-091-3/+7
| | | | | | | | | | | | | | | | | Before: static StructInitInfo module = {MODULE_BUILTIN, /* type */ "streams" /* name */ }; After: static StructInitInfo module = { MODULE_BUILTIN, /* type */ "streams" /* name */ }; This fixes llvm.org/PR19378. llvm-svn: 205851
* clang-format: Fix bug where clang-format would break the code.Daniel Jasper2014-04-091-0/+3
| | | | | | | | | | | | Before, it would turn: SomeFunction([]() { // Cool function.. return 43; }); Into this: SomeFunction([]() { // Cool function.. return 43; }); llvm-svn: 205849
* clang-format: Improve format of calls with several lambdas.Daniel Jasper2014-04-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Before: SomeFunction([]() { int i = 42; return i; }, []() { int j = 43; return j; }); After: SomeFunction([]() { int i = 42; return i; }, []() { int j = 43; return j; }); llvm-svn: 205848
* clang-format: Allow breaking between trailing annotations in more cases.Daniel Jasper2014-04-091-0/+2
| | | | | | | | | | | | Before: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA( aaaaaaaaaaaaaaa); After: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa); llvm-svn: 205846
* clang-format: Keep more trailing annotations on the same line.Daniel Jasper2014-04-091-0/+6
| | | | | | | | | | | | | | | | | | | | More precisely keep all short annotations (<10 characters) on the same line if possible. Previously, clang-format would only prefer to do so for "const", "override" and "final". However, it seems to be generally preferable, especially because some codebases have to wrap those in macros for backwards compatibility. Before: void someLongFunction(int someLongParameter) OVERRIDE {} After: void someLongFunction( int someLongParameter) OVERRIDE {} This fixes llvm.org/PR19363. llvm-svn: 205845
* clang-format: Recognize lists ending in trailing commas correctly.Daniel Jasper2014-04-091-5/+6
| | | | | | | Previously, this did not look through trailing comments leading to a few formatting oddities. llvm-svn: 205843
* clang-format: Fix incorrect multi-block-parameter computation.Daniel Jasper2014-04-081-0/+6
| | | | llvm-svn: 205763
* clang-format: Correctly understand arrays of pointers.Daniel Jasper2014-04-081-0/+1
| | | | | | | | | | | | Before: A<int * []> a; After: A<int *[]> a; This fixes llvm.org/PR19360. llvm-svn: 205761
* clang-format: Extend AllowShortFunctions.. to only merge inline functions.Daniel Jasper2014-04-081-5/+30
| | | | | | | | | | | | | | | | | Before AllowShortFunctionsOnASingleLine could either be true, merging all functions, or false, merging no functions. This patch adds a third value "Inline", which can be used to only merge short functions defined inline in a class, i.e.: void f() { return 42; } class C { void f() { return 42; } }; llvm-svn: 205760
* clang-format: Don't merge simple blocks in case statements.Daniel Jasper2014-04-041-0/+3
| | | | | | | | | | | | | | | | Before: switch (a) { case 1: { return 'a'; } } After: switch (a) { case 1: { return 'a'; } } llvm-svn: 205611
* clang-format: Prefer an additional line-break over hanging indent.Daniel Jasper2014-04-031-2/+3
| | | | | | | | | | | | | | | | | | | | Don't allow the RHS of an operator to be split over multiple lines unless there is a line-break right after the operator. Before: if (aaaa && bbbbb || // break cccc) { } After: if (aaaa && bbbbb || // break cccc) { } In most cases, this seems to increase readability. llvm-svn: 205527
* clang-format: Understand that "auto" is a type.Daniel Jasper2014-04-031-0/+6
| | | | | | | | | | Before: MACRO(auto * a); After: MACRO(auto *a); llvm-svn: 205517
* Fixing the MSVC 2012 build bot, which cannot do initializer lists yet. ↵Aaron Ballman2014-04-011-2/+5
| | | | | | Amends r205307. llvm-svn: 205325
* clang-format: Support configurable list of foreach-macros.Daniel Jasper2014-04-011-0/+16
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* clang-format: Fix aligning of comments and escaped newlines in macros.Daniel Jasper2014-03-281-0/+5
| | | | | | | | | | | | | | Before: #define A \ int i; /*a*/ \ int jjj; /*b*/ After: #define A \ int i; /*a*/ \ int jjj; /*b*/ llvm-svn: 205011
* clang-format: Recognize more ObjC blocks with parameters/return type.Daniel Jasper2014-03-281-0/+4
| | | | llvm-svn: 204990
* Improve handling of bool expressions in template arguments.Manuel Klimek2014-03-271-0/+6
| | | | | | | Now correctly formats: foo<true && false>(); llvm-svn: 204950
* clang-format: Avoid line-breaks that increase the current column.Daniel Jasper2014-03-271-3/+2
| | | | | | | | | | | | | | | | | | While these might make sense for some rule (e.g. break after multi-line operand), they generally appear ugly and confusing. Before: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) After: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) llvm-svn: 204937
* Fix bool expression special case.Manuel Klimek2014-03-271-0/+8
| | | | | | | | Clang-format now correctly formats: some_type<a * b> v; template <bool a, bool b> typename enabled_if<a && b>::type f() {} llvm-svn: 204913
* clang-format: Correctly identify ObjC Block with return type.Daniel Jasper2014-03-271-0/+4
| | | | llvm-svn: 204905
* clang-format: Fix incorrect &/* detection.Daniel Jasper2014-03-251-0/+2
| | | | | | | | | | Before: STATIC_ASSERT((a &b) == 0); After: STATIC_ASSERT((a & b) == 0); llvm-svn: 204709
OpenPOWER on IntegriCloud