summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Support function annotations in macros.Daniel Jasper2015-05-181-2/+9
| | | | | | | | | | | | Before: DEPRECATED("Use NewClass::NewFunction instead.") string OldFunction(const string &parameter) {} After: DEPRECATED("Use NewClass::NewFunction instead.") string OldFunction(const string &parameter) {} llvm-svn: 237562
* clang-format: Properly align ObjC string literals.Daniel Jasper2015-05-171-8/+9
| | | | | | | | | | | | | | | | | | | | | | Before: NSString s = @"a" "b" "c"; NSString s = @"a" @"b" @"c"; After: NSString s = @"a" "b" "c"; NSString s = @"a" @"b" @"c"; This fixes llvm.org/PR23536. llvm-svn: 237538
* clang-format: Improve nested block / lambda indentation when wrappingDaniel Jasper2015-05-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | before binary/ternary operators. Basically, it doesn't seem right to indent a nested block aligned to a binary or ternary operator. Before: int i = aaaaaa ? 1 // : [] { return 2; // }(); llvm::errs() << "number of twos is " << std::count_if(v.begin(), v.end(), [](int x) { return x == 2; // force break }); After: int i = aaaaaa ? 1 // : [] { return 2; // }(); llvm::errs() << "number of twos is " << std::count_if(v.begin(), v.end(), [](int x) { return x == 2; // force break }); llvm-svn: 237263
* clang-format: [ObjC] Make IndentWrappedFunctionNames work with ObjC functionsDaniel Jasper2015-05-131-2/+9
| | | | llvm-svn: 237241
* clang-format: Support aligning ObjC string literals.Daniel Jasper2015-05-111-2/+5
| | | | | | | | | | | | Before: NSString s = @"aaaa" @"bbbb"; After: NSString s = @"aaaa" @"bbbb"; llvm-svn: 237000
* clang-format: Improve wrapping of << operators.Daniel Jasper2015-05-101-8/+9
| | | | | | | | | | | | | | | | | Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; Also, cleanup and simplify the operator wrapping logic. llvm-svn: 236960
* clang-format: Improve r236597, Properly indent method calls without inputs.Daniel Jasper2015-05-071-2/+6
| | | | | | | | | | | | Before: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; llvm-svn: 236730
* clang-format: Fix bad wrapping of ObjC method exprs.Daniel Jasper2015-05-061-3/+3
| | | | | | | | | | | | | | | | | Before: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa: aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa:aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; Note that this might now violate the column limit and we probably need an alternative way of indenting these then. However, that is still strictly better than the messy formatting that clang-format did before. llvm-svn: 236598
* clang-format: Properly indent method calls without inputs.Daniel Jasper2015-05-061-2/+4
| | | | | | | | | | | | Before: [aaaaaaaaaaa aaaaaaa]; After: [aaaaaaaaaaa aaaaaaa]; llvm-svn: 236597
* clang-format: Force aligning different brackets relative to each other.Daniel Jasper2015-05-041-2/+14
| | | | | | | | | | | | Before: void SomeFunction(vector< // break int> v); After: void SomeFunction(vector< // break int> v); llvm-svn: 236412
* clang-format: Don't wrap after short first segments of builder calls.Daniel Jasper2015-04-241-1/+2
| | | | | | | | | | | | | | | Before: a() .aaaaa() .aaaaa() .aaaaa(); After: a().aaaaa() .aaaaa() .aaaaa(); llvm-svn: 235707
* clang-format: Support nested block formatting with ColumnLimit=0.Daniel Jasper2015-04-231-5/+19
| | | | llvm-svn: 235580
* clang-format: Improve nested block formatting.Daniel Jasper2015-04-071-1/+2
| | | | | | | | | | | | | | | | | | Before: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); After: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); llvm-svn: 234304
* clang-format: Indent relative to the ./-> and not the function name.Daniel Jasper2015-04-071-1/+1
| | | | | | | | | | | | | | | | | | Before: aaaaaaaaaaa // .aaaa( // bbbb) // This is different .. .aaaa( // cccc); // .. from this. After: aaaaaaaaaaa // .aaaa( // bbbb) // This is identical .. .aaaa( // cccc); // .. to this. llvm-svn: 234300
* clang-format: Force line break in trailing calls after multline exprs.Daniel Jasper2015-03-261-2/+3
| | | | | | | | | | | | | Before: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb).a(); After: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb) .a(); llvm-svn: 233304
* clang-format: [OBJC] Don't indent 8 spaces in method declarations.Daniel Jasper2015-03-121-7/+3
| | | | | | | | | | | | Before: - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: (SoooooooooooooooooooooomeType *)bbbbbbbbbb; After: - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: (SoooooooooooooooooooooomeType *)bbbbbbbbbb; llvm-svn: 232112
* clang-format: When putting */& next to types, also wrap before them.Daniel Jasper2015-03-121-1/+1
| | | | | | | | | | | | Before: LoooooooooooongType * loooooooooooongVariable; After: LoooooooooooongType *loooooooooooongVariable; llvm-svn: 232044
* clang-format: Slightly change indentation rules in for loops.Daniel Jasper2015-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | There was already a TODO to double-check whether the extra indenation makes sense. A slightly different case reveals that it is actively harmful: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } Here (and it is probably not a totally infrequent case, it just works out that "i < " is four spaces and so the four space extra indentation makes the operator precedence confusing. So, this will now instead be formatted as: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } llvm-svn: 231461
* clang-format: Make braced list formatting more consistent.Daniel Jasper2015-02-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | Before: Aaaa aaaaaaaaaaa{ { a, // +1 indent weird. b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; After: Aaaa aaaaaaaaaaa{ { a, // better!? b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; Interesting that this apparently was entirely untested :-(. llvm-svn: 230627
* clang-format: Don't force a break after "endl" if everything fits on one line.Daniel Jasper2015-02-171-0/+4
| | | | llvm-svn: 229486
* clang-format: Fix crasher.Daniel Jasper2015-02-171-1/+1
| | | | llvm-svn: 229485
* clang-format: Fix incorrect handling of leading whitespace.Daniel Jasper2015-01-311-6/+12
| | | | | | | Added an assertion that triggered in an existing test case (without observable differences) and fixed the code. llvm-svn: 227677
* clang-format: Fix AlwaysBreakBeforeMultilineStrings with ColumnLimit=0Daniel Jasper2015-01-201-2/+3
| | | | | | | | | | | | | | Before: const char *x = "hello llvm"; After: const char *x = "hello llvm"; This fixes llvm.org/PR22245. Patch by Bill Meltsner, thank you! llvm-svn: 226564
* clang-format: Fix clang-format crash on invalid code.Daniel Jasper2015-01-191-1/+1
| | | | llvm-svn: 226449
* clang-format: Remove assert that isn't helpful.Daniel Jasper2015-01-191-1/+0
| | | | | | | This assert would trigger on: #d , = } llvm-svn: 226446
* clang-format: Improve format of lambdas in ctor initializers.Daniel Jasper2015-01-121-0/+1
| | | | | | | | | | | | | | | | Before: Constructor() : Constructor([] { // comment int i; }) {} After: Constructor() : Constructor([] { // comment int i; }) {} llvm-svn: 225625
* clang-format: [Java] Support formatting qualified annotations.Nico Weber2015-01-091-5/+6
| | | | llvm-svn: 225559
* clang-format: Re-enable comment re-indentation for Java/JS.Daniel Jasper2015-01-041-6/+6
| | | | | | This was broken by r224120. llvm-svn: 225130
* Don't break single-line raw string literals.Alexander Kornienko2014-12-141-20/+1
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6636 llvm-svn: 224223
* Don't break string literals in Java and JavaScript.Alexander Kornienko2014-12-121-0/+6
| | | | | | | | The proper way to break string literals in these languages is by inserting a "+" between parts which we don't support yet. So we disable string literal breaking until then. llvm-svn: 224120
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-74/+30
| | | | | | | | | | | | | | | | | | | | | | This fixed llvm.org/PR21804 and hopefully a few other strange cases. Before: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } After: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } llvm-svn: 224112
* clang-format: Remove a few else after return statements.Daniel Jasper2014-12-101-19/+12
| | | | | | | They are against the LLVM coding conventions. No functional changes intended. llvm-svn: 223930
* clang-format: Indent correctly in conditional expressions after return.Daniel Jasper2014-12-081-1/+2
| | | | | | | | | | | | | | | | | | | This only applies when not aligning after the return itself (which is commonly done for C++. Before: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) // This is indented relative to aaaaaaaaaa. : b; After: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) : b; llvm-svn: 223694
* clang-format: [Java] Always break after annotations of multiline decls.Daniel Jasper2014-12-081-3/+6
| | | | | | | | | | | | | Before: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 223688
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-021-4/+8
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
* clang-format: precedence-based indentation when breaking before operators.Daniel Jasper2014-12-021-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; After: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; Not particularly pretty, but can probably help to uncover bugs. And if this bugs somebody, parentheses can help. llvm-svn: 223111
* clang-format: Refactoring.Daniel Jasper2014-11-251-99/+83
| | | | | | Re-apply r222638 and r222641 without variadic templates. llvm-svn: 222747
* Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 ↵Aaron Ballman2014-11-241-83/+99
| | | | | | does not support variadic templates. Also reverting r222641 because it was relying on 222638. llvm-svn: 222656
* clang-format: Refactoring.Daniel Jasper2014-11-231-99/+83
| | | | | | | Provide more overloads to simplify testing the type of a token. No functional changes intended. llvm-svn: 222638
* clang-format: [JS] Support Closure's module statements.Daniel Jasper2014-11-231-2/+3
| | | | | | | These are like import statements and should not be line-wrapped. Minor restructuring of the handling of other import statements. llvm-svn: 222637
* clang-format: Use nested block special case for all languages.Daniel Jasper2014-11-211-23/+20
| | | | | | | | | | | | | | | | | | | Previously this was only used for JavaScript. Before: functionCall({ int i; int j; }, aaaa, bbbb, cccc); After: functionCall({ int i; int j; }, aaaa, bbbb, cccc); llvm-svn: 222531
* clang-format: [Java] Don't align after "return".Daniel Jasper2014-11-201-1/+2
| | | | | | | | | | | | | | | | | | Doesn't seem to be common practice in Java. Before: return aaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbb && ccccccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbb && ccccccccccccccccccc; Patch by Harry Terkelsen. llvm-svn: 222424
* clang-format: Add option to disable alignment after opening bracketsDaniel Jasper2014-11-181-5/+8
| | | | | | | | | | | | | | Before: SomeFunction(parameter, parameter); After: SomeFunction(parameter, parameter); Patch by Harry Terkelsen, thank you! llvm-svn: 222284
* clang-format: Improve function parameter packing.Daniel Jasper2014-11-141-1/+2
| | | | | | | | | | | | | | | Before: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); After: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); llvm-svn: 221989
* clang-format: Improve indentation of comments in expressions.Daniel Jasper2014-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | Before: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; After: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; llvm-svn: 221985
* Revert "clang-format: [js] Updates to Google's JavaScript style."Daniel Jasper2014-11-051-1/+0
| | | | | | | | This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b. Apparently, this change was a bit premature. llvm-svn: 221365
* clang-format: Use identifier table for keywords in other languages.Daniel Jasper2014-11-041-5/+6
| | | | | | | | | Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
* clang-format: [Java] Fix class declaration formatting.Daniel Jasper2014-11-031-1/+3
| | | | | | | | | | | | | | | | Before: @SomeAnnotation() abstract class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb implements cccccccccccc { } After: @SomeAnnotation() abstract class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb implements cccccccccccc { } llvm-svn: 221121
* clang-format: [Java] Don't break after extends/implements.Daniel Jasper2014-11-021-0/+7
| | | | | | | | | | | | Before: abstract class SomeClass extends SomeOtherClass implements SomeInterface {} After: abstract class SomeClass extends SomeOtherClass implements SomeInterface {} llvm-svn: 221103
* clang-format: [Java] Improve line breaks around annotations.Daniel Jasper2014-10-311-3/+6
| | | | | | | | | | | | | | | | | Before: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} After: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} llvm-svn: 220984
OpenPOWER on IntegriCloud