summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Support variadic lambda captures.Daniel Jasper2014-06-101-0/+2
| | | | | | | | | | Before: return [ i, args... ]{}; After: return [i, args...] {}; llvm-svn: 210514
* clang-format: Handle multiline strings inside ternary expressions.Daniel Jasper2014-06-101-1/+2
| | | | | | | With AlwaysSplitBeforeMultilineStrings, clang-format would not find any valid solution. llvm-svn: 210513
* [C++11] Use 'nullptr'.Craig Topper2014-06-091-3/+4
| | | | llvm-svn: 210448
* clang-format: Fix incorrect indentation.Daniel Jasper2014-06-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Before (JavaScript example, but can extend to other languages): return { a: 'E', b: function() { return function() { f(); // This is wrong. }; } }; After: return { a: 'E', b: function() { return function() { f(); // This is better. }; } }; llvm-svn: 210334
* clang-format: Leave empty lines within UnwrappedLines.Daniel Jasper2014-06-042-4/+4
| | | | | | | | These are commonly used to structure things like enums or long braced lists. There doesn't seem to be a good reason to have the behavior in such structures be different from the behavior between statements. llvm-svn: 210183
* clang-format: Refactor indentation behavior for multiple nested blocks.Daniel Jasper2014-06-034-33/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a few oddities when formatting multiple nested JavaScript blocks, e.g.: Before: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); After: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); llvm-svn: 210097
* clang-format: Fix special case of binary operator detection.Daniel Jasper2014-06-021-0/+6
| | | | | | | | | | | | | | | | | There is a pattern where evaluation order is used as control flow. This patch special-cases a commonly occuring version of this pattern. Before: Aaaaa *aaa = nullptr; // ... aaa &&aaa->f(); After: Aaaaa *aaa = nullptr; // ... aaa && aaa->f(); llvm-svn: 210017
* clang-format: No space between ")" and braced init list.Daniel Jasper2014-06-021-1/+2
| | | | | | | | | | | | Before: auto j = decltype(i) {}; After: auto j = decltype(i){}; This fixes llvm.org/PR19892. llvm-svn: 210013
* clang-format: Fix Allman brace breaking of enums.Daniel Jasper2014-06-021-4/+9
| | | | | | | | | | | | | | | | | | Before: enum Side { LEFT, RIGHT }; After: enum Side { LEFT, RIGHT }; This fixes llvm.org/PR19911. llvm-svn: 210011
* clang-format: Fix trailing const (etc.) with Allman brace style.Daniel Jasper2014-06-021-2/+2
| | | | | | | | | | | | | | | | | | Before: void someLongFunction(int someLongParameter) const { } After: void someLongFunction( int someLongParameter) const { } This fixes llvm.org/PR19912. llvm-svn: 210010
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-1/+1
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209949
* clang-format: Don't break before a case's colon.Daniel Jasper2014-05-281-4/+5
| | | | | | | | | | | | | | | | | | 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-45/+59
| | | | | | | | | | | | | | | | | | | | | | | 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: Split up moveStateToNextToken.Daniel Jasper2014-05-262-120/+163
| | | | | | No functional changes intended. llvm-svn: 209626
* clang-format: Keep '{' of dict literals on the same line in Allman styleDaniel Jasper2014-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | Before: void f() { [object someMethod:@ { @"a" : @"b" }]; } After: void f() { [object someMethod:@{ @"a" : @"b" }]; } This fixes llvm.org/PR19854. llvm-svn: 209615
* Use error_code::success() instead of make_error_code(llvm::errc::success).Alexander Kornienko2014-05-221-1/+1
| | | | llvm-svn: 209477
* clang-format: Introduce DisableFormat that prevents formatting.Daniel Jasper2014-05-221-0/+16
| | | | | | | | | | | | | | | | | And "none" pseudo-style indicating that formatting should be not applied. (1) Using .clang-format with "DisableFormat: true" effectively prevents formatting for all files within the folder containing such .clang-format file. (2) Using -fallback-style=none together with -style=file prevents formatting when .clang-format is not found, which can be used in on-save callback. Patch by Adam Strzelecki. Thank you! llvm-svn: 209446
* clang-format: Don't use Allman brace breaking for ObjC blocks.Daniel Jasper2014-05-221-1/+2
| | | | | | It just seems wrong. This fixes llvm.org/PR19736. llvm-svn: 209440
* clang-format: Fix corner case in AllowShortBlocksOnASingleLine.Daniel Jasper2014-05-221-2/+1
| | | | | | | | | | | | | | | | 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-2/+6
| | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | | | | | | | | 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: Store pointers to seen formatting states.Daniel Jasper2014-05-221-2/+8
| | | | | | | | | | | As the memory ownership is handled by the SpecificBumpPtrAllocator anyway, there is no need to duplicate states when inserting them into the Seen-set. This leads to an improvement of ~10% on the benchmark formatting file. No functional changes intended. llvm-svn: 209422
* clang-format: [JS] Understand line breaks in concatenated strings.Daniel Jasper2014-05-221-0/+7
| | | | | | | | | | | | | | 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-222-1/+3
| | | | | | | | | | | | | 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-9/+17
| | | | | | | | | | | | | | | 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-2/+4
| | | | | | | | | | | | | | | 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-1/+3
| | | | | | | | | | | | | 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-213-5/+48
| | | | | | | | | | | | | | | | | 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-0/+4
| | | | llvm-svn: 209205
* clang-format: Don't force line breaks in ObjC calls with ColumnLimit 0.Daniel Jasper2014-05-191-1/+1
| | | | | | | | | | | 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/+3
| | | | | | | | | | 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/+3
| | | | | | | | | | Before: var b = a.map((x) = > x + 1); After: var b = a.map((x) => x + 1); llvm-svn: 209112
* Fix typosAlp Toker2014-05-151-1/+1
| | | | llvm-svn: 208838
* clang-format: Add option to allow short blocks on a single line.Daniel Jasper2014-05-141-10/+29
| | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | 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-1/+21
| | | | | | | | | | Before: var regex = /\\/ g; // This isn't even recognized as regex. After: var regex = /\\/g; // It now is. llvm-svn: 208539
* Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer2014-05-101-0/+1
| | | | | | | Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
* clang-format: Fix bug introduced by r208392.Daniel Jasper2014-05-099-89/+74
| | | | | | Also run clang-format over clang-format's files. llvm-svn: 208409
* clang-format: [JS] Allow up to 3 empty lines in Google's JS style.Daniel Jasper2014-05-091-1/+1
| | | | llvm-svn: 208404
* clang-format: [JS] Fix spacing in dict literals.Daniel Jasper2014-05-091-3/+6
| | | | | | | | | | Before: someVariable = {'a':[{}]}; After: someVariable = {'a': [{}]}; llvm-svn: 208403
* [C++11] Use 'nullptr'.Craig Topper2014-05-098-87/+88
| | | | llvm-svn: 208392
* clang-format: Cleanup redundant calculation of ParenLevel.Daniel Jasper2014-05-082-25/+18
| | | | | | No functional changes intended. llvm-svn: 208304
* clang-format: Initial support for try-catch.Daniel Jasper2014-05-082-0/+74
| | | | | | | | | | 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-082-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+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-5/+5
| | | | llvm-svn: 208285
* clang-format: [JS] Initial support for regex literals.Daniel Jasper2014-05-083-7/+44
| | | | llvm-svn: 208281
* Enable alternative tokens by default for clang-format.Nikola Smiljanic2014-05-081-0/+1
| | | | | | Patch by Bobby Moretti. llvm-svn: 208269
* clang-format: Be slightly more aggressive on single-line functions.Daniel Jasper2014-05-071-2/+6
| | | | | | | | | | | | | | 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-072-3/+4
| | | | | | | | | | | | Before: if ( // a x + 3) { .. After: if ( // a x + 3) { .. llvm-svn: 208175
OpenPOWER on IntegriCloud