summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Support ObjC selectors with unnamed parameters.Daniel Jasper2016-11-121-0/+5
| | | | | | This fixes llvm.org/PR28063. llvm-svn: 286715
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* clang-format: Don't indent lambda body relative to its return type.Daniel Jasper2016-06-131-5/+7
| | | | | | | | | | | | | | | | Before: []() // -> int { return 1; // }; After: []() // -> int { return 1; // }; llvm-svn: 272535
* clang-format: Fix incorrect calculation of "length" of /**/ comments.Daniel Jasper2016-06-081-3/+6
| | | | | | This could lead to column limit violations. llvm-svn: 272125
* clang-format: Fix segfault introduced by allowing wraps after comments.Daniel Jasper2016-05-291-1/+2
| | | | llvm-svn: 271191
* Addressed reviewer's post-submission comments from ↵Eric Liu2016-04-281-1/+1
| | | | | | | | | | | | | | http://reviews.llvm.org/D18551. Summary: Make SourceManager in Environment, WhitespaceManager, and FormatTokenAnalyzer etc constant members. Reviewers: djasper, klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19587 llvm-svn: 267859
* clang-format: [JS] generator and async functions.Martin Probst2016-04-241-1/+1
| | | | | | | | | | | | | | | For generators, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators async functions are not quite in the spec yet, but stage 3 and already widely used: http://tc39.github.io/ecmascript-asyncawait/ Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D19204 llvm-svn: 267368
* clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.Daniel Jasper2016-03-171-1/+11
| | | | | | | | | | | | | | | | | | If a call takes a single argument, using AlwaysBreak can lead to lots of wasted lines and additional indentation without improving the readability in a significant way. Before: caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); After: caaaaaaaaaaaall(caaaaaaaaaaaall(caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); llvm-svn: 263709
* clang-format: Correctly apply wrap before multi-line RHS rule toDaniel Jasper2016-03-011-1/+1
| | | | | | | | | | | | | | | ternary expressions. Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; llvm-svn: 262293
* clang-format: Make indentation after "<<" more consistent.Daniel Jasper2016-02-111-3/+9
| | | | | | | | | | | | | | | | | | | | | | Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; llvm-svn: 260517
* clang-format: Fix weird alignment when not aligning after brackets.Daniel Jasper2016-02-081-1/+2
| | | | | | | | | | | | | | | | Before: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); After: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); This fixes llvm.org/PR24905. llvm-svn: 260080
* clang-format: Fix corner case in template detection.Daniel Jasper2016-02-051-1/+1
| | | | | | | | | | Before: f(a.operator() < A > ()); After: f(a.operator()<A>()); llvm-svn: 259884
* clang-format: Fix formatting of ternary expressions with comments.Daniel Jasper2016-02-031-4/+8
| | | | | | | | | | | | | | Before: int i = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? /*bbbbbbbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb : ccccccccccccccccccccccccccc; After: int i = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? /*bbbbbbbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb : ccccccccccccccccccccccccccc; llvm-svn: 259670
* clang-format: Make AlignAfterOpenBracket also affect angle brackets.Daniel Jasper2016-02-021-1/+2
| | | | | | Patch by Matthew Whitehead, thank you. llvm-svn: 259487
* clang-format: Add option to disable string literal formatting.Daniel Jasper2016-02-011-1/+2
| | | | llvm-svn: 259352
* clang-format: [Java] Remove unnecessary line break after complex annotationsDaniel Jasper2016-01-271-0/+1
| | | | | | | | | | | | | | | Before: @Annotation("Some" + " text") List<Integer> list; After: @Annotation("Some" + " text") List<Integer> list; llvm-svn: 258981
* clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.Daniel Jasper2016-01-141-1/+1
| | | | | | | | | | | Before: aaaa[bbbb] .cccc(); After: aaaa[bbbb].cccc(); llvm-svn: 257763
* clang-format: [ObjC+JS] Allow bin-packing of array literals.Daniel Jasper2016-01-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After reading the style guides again, they don't actually say how to pack or not pack array literals. Based on some user reports, array initializers can unnecessarily get quite long if they contain many small elements. Array literals with trailing commas are still formatted one per line so that users have a way to opt out of the packing. Before: var array = [ aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa ]; After: var array = [ aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa ]; llvm-svn: 257615
* clang-format: Slightly row back on r257257.Daniel Jasper2016-01-111-1/+5
| | | | | | | | | | | | | | | | | | | | | r257257 change the way clang-format enforces line breaks after a templated type has been line-wrapped. This was to fix an incorrect line break if BinPackParameters is set to false. However, it also leads to an unwanted line break in a different case. Thus, for now, only do this when BinPackParameters is false. This isn't ideal yet, but helps us until we have a better solution. With BinPackParameters: Before: void fffffffffff(aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaa> aaaaaaaaaa); After: void fffffffffff( aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaa> aaaaaaaaaa); llvm-svn: 257325
* clang-format: [JS] Improve line-flow when calling functions on array literals.Daniel Jasper2016-01-111-4/+6
| | | | | | | | | | | | | | | | | | | Before: return [ aaaaaaaaaaaaaaaaaaaaaa ].aaaaaaa(function() { // }) .bbbbbb(); After: return [aaaaaaaaaaaaaaaaaaaaaa] .aaaaaaa(function() { // }) .bbbbbb(); llvm-svn: 257324
* clang-format: Fix incorrect line break in certain configurations.Daniel Jasper2016-01-091-1/+2
| | | | | | | | | | | | | Before: void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, vector<int> bbbbbbbbbbbbbbb); After: void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, vector<int> bbbbbbbbbbbbbbb); llvm-svn: 257257
* clang-format: Support definitions/declarations of operator,.Daniel Jasper2016-01-091-1/+2
| | | | | | | | | | Before: bool operator, (); After: bool operator,(); llvm-svn: 257256
* clang-format: Fix corner case in one-per-line formatting.Daniel Jasper2016-01-071-1/+1
| | | | | | | | | | | | | | | | | | | Before (example is JS, but also applies to C++): return [ aaaa() .bbbbbbbb('A'), aaaa().bbbbbbbb('B'), aaaa().bbbbbbbb('C'), ]; After: return [ aaaa().bbbbbbbb('A'), aaaa().bbbbbbbb('B'), aaaa().bbbbbbbb('C'), ]; llvm-svn: 257079
* clang-format: Fix corner case in "if it saves columns"-calculation.Daniel Jasper2016-01-051-1/+1
| | | | | | | | | | | | | | | Before: aaaa .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256841
* clang-format: Handle \n the same way as std::endl with stream operator.Daniel Jasper2016-01-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang-format breaks multi-line streams after std::endl. It now also break for '\n', the suggested replacement for std::endl: http://llvm.org/docs/CodingStandards.html#avoid-std-endl Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb << '\n'; llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb << "bbbbbbbbbbbbbbbbbb\n"; After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb << '\n'; llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb << "bbbbbbbbbbbbbbbbbb\n"; This changeset ensure that multiline streams have a line break after: - std::endl - '\n' - "\n" - "Some Text\n" Patch by Jean-Philippe Dufraigne, thank you. llvm-svn: 256832
* clang-format: Avoid creating hanging indents in call sequences.Daniel Jasper2016-01-051-0/+10
| | | | | | | | | | | | | | Before: aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaa) .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaaaaaaaaaaaa .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa) .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256831
* clang-format: Improve line wrapping behavior in call sequences.Daniel Jasper2016-01-051-2/+2
| | | | | | | | | | | | | | | r256750 has been leading to an undesired behavior: aaaaaaaaaa .aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); This change increases penalty for wrapping before member accesses that aren't calls. Thus, this is again formatted as (as it has been before r256750): aaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256830
* clang-format: Fix corner-case in ObjC method declaration formattingDaniel Jasper2016-01-041-7/+7
| | | | | | | | | | | | | | | | | | Before: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } After: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } llvm-svn: 256738
* clang-format: [Proto] Improve wrapping of message field attributes.Daniel Jasper2016-01-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Before: optional AAA aaa = 1 [foo = { key: "a" // }, bar = { key: "a" // }]; After: optional AAA aaa = 1 [ foo = { key: "a" // }, bar = { key: "a" // } ]; llvm-svn: 256736
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-181-4/+4
| | | | | | | | | | | This changes the behavior of AlwaysBreakAfterDeclarationReturnType so that it supports breaking after declarations, definitions, or both. Differential Revision: http://reviews.llvm.org/D10370 Reviewed By: Daniel Jasper llvm-svn: 256046
* clang-format: Make it possible to turn off comment reflowing.Daniel Jasper2015-12-011-2/+4
| | | | llvm-svn: 254414
* clang-format: If the template list of a variable declaration spansDaniel Jasper2015-11-231-0/+1
| | | | | | | | | | | | | | | multiple lines, also break before the variable name. Before: std::vector<aaaaaa, // wrap aa> aaa; After: std::vector<aaaaaa, // wrap aa> aaa; llvm-svn: 253871
* clang-format: Undo unwanted format change done in r251405.Daniel Jasper2015-10-271-11/+13
| | | | | | | | Specifically, don't wrap between the {} of an empty constructor if the "}" falls on column 81 and ConstructorInitializerAllOnOneLineOrOnePerLine is set. llvm-svn: 251406
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-271-8/+21
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
* clang-format: Don't let a leading "template <..>" lead to wrapped initializers.Daniel Jasper2015-08-271-0/+3
| | | | | | | | | | | | | | | | | Before: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} After: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} llvm-svn: 246146
* clang-format: Be more conservative about specially indenting blocks in C++.Daniel Jasper2015-08-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | This is a bit of a step back of what we did in r222531, as there are some corner cases in C++, where this kind of formatting is really bad. Example: Before: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); After: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); The block formatting logic in JavaScript will probably go some other changes, too, and we'll potentially be able to make the rules more consistent again. For now, this seems to be the best approach for C++. llvm-svn: 245694
* clang-format: Respect IndentWrappedFunctionNames when aligning colonsDaniel Jasper2015-07-161-1/+6
| | | | | | | | | | | | | | | | Before: - (void)shortf:(GTMFoo *)theFoo dontAlignNamef:(NSRect)theRect { } After: - (void)shortf:(GTMFoo *)theFoo dontAlignNamef:(NSRect)theRect { } Patch by Kwasi Mensah, thank you! llvm-svn: 242484
* clang-format: Fix return type breaking with overloaded operator functionsBirunthan Mohanathas2015-07-151-1/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D11177 llvm-svn: 242316
* clang-format: Fix formatting of multiple lambdas in initializers.Daniel Jasper2015-07-141-2/+4
| | | | | | | | | | | | | | | | | | | | Before: SomeFunction({[&] { // comment }, [&] { // comment }}); After: SomeFunction({[&] { // comment }, [&] { // comment }}); llvm-svn: 242138
* clang-format: [JS] Prevent confusing TypeScript parameters wraps.Daniel Jasper2015-07-061-1/+1
| | | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} After: aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} llvm-svn: 241444
* clang-format: Add option to break after definition return type for top-level ↵Birunthan Mohanathas2015-06-291-1/+2
| | | | | | | | functions only Differential Revision: http://reviews.llvm.org/D10774 llvm-svn: 240959
* clang-format: Don't indent relative to unary operators (some more).Daniel Jasper2015-06-291-1/+1
| | | | | | | | | | | | | | | | Before: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); After: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); llvm-svn: 240934
* clang-format: Make exception to AlwaysBreakBeforeMultilineStrings moreDaniel Jasper2015-06-191-1/+1
| | | | | | | | | | | | | | | | | | conservative. In particular, this fixes an unwanted corner case. Before: string s = someFunction("aaaa" "bbbb"); After: string s = someFunction( "aaaa" "bbbb"); llvm-svn: 240129
* clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change.Daniel Jasper2015-06-181-1/+2
| | | | | | | | | | | | | | | It was a bit too aggressive. With this patch, we keep on breaking here: aaaaaaaaaaaaa(aaaaaaa, "aaaaaaa" "bbbbbbb"); But don't break in: aaaaaaaaaaaaa(aaaaaaa, aaaaaaaa("aaaaaaa" "bbbbbbb")); llvm-svn: 240024
* clang-format: [JS] Add a special case for indenting function literals.Daniel Jasper2015-06-181-1/+15
| | | | | | | | | | | | | | | | | | | | Before: var func = function() { doSomething(); }; After: var func = function() { doSomething(); }; This is a very narrow special case which fixes most of the discrepency with what our users do. In the long run, we should try to come up with a more generic fix for indenting these. llvm-svn: 240014
* clang-format: Make AlwaysBreakBeforeMultilineStrings more conservative.Daniel Jasper2015-06-181-7/+9
| | | | | | | | | | | | | | | | | In essence this is meant to consistently indent multiline strings by a fixed amount of spaces from the start of the line. Don't do this in cases where it wouldn't help anyway. Before: someFunction(aaaaa, "aaaaa" "bbbbb"); After: someFunction(aaaaa, "aaaaa" "bbbbb"); llvm-svn: 240004
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-2/+2
| | | | llvm-svn: 239903
* clang-format: [JS] Tweak behavior for multiline array initializer parametersDaniel Jasper2015-06-151-1/+2
| | | | | | | | | | | | | | | | | | | | | Before: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); After: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); llvm-svn: 239722
* clang-format: More eagerly wrap trailing return types.Daniel Jasper2015-06-051-1/+1
| | | | | | | | | | | | | | | | | Before: template <typename T> auto aaaaaaaaaaaaaaaaaaaaaa(T t) -> decltype(eaaaaaaaaaaaaaaa<T>(t.a) .aaaaaaaa()); After: template <typename T> auto aaaaaaaaaaaaaaaaaaaaaa(T t) -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa()); Also add a test case for a difficult template parsing case I stumbled accross. Needs fixing. llvm-svn: 239149
* clang-format: Properly reset BreakBeforeParameter when wrappingDaniel Jasper2015-06-031-0/+2
| | | | | | | | | | | | | | | | | operators to the new line. Before: LOG_IF(aaa == // bbb) << a << b; After: LOG_IF(aaa == // bbb) << a << b; llvm-svn: 238911
OpenPOWER on IntegriCloud