summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* There is no std::errc:success, remove the llvm one.Rafael Espindola2014-05-311-14/+13
| | | | llvm-svn: 209959
* clang-format: Don't break before a case's colon.Daniel Jasper2014-05-281-0/+7
| | | | | | | | | | | | | | | | | | Before (with just the right line length: switch (a) { case some_namespace::some_constant : return; } After: switch (a) { case some_namespace:: some_constant: return; } llvm-svn: 209725
* clang-format: Format array and dict literals similar to blocks.Daniel Jasper2014-05-281-3/+11
| | | | | | | | | | | | | | | | | | | | | | | Especially, reduce the amount of indentation if it doesn't increase readability. Before: NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithDictionary:@{ aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb : bbbbb, cccccccccccccccc : ccccccccccccccc }]; After: NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithDictionary:@{ aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb : bbbbb, cccccccccccccccc : ccccccccccccccc }]; llvm-svn: 209720
* clang-format: Keep '{' of dict literals on the same line in Allman styleDaniel Jasper2014-05-261-3/+11
| | | | | | | | | | | | | | | | | | | | Before: void f() { [object someMethod:@ { @"a" : @"b" }]; } After: void f() { [object someMethod:@{ @"a" : @"b" }]; } This fixes llvm.org/PR19854. llvm-svn: 209615
* clang-format: Don't use Allman brace breaking for ObjC blocks.Daniel Jasper2014-05-221-0/+10
| | | | | | It just seems wrong. This fixes llvm.org/PR19736. llvm-svn: 209440
* clang-format: Fix corner case in AllowShortBlocksOnASingleLine.Daniel Jasper2014-05-221-0/+5
| | | | | | | | | | | | | | | | Before: template <int> struct A4 { A4() { } }; After: template <int i> struct A4 { A4() {} }; This fixes llvm.org/PR19813 (at least the part that isn't working as intended). llvm-svn: 209438
* clang-format: Fix braced list detection.Daniel Jasper2014-05-221-4/+10
| | | | | | | | | | | | | Before: static_assert(std::is_integral<int> {} + 0, ""); int a = std::is_integral<int> {} + 0; After: static_assert(std::is_integral<int>{} + 0, ""); int a = std::is_integral<int>{} + 0; llvm-svn: 209431
* clang-format: Fix incorrect braced init identification.Daniel Jasper2014-05-221-0/+3
| | | | | | | | | | | | | | | | | | | | Before: int foo(int i) { return fo1 {} (i); } int foo(int i) { return fo1 {} (i); } After: int foo(int i) { return fo1{}(i); } int foo(int i) { return fo1{}(i); } This fixes llvm.org/PR19812. llvm-svn: 209428
* clang-format: [JS] Understand line breaks in concatenated strings.Daniel Jasper2014-05-221-0/+5
| | | | | | | | | | | | | | Before: var literal = 'hello ' + 'world'; After: var literal = 'hello ' + 'world'; There is no reason to concatenated two string literals with a '+' unless the line break is intended. llvm-svn: 209413
* clang-format: Correctly identify multiplications in braces init lists.Daniel Jasper2014-05-221-3/+2
| | | | | | | | | | | | | Before: int i{a *b}; After: int i{a * b}; Also fix unrelated issue where braced init lists were counted as blocks and prevented single-line functions. llvm-svn: 209412
* clang-format: Correctly calculate line lenghts for nest blocks.Daniel Jasper2014-05-222-16/+13
| | | | | | | | | | | | | | | If simple (one-statement) blocks can be inlined, the length needs to be calculated correctly. Before (in JavaScript but this also affects lambdas, etc.): var x = { valueOf: function() { return 1; } }; After: var x = {valueOf: function() { return 1; }}; llvm-svn: 209410
* clang-format: Fix corner case working around one-per-line dict literals.Daniel Jasper2014-05-211-0/+5
| | | | | | | | | | | | | | | Before: var object_literal_with_long_name = { a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb' }; After: var object_literal_with_long_name = { a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb' }; llvm-svn: 209296
* clang-format: Fix incorrect macro call detection.Daniel Jasper2014-05-211-0/+2
| | | | | | | | | | | | | In: struct A { A() noexcept(....) {} }; 'A()' is not a macro call. This fixes llvm.org/PR19814. llvm-svn: 209294
* clang-format: [JS] Support different function literal style.Daniel Jasper2014-05-211-0/+12
| | | | | | | | | | | | | | | | | Before: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); After: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); llvm-svn: 209291
* clang-format: [JS] Understand top-level function literals properly.Daniel Jasper2014-05-201-1/+5
| | | | llvm-svn: 209205
* clang-format: Don't force line breaks in ObjC calls with ColumnLimit 0.Daniel Jasper2014-05-191-8/+21
| | | | | | | | | | | Before: [self.x a:b c:d]; Got reformatted toi (with ColumnLimit set to 0): [self.x a:b c:d]; llvm-svn: 209114
* clang-format: [JS] Support ES6 destructuring assignments.Daniel Jasper2014-05-191-0/+5
| | | | | | | | | | Before: var[a, b, c] = [1, 2, 3]; After: var [a, b, c] = [1, 2, 3]; llvm-svn: 209113
* clang-format: [JS] Support for EC6 arrow functions.Daniel Jasper2014-05-191-0/+2
| | | | | | | | | | Before: var b = a.map((x) = > x + 1); After: var b = a.map((x) => x + 1); llvm-svn: 209112
* clang-format: Add option to allow short blocks on a single line.Daniel Jasper2014-05-141-0/+41
| | | | | | | | | With AllowShortBlocksOnASingleLine, clang-format allows: if (a) { return; } Based on patch by Gonzalo BG, thank you! llvm-svn: 208765
* clang-format: Don't break in the middle of ">>".Daniel Jasper2014-05-131-0/+6
| | | | | | | | | | | | | | | Before: zzzzzzzzzz = bbbbbbbbbbbbbbbbb > > aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa); After: zzzzzzzzzz = bbbbbbbbbbbbbbbbb >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa); This fixes llvm.org/PR19731. llvm-svn: 208672
* clang-format: [JS] Basic support for escape sequences in regex literals.Daniel Jasper2014-05-121-0/+3
| | | | | | | | | | Before: var regex = /\\/ g; // This isn't even recognized as regex. After: var regex = /\\/g; // It now is. llvm-svn: 208539
* clang-format: [JS] Fix spacing in dict literals.Daniel Jasper2014-05-091-0/+1
| | | | | | | | | | Before: someVariable = {'a':[{}]}; After: someVariable = {'a': [{}]}; llvm-svn: 208403
* clang-format: Initial support for try-catch.Daniel Jasper2014-05-082-16/+72
| | | | | | | | | | Most of this patch was created by Alexander Rojas in http://reviews.llvm.org/D2555 Thank you! Synced and addressed review comments. llvm-svn: 208302
* clang-format: [JS] support closures in container literals.Daniel Jasper2014-05-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Before: return {body: {setAttribute: function(key, val) {this[key] = val; } , getAttribute : function(key) { return this[key]; } , style : { direction: '' } } } ; After: return { body: { setAttribute: function(key, val) { this[key] = val; }, getAttribute: function(key) { return this[key]; }, style: {direction: ''} } }; llvm-svn: 208292
* 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
* clang-format: [JS] Support regex literals after 'return'.Daniel Jasper2014-05-081-0/+2
| | | | llvm-svn: 208285
* clang-format: [JS] Initial support for regex literals.Daniel Jasper2014-05-081-0/+70
| | | | llvm-svn: 208281
* Enable alternative tokens by default for clang-format.Nikola Smiljanic2014-05-082-2/+47
| | | | | | Patch by Bobby Moretti. llvm-svn: 208269
* clang-format: Be slightly more aggressive on single-line functions.Daniel Jasper2014-05-071-0/+5
| | | | | | | | | | | | | | So that JS functions can also be merged into a single line. Before: var func = function() { return 1; }; After: var func = function() { return 1; }; llvm-svn: 208176
* 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
* clang-format: [JS] Keep space after closure style comments.Daniel Jasper2014-05-061-0/+4
| | | | | | | | | | Before: var x = /** @type {foo} */ (bar); After: var x = /** @type {foo} */(bar); llvm-svn: 208093
* clang-format: [JS] Keep space between 'return' and '['.Daniel Jasper2014-05-061-0/+4
| | | | llvm-svn: 208090
* clang-format: [JS] Don't indent in goog.scope blocks.Daniel Jasper2014-05-061-0/+7
| | | | | | | | | | | | | | | | Before: goog.scope(function() { var x = a.b; var y = c.d; }); // goog.scope After: goog.scope(function() { var x = a.b; var y = c.d; }); // goog.scope llvm-svn: 208088
* 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: Don't bin-pack text-proto-formatted options.Daniel Jasper2014-04-291-0/+4
| | | | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA, bbbbbbb: BBBB, bbbb: BBB}]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA, bbbbbbb: BBBB, bbbb: BBB}]; llvm-svn: 207538
* 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-223-6/+6
| | | | | | | | | | 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
OpenPOWER on IntegriCloud