summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [js] Updates to Google's JavaScript style.Daniel Jasper2014-10-311-0/+1
| | | | | | The style guide is changing.. llvm-svn: 220977
* clang-format: [ObjC] Add separate flag to control indentation in blocksDaniel Jasper2014-10-281-2/+2
| | | | | | | | | | 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-0/+6
| | | | | | | | | | | | | | Before: void SomeFunction(int parameter); After: void SomeFunction( int parameter); (Unless AlwaysBreakAfterDefinitionReturnType after type is set). llvm-svn: 220686
* clang-format: [Proto] Change formatting text-formatted options.Daniel Jasper2014-10-271-2/+1
| | | | | | | | | | | | | | Before: optional Type type = 1 [(mutate_options) = {vital : true abc : false}]; After: optional Type type = 1 [(mutate_options) = { vital : true abc : false }]; llvm-svn: 220679
* clang-format: [Java] Wrap after each function annotation.Daniel Jasper2014-10-211-1/+3
| | | | | | | | | | | Before: @Override public String toString() { .. } After: @Override public String toString() { .. } llvm-svn: 220274
* clang-format: Add option to control call argument bin-packing separatelyDaniel Jasper2014-10-091-5/+7
| | | | | | | 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-3/+4
| | | | | | | | | | | | | | Before: SomeFunction(a, a, // comment b + x); After: SomeFunction(a, a, // comment b + x); llvm-svn: 219209
* clang-format: [JS] Improve formatting of function literals in chainsDaniel Jasper2014-09-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before: getSomeLongPromise(.....) .then( function(value) { body(); body(); }) .thenCatch(function(error) { body(); body(); }); After: getSomeLongPromise(.....) .then(function(value) { body(); body(); }) .thenCatch(function(error) { body(); body(); }); llvm-svn: 218595
* clang-format: Undo r216377.Daniel Jasper2014-09-191-4/+3
| | | | | | It has proven to not be a food idea in many case. llvm-svn: 218107
* clang-format: Improve line breaks at function calls.Daniel Jasper2014-09-121-0/+12
| | | | | | | | | | | | | 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
* clang-format: [JS] Format embedded function literals more efficently.Daniel Jasper2014-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; After: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; llvm-svn: 217238
* clang-format: Improve formatting of nested builder-type calls.Daniel Jasper2014-08-251-3/+4
| | | | | | | | | | | | Before: f(FirstToken->WhitespaceRange.getBegin().getLocWithOffset( First->LastNewlineOffset)); After: f(FirstToken->WhitespaceRange.getBegin() .getLocWithOffset(First->LastNewlineOffset)); llvm-svn: 216377
* clang-format: Fix indentation in multi-line placement new.Daniel Jasper2014-08-061-0/+3
| | | | | | | | | | | | | | Before: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214964
* clang-format: [proto] Improve formatting of text-proto options.Daniel Jasper2014-07-281-1/+2
| | | | | | Initial patch and tests by Kaushik Sridharan, thank you! llvm-svn: 214084
* clang-format: Improve heuristic around avoiding bad line breaks.Daniel Jasper2014-07-151-1/+2
| | | | | | | | | | | Now, this can be properly formatted: static_cast<A< // B> *>( // ); Before, clang-format could end up, not formatting the code at all. llvm-svn: 213055
* clang-format: Add new option to indent wrapped function declarations.Daniel Jasper2014-07-091-2/+3
| | | | | | | | | Though not completely identical, make former IndentFunctionDeclarationAfterType change this flag for backwards compatibility (it is somewhat close in meaning and better the err'ing on an unknown config flag). llvm-svn: 212597
* clang-format: Revamp function declaration/definition indentation.Daniel Jasper2014-07-091-8/+7
| | | | | | | | | | | | | | Key changes: - Correctly (well ...) distinguish function declarations and variable declarations with ()-initialization. - Don't indent when breaking function declarations/definitions after the return type. - Indent variable declarations and typedefs when breaking after the type. This fixes llvm.org/PR17999. llvm-svn: 212591
* clang-format: [JS] Treat dict literals similar to objc method exprs.Daniel Jasper2014-06-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } } After: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } }; llvm-svn: 210537
* clang-format: Fix enum formatting with specific comment.Daniel Jasper2014-06-101-1/+3
| | | | | | | | | | | | | | | Before: enum Fruit { // APPLE, PEAR }; After: enum Fruit { // APPLE, PEAR }; llvm-svn: 210522
* 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
* clang-format: Leave empty lines within UnwrappedLines.Daniel Jasper2014-06-041-4/+2
| | | | | | | | 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-031-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 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-261-120/+151
| | | | | | No functional changes intended. llvm-svn: 209626
* 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: [JS] Support different function literal style.Daniel Jasper2014-05-211-2/+33
| | | | | | | | | | | | | | | | | Before: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); After: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); llvm-svn: 209291
* 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: Fix bug introduced by r208392.Daniel Jasper2014-05-091-8/+5
| | | | | | Also run clang-format over clang-format's files. llvm-svn: 208409
* [C++11] Use 'nullptr'.Craig Topper2014-05-091-3/+3
| | | | llvm-svn: 208392
* clang-format: Cleanup redundant calculation of ParenLevel.Daniel Jasper2014-05-081-18/+16
| | | | | | No functional changes intended. llvm-svn: 208304
* clang-format: Fix corner cases for comments in if conditions.Daniel Jasper2014-05-071-2/+3
| | | | | | | | | | | | Before: if ( // a x + 3) { .. After: if ( // a x + 3) { .. llvm-svn: 208175
* clang-format: Fix import statements with ColumnLimit: 0Daniel Jasper2014-05-051-1/+1
| | | | | | These used to interact badly with AlwaysBreakBeforeMultilineStrings. llvm-svn: 207955
* Fix typo (first commit to test commit access).Dinesh Dwivedi2014-05-011-1/+1
| | | | llvm-svn: 207775
* clang-format: Don't bin-pack text-proto-formatted options.Daniel Jasper2014-04-291-0/+1
| | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | | | | Before: void f() { return; } After: void f() { return; } llvm-svn: 207527
* [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
* clang-format: Respect BinPackParameters in Cpp11BracedListStyle.Daniel Jasper2014-04-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+4
| | | | | | | | | | | | | | | | 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-0/+6
| | | | | | | | | | | | | | 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: Understand proto text format without commas.Daniel Jasper2014-04-151-0/+3
| | | | | | | | | | | | | | | | Also removed spaces before colons as they don't seem to be used frequently. Before: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb : "baz"}]; After: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123, bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}]; llvm-svn: 206269
* clang-format: Improve array literal formatting fix in r206161.Daniel Jasper2014-04-141-1/+1
| | | | | | | 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/+1
| | | | | | | | | | | | | | | | 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-13/+25
| | | | | | | | | | | | | | | | 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
* clang-format: Improve format of calls with several lambdas.Daniel Jasper2014-04-091-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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: Extend AllowShortFunctions.. to only merge inline functions.Daniel Jasper2014-04-081-1/+1
| | | | | | | | | | | | | | | | | 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: Prefer an additional line-break over hanging indent.Daniel Jasper2014-04-031-0/+12
| | | | | | | | | | | | | | | | | | | | 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
* xDaniel Jasper2014-04-031-1/+1
| | | | llvm-svn: 205526
* clang-format: Solve issues found and fixed by clang-tidy.Daniel Jasper2014-03-311-1/+1
| | | | llvm-svn: 205193
* clang-format: Avoid line-breaks that increase the current column.Daniel Jasper2014-03-271-5/+9
| | | | | | | | | | | | | | | | | | 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
* clang-format: Extract getNewLineColumn out of addTokenOnNewLine.Daniel Jasper2014-03-271-74/+100
| | | | | | No functional changes intended. llvm-svn: 204930
OpenPOWER on IntegriCloud