summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.h
Commit message (Collapse)AuthorAgeFilesLines
* Addressed reviewer's post-submission comments from ↵Eric Liu2016-04-281-2/+3
| | | | | | | | | | | | | | 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] Use in-class initializers to simplify constructor.Benjamin Kramer2015-06-121-17/+14
| | | | | | Sadly C++11 doesn't let us use initializers on bitfield members (DR1341). NFC. llvm-svn: 239606
* [clang-format] Reorder and pack ParenState members to minimize paddingBenjamin Kramer2015-06-121-36/+36
| | | | | | sizeof(ParenState) goes from 64 bytes to 52 bytes. NFC. llvm-svn: 239605
* clang-format: [JS] Hotfix for runtime issue with deeply nested JS code.Daniel Jasper2015-06-091-3/+3
| | | | | | | | | | | | | | I have not succeeded in writing a proper test case for this yet and we also need to solve the underlying fundamental problem of trying too many combinations with nested blocks (basically this somewhat works around our Dijkstra algorithm). Preventing this linebreak is good anyways as usually the penalties never make us choose it (that's why I can't create a test) and it also looks ugly. Also cleaned up state comparison code that I discovered while hunting this down. llvm-svn: 239398
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-1/+8
| | | | | | | | | | | | | | | | | | | | | | 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: Use nested block special case for all languages.Daniel Jasper2014-11-211-6/+6
| | | | | | | | | | | | | | | | | | | 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: Use identifier table for keywords in other languages.Daniel Jasper2014-11-041-2/+5
| | | | | | | | | Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-3/+3
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* clang-format: Refactor indentation behavior for multiple nested blocks.Daniel Jasper2014-06-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Split up moveStateToNextToken.Daniel Jasper2014-05-261-0/+12
| | | | | | No functional changes intended. llvm-svn: 209626
* clang-format: [JS] Support different function literal style.Daniel Jasper2014-05-211-1/+8
| | | | | | | | | | | | | | | | | Before: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); After: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); llvm-svn: 209291
* clang-format: Cleanup redundant calculation of ParenLevel.Daniel Jasper2014-05-081-7/+2
| | | | | | No functional changes intended. llvm-svn: 208304
* clang-format: Don't allow hanging indentation for operators on new linesDaniel Jasper2014-04-141-5/+11
| | | | | | | | | | | | | | | | 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/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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: Extract getNewLineColumn out of addTokenOnNewLine.Daniel Jasper2014-03-271-0/+3
| | | | | | No functional changes intended. llvm-svn: 204930
* Added an option to avoid splitting certain kinds of comments into lines.Alexander Kornienko2014-01-021-0/+2
| | | | | | | | | | | | | | 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 various problems in formatting ObjC blocks.Daniel Jasper2013-12-231-1/+16
| | | | | | Among other things, this fixes llvm.org/PR15269. llvm-svn: 197900
* clang-format: Improve handling of raw string literals.Daniel Jasper2013-12-161-1/+1
| | | | | | | | | | | | | | | | 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
* Simplify fix proposed in r195240.Daniel Jasper2013-11-201-2/+2
| | | | llvm-svn: 195253
* Fix bug where optimization would lead to strange line breaks.Manuel Klimek2013-11-201-2/+2
| | | | | | | | | | | | | | | | | Before: void f() { CHECK_EQ(aaaa, ( *bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } After: void f() { CHECK_EQ(aaaa, (*bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } llvm-svn: 195240
* Keep track of indentation levels in static initializers for correct ↵Alexander Kornienko2013-10-141-4/+7
| | | | | | | | | | | | | | | | | | | indentation with tabs. Summary: Store IndentationLevel in ParentState and use it instead of the Line::Level when indening. Also fixed incorrect indentation level calculation in formatFirstToken. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1797 llvm-svn: 192563
* Support formatting of preprocessor branches.Manuel Klimek2013-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | We now correctly format: void SomeFunction(int param1, #ifdef X NoTemplate param2, #else template < #ifdef A MyType<Some> > #else Type1, Type2> #endif param2, #endif param3) { f(); } llvm-svn: 192503
* Refactoring: split addTokenToState into two methods.Alexander Kornienko2013-10-011-0/+19
| | | | | | | | | | | | | | Summary: Pure refactoring, should be no semantic changes. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1796 llvm-svn: 191772
* Correctly calculate OriginalColumn after multi-line tokens.Alexander Kornienko2013-09-101-3/+2
| | | | | | | | | | | | | | Summary: This also unifies the handling of escaped newlines for all tokens. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1638 llvm-svn: 190405
* clang-format: Fix comment formatting bugs in nested blocks.Daniel Jasper2013-09-061-1/+2
| | | | | | | | | | | This fixes two issues: 1) The indent of a line comment was not adapted to the subsequent statement as it would be outside of a nested block. 2) A missing DryRun flag caused actualy breaks to be inserted in overly long comments while trying to come up with the best line breaking decisions. llvm-svn: 190123
* clang-format: Enable formatting of nested blocks.Daniel Jasper2013-09-051-7/+12
| | | | | | | | | | | | | | | | | | Among other things, this enables (better) formatting lambdas and constructs like: MACRO({ long_statement(); long_statement_2(); }, { long_statement(); long_statement_2(); }, { short_statement(); }, ""); This fixes llvm.org/PR15381. llvm-svn: 190038
* Better support for multiline string literals (including C++11 raw string ↵Alexander Kornienko2013-08-291-0/+8
| | | | | | | | | | | | | | | | | | literals). Summary: Calculate characters in the first and the last line correctly so that we only break before the literal when needed. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1544 llvm-svn: 189595
* clang-format: Format segments of builder-type calls one per line.Daniel Jasper2013-08-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | This fixes llvm.org/PR14818. Before: return llvm::StringSwitch<Reference::Kind>(name) .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR) .StartsWith(".eh_frame", ORDER_EH_FRAME) .StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI) .StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT); After: return llvm::StringSwitch<Reference::Kind>(name) .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR) .StartsWith(".eh_frame", ORDER_EH_FRAME) .StartsWith(".init", ORDER_INIT) .StartsWith(".fini", ORDER_FINI) .StartsWith(".hash", ORDER_HASH) .Default(ORDER_TEXT); llvm-svn: 189353
* clang-format: Fix corner case for string splitting ..Daniel Jasper2013-08-231-0/+7
| | | | | | | | .. in conjunction with Style.AlwaysBreakBeforeMultilineStrings. Also, simplify the implementation by handling newly split strings and already split strings by the same code. llvm-svn: 189102
* clang-format: Add column layout formatting for braced listsDaniel Jasper2013-08-221-1/+2
| | | | | | | | | | | | | | | | | | | | With this patch, braced lists (with more than 3 elements are formatted in a column layout if possible). E.g.: static const uint16_t CallerSavedRegs64Bit[] = { X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI, X86::R8, X86::R9, X86::R10, X86::R11, 0 }; Required other changes: - FormatTokens can now have a special role that contains extra data and can do special formattings. A comma separated list is currently the only implementation. - Move penalty calculation entirely into ContinuationIndenter (there was a last piece still in UnwrappedLineFormatter). Review: http://llvm-reviews.chandlerc.com/D1457 llvm-svn: 189018
* Split UnwrappedLineFormatter into individual components.Daniel Jasper2013-08-161-0/+277
Goals: Structure code better and make components easier to use for future features (e.g. column layout for long braced initializers). No functional changes intended. llvm-svn: 188543
OpenPOWER on IntegriCloud