summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* clang-format: Correctly identify ObjC Block with return type.Daniel Jasper2014-03-271-8/+3
| | | | llvm-svn: 204905
* Fix crasher bug.Manuel Klimek2014-03-181-3/+14
| | | | | | | | | | | | | | | Due to not resetting the fake rparen data on the token when iterating over annotated lines, we would pop the last element of the paren stack. This patch fixes the underlying root cause, and makes the code more robust against similar problems in the future: - reset the first token when iterating on the same annotated lines due to preprocessor branches - never pop the last element from the paren stack, so we do not crash, but rather incorrectly format - add assert()s so we can figure out if our assumptions are violated llvm-svn: 204140
* clang-format: Indent from dict literal labels.Daniel Jasper2014-03-171-2/+3
| | | | | | | | | | | | | | | | Before: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; After: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; llvm-svn: 204041
* clang-format: Fix crasher.Daniel Jasper2014-03-121-3/+2
| | | | | | | | | | Caused by unknown tokens (e.g. "\n") not properly updating the state. Example: const char* c = STRINGIFY( \na : b); llvm-svn: 203645
* clang-format: Avoid unnecessary break before lambda return type.Daniel Jasper2014-03-111-1/+2
| | | | | | | | | | | | | | | | | Before: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; After: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; llvm-svn: 203562
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-1/+1
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* Fix operator<< recognition (PR19064).Alexander Kornienko2014-03-061-2/+4
| | | | llvm-svn: 203123
* clang-format: Fix alignment of comments inside statements.Daniel Jasper2014-02-111-22/+29
| | | | | | | | | | | | | | Before: auto result = SomeObject // Calling someFunction on SomeObject .someFunction(); After: auto result = SomeObject // Calling someFunction on SomeObject .someFunction(); llvm-svn: 201138
* clang-format: Don't indent relative to unary operators.Daniel Jasper2014-02-051-1/+0
| | | | | | | | | | | | | | It seems like most people see unary operators more like part of the subsequent identifier and find relative indentation odd. Before: aaaaaaaaaa(!aaaaaaaaaa( // break aaaaa)); After: aaaaaaaaaa(!aaaaaaaaaa( // break aaaaa)); llvm-svn: 200840
* clang-format: Understand __attribute__s preceding parameter lists.Daniel Jasper2014-01-281-1/+2
| | | | | | | | | | | | | | Before: ReturnType __attribute__((unused)) function(int i); After: ReturnType __attribute__((unused)) function(int i); This fixes llvm.org/PR18632. llvm-svn: 200337
* clang-format: Fix bug introduced in r198871.Daniel Jasper2014-01-141-1/+0
| | | | | | | | | | | | We cannot simply change the start column to accomodate for the @ in an ObjC string literal as that will make clang-format happily violate the column limit. Use a different workaround instead. However, a better long-term solution might be to join the @ and the rest of the literal into a single token. llvm-svn: 199198
* clang-format: Don't indent relative to ./->.Daniel Jasper2014-01-131-2/+0
| | | | | | | | | | | | | | | Before: SomeThing // break .SomeFunction( // break param); After: SomeThing // break .SomeFunction( // break param); Seems to be more common in editors and codebases I have looked at. llvm-svn: 199105
* clang-format: Add @s when breaking NSString literals.Daniel Jasper2014-01-091-2/+10
| | | | | | | | While it is allowed to not have an @ on subsequent lines, it seems general practice to add them. If undesired, the code author can easily remove them again and clang-format won't re-add them. llvm-svn: 198871
* clang-format: Some tweaks to braces list formatting:Daniel Jasper2014-01-091-1/+3
| | | | | | | | | - Format a braced list with one element per line if it has nested braced lists. - Use a column layout only when the list has 6+ elements (instead of the current 4+ elements). llvm-svn: 198869
* clang-format: Allow formatting short enums on a single line.Daniel Jasper2014-01-051-4/+12
| | | | | | | | | | | | | | | | | Before: enum ShortEnum { A, B, C }; After: enum ShortEnum { A, B, C }; This seems to be the predominant choice in LLVM/Clang as well as in Google style. llvm-svn: 198558
* Added an option to avoid splitting certain kinds of comments into lines.Alexander Kornienko2014-01-021-1/+6
| | | | | | | | | | | | | | Summary: Added CommentPragmas option for this. Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2460 llvm-svn: 198310
* clang-format: Fix invalid write discovered by ASAN.Daniel Jasper2013-12-231-1/+2
| | | | | | Introduced in r197900. llvm-svn: 197906
* clang-format: Fix various problems in formatting ObjC blocks.Daniel Jasper2013-12-231-15/+48
| | | | | | Among other things, this fixes llvm.org/PR15269. llvm-svn: 197900
* clang-format: Better support for multi-line wide string literals.Daniel Jasper2013-12-201-16/+10
| | | | | | | | | | | Before: SomeFunction(L"A" L"B"); After: SomeFunction(L"A" L"B"); llvm-svn: 197785
* clang-format: Add special case for leading comments in braced lists.Daniel Jasper2013-12-191-1/+3
| | | | | | | | | | | | | | | | | | | A comment following the "{" of a braced list seems to almost always refer to the first element of the list and thus should be aligned to it. Before (with Cpp11 braced list style): SomeFunction({ // Comment 1 "first entry", // Comment 2 "second entry"}); After: SomeFunction({// Comment 1 "first entry", // Comment 2 "second entry"}); llvm-svn: 197725
* clang-format: Slightly adapt decision of when to break before <<.Daniel Jasper2013-12-191-1/+1
| | | | | | | | | | | | Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaa); After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa); llvm-svn: 197690
* clang-format: Fix indentation corner case.Daniel Jasper2013-12-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | Before: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); Probably still not ideal, but should be a step into the right direction. llvm-svn: 197557
* Always break before the colon in constructor initializers, whenAlexander Kornienko2013-12-161-3/+6
| | | | | | | | | | | BreakConstructorInitializersBeforeComma is true. This option is used in WebKit style, so this also ensures initializer lists are not put on a single line, as per the WebKit coding guidelines. Patch by Florian Sowade! llvm-svn: 197386
* clang-format: Improve handling of raw string literals.Daniel Jasper2013-12-161-3/+4
| | | | | | | | | | | | | | | | Especially try to keep existing line breaks before raw string literals, as the code author might have aligned content to it. Thereby, clang-format now keeps things like: parseStyle(R"( BasedOnStyle: Google, ColumnLimit: 100)"); parseStyle( R"(BasedOnStyle: Google, ColumnLimit: 100)"); llvm-svn: 197368
* clang-format: Fix bad indentation of nested blocks.Daniel Jasper2013-11-291-1/+2
| | | | | | | | | | | | | | | Before: DEBUG( // { f(); }); After: DEBUG( // { f(); }); Also add additional test to selected formatting of individual statements in nested blocks. llvm-svn: 195952
* clang-format: Refactor calculation of lines intersecting with -lines.Daniel Jasper2013-11-251-2/+2
| | | | | | | | No functional changes intended. However, it seems to have found a buggy behavior in one of the tests. I think this structure is generally desirable and it will make a planned bugfix significantly easier. llvm-svn: 195634
* clang-format: Fix bug in alignment of complex template parameters.Daniel Jasper2013-11-221-1/+2
| | | | | | | | | | | | | | | Before: template <typename aaaaaaaaaaa, typename bbbbbbbbbbbbb, template <typename> class cccccccccccccccccccccc, typename ddddddddddddd> class C {}; After: template <typename aaaaaaaaaaa, typename bbbbbbbbbbbbb, template <typename> class cccccccccccccccccccccc, typename ddddddddddddd> class C {}; llvm-svn: 195418
* Simplify fix proposed in r195240.Daniel Jasper2013-11-201-16/+8
| | | | llvm-svn: 195253
* Fix bug where optimization would lead to strange line breaks.Manuel Klimek2013-11-201-6/+16
| | | | | | | | | | | | | | | | | Before: void f() { CHECK_EQ(aaaa, ( *bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } After: void f() { CHECK_EQ(aaaa, (*bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } llvm-svn: 195240
* Remove extra whitespace instead of breaking the line in comments when possible.Alexander Kornienko2013-11-121-0/+9
| | | | | | | | | | | | | | Summary: Solves the problem described in http://llvm.org/PR17756 Reviewers: klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2131 llvm-svn: 194493
* Do not insert backslashes, when breaking line comments after preprocessor ↵Alexander Kornienko2013-11-121-8/+9
| | | | | | | | | | | | | | | | directives. Summary: This solves http://llvm.org/PR17536 Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2142 llvm-svn: 194491
* clang-format: Fix alignment of ObjC string literals.Daniel Jasper2013-11-091-1/+1
| | | | | | | | This used to interfere with AlwaysBreakBeforeMultilineStrings. This fixes llvm.org/PR17856. llvm-svn: 194310
* clang-format: Improve formatting of operators forced to new lines.Daniel Jasper2013-11-081-4/+6
| | | | | | | | | | | | | | | | | | | | | | | Before: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) After: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) This fixes llvm.org/PR17687. llvm-svn: 194276
* clang-format: Improve linebreaking and indentation for ObjC calls.Daniel Jasper2013-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Before: popup_wdow_.reset([[RenderWidgetPopupWindow alloc] iniithContentRect: NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height()) syeMask:NSBorderlessWindowMask bking:NSBackingStoreBuffered der:NO]); [self param:function( // parameter)] After: popup_wdow_.reset([[RenderWidgetPopupWindow alloc] iniithContentRect:NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height()) syeMask:NSBorderlessWindowMask bking:NSBackingStoreBuffered der:NO]); [self param:function( // parameter)] llvm-svn: 194267
* clang-format: Properly indent ObjC calls wrapped before first selectorDaniel Jasper2013-11-081-1/+5
| | | | | | | | | | | | | | | | Before: [self // break a:a aa:aa aaaaa:aaa]; After: [self // break a:a aa:aa aaaaa:aaa]; llvm-svn: 194241
* clang-format: Make breaking before ternary operators configurable.Daniel Jasper2013-11-081-6/+15
| | | | llvm-svn: 194229
* clang-format: Improve ObjC variadic and binary expression parameters.Daniel Jasper2013-11-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | Before: [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa]; [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa]; After: [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa]; [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa]; This addresses llvm.org/PR15349 and llvm.org/PR16185. llvm-svn: 194214
* clang-format: Fix corner case for brace alignment.Daniel Jasper2013-11-071-1/+3
| | | | | | | | | | | | | | | | Before: Constructor::Constructor() : some_value{ // aaaaaaa // } {} After: Constructor::Constructor() : some_value{ // aaaaaaa // } {} llvm-svn: 194204
* clang-format: Fix indenting corner case with comment and else.Daniel Jasper2013-10-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | Before: if (a) { f(); } // or else .. else { g(); } After: if (a) { f(); } // or else .. else { g(); } llvm-svn: 193684
OpenPOWER on IntegriCloud