summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* 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
OpenPOWER on IntegriCloud