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