summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: [js] Updates to Google's JavaScript style.Daniel Jasper2014-10-311-2/+2
| | | | | | The style guide is changing.. llvm-svn: 220977
* clang-format: Format line if invoked on the trailing newline.Daniel Jasper2014-10-291-1/+13
| | | | llvm-svn: 220883
* clang-format: Improve && detection as binary operator.Daniel Jasper2014-10-281-1/+8
| | | | | | | | | | | | | | | | Before: template <class T, class = typename ::std::enable_if< ::std::is_array<T>{}&& ::std::is_array<T>{}>::type> void F(); After: template <class T, class = typename ::std::enable_if< ::std::is_array<T>{} && ::std::is_array<T>{}>::type> void F(); llvm-svn: 220813
* clang-format: Fix test.Daniel Jasper2014-10-281-1/+1
| | | | llvm-svn: 220807
* clang-format: Improve && detection as binary operators.Daniel Jasper2014-10-281-0/+5
| | | | | | | | | | | | | | | Before: template <class T, class = typename std::enable_if<std::is_integral< T>::value &&(sizeof(T) > 1 || sizeof(T) < 8)>::type> void F(); After: template <class T, class = typename std::enable_if< std::is_integral<T>::value && (sizeof(T) > 1 || sizeof(T) < 8)>::type> void F(); llvm-svn: 220805
* clang-format: Improve function declaration detection.Daniel Jasper2014-10-281-0/+2
| | | | | | | | | | | | | | | | | Before: ReturnType MACRO FunctionName() {} After: ReturnType MACRO FunctionName() {} This fixes llvm.org/PR21404. I wonder what the motivation for that if-condition was. But as no test breaks, ... llvm-svn: 220801
* clang-format: [ObjC] Add separate flag to control indentation in blocksDaniel Jasper2014-10-281-37/+45
| | | | | | | | | | Apparently, people are very much divided on what the "correct" indentation is. So, best to give them a choice. The new flag is called ObjCBlockIndentWidth and the default is now set to the same value as IndentWidth for the pre-defined styles. llvm-svn: 220784
* clang-format: Don't break after very short return types.Daniel Jasper2014-10-271-10/+10
| | | | | | | | | | | | | | Before: void SomeFunction(int parameter); After: void SomeFunction( int parameter); (Unless AlwaysBreakAfterDefinitionReturnType after type is set). llvm-svn: 220686
* clang-format: Fix bad merging of lines in nested blocks.Daniel Jasper2014-10-271-0/+8
| | | | | | | | | | | | | | | Before: SomeFunction([]() { #define A a return 43; }); After: SomeFunction([]() { #define A a return 43; }); llvm-svn: 220684
* clang-format: Fix incorrect space after "<".Daniel Jasper2014-10-231-0/+1
| | | | | | | | | | Before: bool a = 2 <::SomeFunction(); After: bool a = 2 < ::SomeFunction(); llvm-svn: 220505
* clang-format: Use AllowShortBlocksOnASingleLine for ObjC blocks, too.Daniel Jasper2014-10-221-17/+28
| | | | llvm-svn: 220375
* clang-format: Fix broken test.Daniel Jasper2014-10-221-1/+1
| | | | llvm-svn: 220374
* clang-format: Fix incorrect trailing return arrow detection.Daniel Jasper2014-10-221-0/+1
| | | | | | | | | | Before: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {} After: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {} llvm-svn: 220373
* clang-format: [ObjC] Fix spacing in block variable parameters.Daniel Jasper2014-10-211-0/+1
| | | | | | | | | | Before: { void (^block)(Object * x); } After: { void (^block)(Object *x); } llvm-svn: 220270
* clang-format: Fix space in direct destructor calls.Daniel Jasper2014-10-211-0/+5
| | | | | | | | | | | | Before: void F(int& i) { i. ~int(); } After: void F(int& i) { i.~int(); } Also, some cleanups. llvm-svn: 220269
* clang-format: Fix overloaded operator edge case.Daniel Jasper2014-10-201-0/+1
| | | | | | | | | | | | | | | | Before: template <class F> void Call(F f) { f.template operator() <int>(); } After: template <class F> void Call(F f) { f.template operator()<int>(); } llvm-svn: 220202
* clang-format: [ObjC] Fix using selector names as macro arguments.Daniel Jasper2014-10-201-0/+1
| | | | | | | | | | Before: [self aaaaa:MACRO(a, b :, c :)]; After: [self aaaaa:MACRO(a, b:, c:)]; llvm-svn: 220197
* clang-format: Fix indentation of struct definitions with array init.Daniel Jasper2014-10-201-0/+10
| | | | | | | | | | | | | | | | | | | | Before: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; After: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; llvm-svn: 220195
* clang-format: Prefer breaking before trailing return arrows.Daniel Jasper2014-10-171-0/+2
| | | | | | | | | | | | Before: auto SomeFunction( A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} After: auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} llvm-svn: 220043
* clang-format: Fix behavior with comments before conditional expressionsDaniel Jasper2014-10-161-0/+6
| | | | | | | | | | | | | | | Before: SomeFunction(aaaaaaaaaaaaaaaaa, // comment. ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa : bbbbbbbbbbbbbbbbbbbb); After: SomeFunction(aaaaaaaaaaaaaaaaa, // comment. ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa : bbbbbbbbbbbbbbbbbbbb); llvm-svn: 219921
* clang-format: [ObjC] Fix method expression detection.Daniel Jasper2014-10-161-3/+2
| | | | | | | | | | Before: return (a)[foo bar : baz]; After: return (a)[foo bar:baz]; llvm-svn: 219919
* clang-format: [ObjC] Wrap ObjC method declarations before annotations.Daniel Jasper2014-10-111-0/+4
| | | | | | | | | | | | | Before: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>) y NS_DESIGNATED_INITIALIZER; After: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>)y NS_DESIGNATED_INITIALIZER; llvm-svn: 219564
* clang-format: Add option to control call argument bin-packing separatelyDaniel Jasper2014-10-091-12/+28
| | | | | | | This is desirable for the Chromium style guide: http://www.chromium.org/developers/coding-style llvm-svn: 219400
* clang-format: Fix bug with comments between non-trival parameters.Daniel Jasper2014-10-071-0/+6
| | | | | | | | | | | | | | Before: SomeFunction(a, a, // comment b + x); After: SomeFunction(a, a, // comment b + x); llvm-svn: 219209
* clang-format: If in doubt, assume '+' is a binary operator.Daniel Jasper2014-10-061-1/+2
| | | | | | | | | | Before: #define LENGTH(x, y) (x) - (y)+1 After: #define LENGTH(x, y) (x) - (y) + 1 llvm-svn: 219119
* clang-format: Fix GCC warning about implicit bool pointer conversion.Daniel Jasper2014-09-291-6/+6
| | | | | | Introduced in r217880. llvm-svn: 218597
* clang-format: Don't let -style=Chromium imply c++03 template formatting.Nico Weber2014-09-241-0/+2
| | | | | | | Chromium's now using some c++11 language features, so it's now fine that clang-format produces vector<vector<int>>. llvm-svn: 218392
* clang-format: Prevent column layout if elements aren't uniform enough.Daniel Jasper2014-09-191-9/+5
| | | | | | | | | | | | | | | | | | | | | | | This patch only considers the difference between the length of the shortest and longest element, but we might want to look at other features (token count, etc.) in future. Before: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a}; After: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a}; llvm-svn: 218111
* clang-format: Undo r216377.Daniel Jasper2014-09-191-4/+1
| | | | | | It has proven to not be a food idea in many case. llvm-svn: 218107
* clang-format: Allow unbroken ::: in inline assembly.Daniel Jasper2014-09-161-0/+1
| | | | | | | | | | | | Before: asm volatile("nop" :: : "memory"); After: asm volatile("nop" ::: "memory"); Patch by Eugene Toder. Thank you. llvm-svn: 217883
* clang-format: Restructure and add missing tests.Daniel Jasper2014-09-161-15/+31
| | | | | | Patch by Jean-Philippe Dufraigne, Thank you! llvm-svn: 217880
* clang-format: Add option to break before non-assignment operators.Daniel Jasper2014-09-151-5/+28
| | | | | | | | | This will allow: int aaaaaaaaaaaaaa = bbbbbbbbbbbbbb + ccccccccccccccc; llvm-svn: 217757
* clang-format: Improve line breaks at function calls.Daniel Jasper2014-09-121-0/+5
| | | | | | | | | | | | | Before: EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly( Return(SomeValue)); After: EXPECT_CALL(SomeObject, SomeFunction(Parameter)) .Times(2) .WillRepeatedly(Return(SomeValue)); llvm-svn: 217687
* Fix bug 20892 - clang-format does not handle C-style commentsRoman Kashitsyn2014-09-111-0/+10
| | | | | | | | | | | | | | | | | | | | | | Summary: http://llvm.org/bugs/show_bug.cgi?id=20892 Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported: // clang-format on /* clang-format on */ The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, curdeius, klimek Differential Revision: http://reviews.llvm.org/D5309 llvm-svn: 217588
* clang-format: Add option to allow short case labels on a single line.Daniel Jasper2014-09-101-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | On a single line: switch (a) { case 1: x = 1; return; case 2: x = 2; return; default: break; } Not on a single line: switch (a) { case 1: x = 1; return; case 2: x = 2; return; default: break; } This partly addresses llvm.org/PR16535. In the long run, we probably want to lay these out in columns. llvm-svn: 217501
* clang-format: Add an option 'SpaceAfterCStyleCast'.Daniel Jasper2014-09-031-0/+33
| | | | | | | | | | | | | | | | | This permits to add a space after closing parenthesis of a C-style cast. Defaults to false to preserve old behavior. Fixes llvm.org/PR19982. Before: (int)i; After: (int) i; Patch by Marek Kurdej. llvm-svn: 217022
* clang-format: Fix unary operator detection in corner case.Daniel Jasper2014-08-291-0/+1
| | | | | | | | | | Before: decltype(* ::std::declval<const T &>()) void F(); After: decltype(*::std::declval<const T &>()) void F(); llvm-svn: 216724
* clang-format: Fix regression in formatting of braced initializers.Daniel Jasper2014-08-271-0/+2
| | | | | | | | | | | | Before: Node n{1, Node{1000}, // 2}; After: Node n{1, Node{1000}, // 2}; llvm-svn: 216540
* clang-format: Don't butcher __asm blocks.Daniel Jasper2014-08-261-0/+15
| | | | | | | | Instead completely cop out of formatting them for now. This fixes llvm.org/PR20618. llvm-svn: 216501
* clang-format: New option SpacesInSquareBrackets.Daniel Jasper2014-08-261-0/+23
| | | | | | | | | | | | | | | | Before: int a[5]; a[3] += 42; After: int a[ 5 ]; a[ 3 ] += 42; Fixes LLVM bug #17887 (http://llvm.org/bugs/show_bug.cgi?id=17887). Patch by Marek Kurdej, thank you! llvm-svn: 216449
* clang-format: Improve handling of block comments in braced lists.Daniel Jasper2014-08-261-8/+5
| | | | | | | | | | | | Before: std::vector<int> v = { 1, 0 /* comment */ }; After: std::vector<int> v = {1, 0 /* comment */}; llvm-svn: 216445
* clang-format: Understand sequenced casts.Daniel Jasper2014-08-251-0/+1
| | | | | | | | | | | | This fixed llvm.org/PR20712. Before: int i = (int)(int) -2; After: int i = (int)(int)-2; llvm-svn: 216378
* clang-format: Improve formatting of nested builder-type calls.Daniel Jasper2014-08-251-1/+4
| | | | | | | | | | | | Before: f(FirstToken->WhitespaceRange.getBegin().getLocWithOffset( First->LastNewlineOffset)); After: f(FirstToken->WhitespaceRange.getBegin() .getLocWithOffset(First->LastNewlineOffset)); llvm-svn: 216377
* clang-format: Prefer breaking after return type over template paramDaniel Jasper2014-08-151-0/+4
| | | | | | | | | | | | | | Before: typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa< aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} After: typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} llvm-svn: 215693
* Split a large unit-test, so that it doesn't exceed stack frame size in ↵Alexander Kornienko2014-08-141-7/+12
| | | | | | certain test environments llvm-svn: 215639
* clang-format: Fix AlwaysBreakAfterDefinitionReturnType in Stroutrup styleDaniel Jasper2014-08-141-0/+23
| | | | | | | | | | | | | | | | | | | | | Before: template <class T> T *f(T &c) // Problem here: no line break before f { return NULL; } After: template <class T> T * f(T &c) { return NULL; } Patch by Marek Kurdej, thank you! llvm-svn: 215633
* clang-format: Support chained dereferenced assignments.Daniel Jasper2014-08-141-0/+4
| | | | | | | | | | Before: x = * a(x) = *a(y); After: x = *a(x) = *a(y); llvm-svn: 215632
* clang-format: Support breaking arguments of function type typedefs.Daniel Jasper2014-08-141-0/+4
| | | | | | | | | | | | | Before: typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)( const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)( const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 215631
* Fix crasher bug in clang-format.Manuel Klimek2014-08-131-0/+4
| | | | llvm-svn: 215549
* clang-format: Format long lists in columns if without bin-packing.Daniel Jasper2014-08-131-0/+7
| | | | | | | | | | | | | | | | After (even with BinPacking = false): const Aaaaaa aaaaa = { aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk, aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk, }; Before: <each element on its own line> This fixes http://llvm.org/PR20623. llvm-svn: 215529
OpenPOWER on IntegriCloud