- Sep 06, 2013
-
-
Daniel Jasper authored
Before: FirstToken->WhitespaceRange.getBegin() .getLocWithOffset(First->LastNewlineOffset); After: FirstToken->WhitespaceRange.getBegin().getLocWithOffset( First->LastNewlineOffset); Re-add logic to prevent breaking after an empty set of parentheses. Basically it seems that calling a function without parameters is more like navigating along the same object than it is a separate step of a builder-type call. We might need to extends this in future to allow "short" parameters that e.g. are an index accessing a specific element. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190126 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190123 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Sep 05, 2013
-
-
Alexander Kornienko authored
Summary: Count column width instead of the number of code points. This also includes correct handling of tabs inside string literals and comments (with an exception of multiline string literals/comments, where tabs are present before the first escaped newline). Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1601 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190052 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Mostly additional comments :-). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190042 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190038 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Sep 04, 2013
-
-
Alexander Kornienko authored
consistency of serialized form with the actual enum member names without a prefix. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189936 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Sep 02, 2013
-
-
Alexander Kornienko authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189765 91177308-0d34-0410-b5e6-96231b3b80d8
-
Alexander Kornienko authored
Summary: Store first and last newline position in the token text for string literals and comments to avoid doing .find('\n') for each possible solution. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1556 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189758 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 29, 2013
-
-
Alexander Kornienko authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189595 91177308-0d34-0410-b5e6-96231b3b80d8
-
Manuel Klimek authored
We now count the original token's column directly when lexing the tokens, where we already have all knowledge about where lines start. Before this patch, formatting: void f() { \tg(); \th(); } would incorrectly count the \t's as 1 character if only the line containing h() was reformatted, and thus indent h() at offset 1. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189585 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 28, 2013
-
-
Daniel Jasper authored
Two changes: * Don't add an extra penalty on breaking the same token multiple times. Generally, we should prefer not to break, but once we break, the normal line breaking penalties apply. * Slightly increase the penalty for breaking comments. In general, the author has put some thought into how to break the comment and we should not overwrite this unnecessarily. With a 40-column column limit, formatting aaaaaa("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"); Leads to: Before: aaaaaa( "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); After: aaaaaa("aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189466 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 22, 2013
-
-
Daniel Jasper authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189028 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189018 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 21, 2013
-
-
Daniel Jasper authored
Before: if (!aaaaaaaaaa( // break aaaaa)) { } After: if (!aaaaaaaaaa( // break aaaaa)) { } Also cleaned up formatting using clang-format. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188891 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 20, 2013
-
-
Daniel Jasper authored
This patch adds four new options to control: - Spaces after control keyworks (if(..) vs if (..)) - Spaces in empty parentheses (f( ) vs f()) - Spaces in c-style casts (( int )1.0 vs (int)1.0) - Spaces in other parentheses (f(a) vs f( a )) Patch by Joe Hermaszewski. Thank you for working on this! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188793 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 16, 2013
-
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188543 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 13, 2013
-
-
Daniel Jasper authored
Some coding styles use a different indent for constructor initializers. Patch by Klemens Baum. Thank you. Review: http://llvm-reviews.chandlerc.com/D1360 Post review changes: Changed data type to unsigned as a negative indent width does not make sense and added test for configuration parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188260 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 12, 2013
-
-
Daniel Jasper authored
Before: CHECK(controller->WriteProto(FLAGS_row_key, FLAGS_proto)) << "\"" << FLAGS_proto << "\""; After: SemaRef.Diag(Loc, diag::note_for_range_begin_end) << BEF << IsTemplate << Description << E->getType(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188175 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before: template <class CallbackClass> using MyCallback = void(CallbackClass::*)(SomeObject * Data);"); After: template <class CallbackClass> using MyCallback = void (CallbackClass::*)(SomeObject *Data);"); Also fix three wrong indentations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188172 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 07, 2013
-
-
Manuel Klimek authored
In particular, left braces after an enum declaration now occur on their own line. Further, when short ifs/whiles are allowed these no longer cause the left brace to be on the same line as the if/while when a brace is included. Patch by Thomas Gibson-Robinson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187901 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 02, 2013
-
-
Manuel Klimek authored
Patch by Frank Miller. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187678 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before, clang-format would not break overly long string literals following a "<<" with FormatStyle::AlwaysBreakBeforeMultilineStrings being set. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187650 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before: some_quite_long_variable_name_ptr ? : argv[9] ? ptr : argv[8] ? : argv[7] ? ptr : argv[6]; After: some_quite_long_variable_name_ptr ?: argv[9] ? ptr : argv[8] ?: argv[7] ? ptr : argv[6]; Patch by Adam Strzelecki, thank you!! This fixed llvm.org/PR16758. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187622 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Aug 01, 2013
-
-
Daniel Jasper authored
Before: template <bool B, bool C> class A { static_assert(B &&C, "Something is wrong"); }; After: template <bool B, bool C> class A { static_assert(B && C, "Something is wrong"); }; (Note the spacing around '&&'). Also change the identifier table to always understand all C++11 keywords (which seems like the right thing to do). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187589 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
.. in order to support WebKit style properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187549 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
With this patch, clang-format can be configured to: * not indent in namespace at all (former behavior). * indent in namespace as in other blocks. * indent only in inner namespaces (as required by WebKit style). Also fix alignment of access specifiers in WebKit style. Patch started by Marek Kurdej. Thank you! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187540 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 26, 2013
-
-
Daniel Jasper authored
New options: * Break before the commas of constructor initializers and align the commas with the colon. * Break before binary operators Additionally, for styles without column limit, don't just accept linebreaks done by the user, but instead remove 'invalid' (according to the current style) linebreaks and add 'required' ones. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187210 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 24, 2013
-
-
Daniel Jasper authored
This is far from implementing all the rules given by http://www.webkit.org/coding/coding-style.html The important new feature is the support for styles that don't have a column limit. For such styles, clang-format will (at the moment) simply respect the input's formatting decisions within statements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187033 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 17, 2013
-
-
Daniel Jasper authored
The AlwaysBreakBeforeMultilineStrings rule does not really make sense if it does not a column gain. Before (in Google style): f( "aaaa" "bbbb"); After: f("aaaa" "bbbb"); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186515 91177308-0d34-0410-b5e6-96231b3b80d8
-
Alexander Kornienko authored
Motivating example: // column limit -------------------> void ffffffffffff(int aaaaaa /* test */); Formatting before the patch: void ffffffffffff(int aaaaaa /* test */); Formatting after the patch: void ffffffffffff(int aaaaaa /* test */); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186471 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 16, 2013
-
-
Alexander Kornienko authored
Summary: These can appear when comments contain command lines with quoted line breaks. As the text (including escaped newlines and '//' from consecutive lines) is a single line comment, we used to break it even when it didn't exceed column limit. This is a temporary solution, in the future we may want to support this case completely - at least adjust leading whitespace when changing indentation of the first line. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1146 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186456 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before, clang-format would simply eat these as they were recognized as whitespace. With this patch, they are mostly left alone. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186454 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
The fundamental concept is: Format as if the braced init list was a function call (with parentheses replaced by braces). If there is no name/type before the opening brace (e.g. if the braced list is nested), assume a zero-length identifier just before the opening brace. This behavior is gated on a new style flag, which for now replaces the SpacesInBracedLists style flag. Activate this style flag for Google style to reflect recent style guide changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186433 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 15, 2013
-
-
Daniel Jasper authored
Fixed a test that by now passed for the wrong reason. Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa); Also reformatted Format.cpp with the latest changes (1 formatting fix and 1 layout change of a <<-chain). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186322 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa; After: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186320 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 12, 2013
-
-
Daniel Jasper authored
This fixes a regression caused by r186115. Before: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186164 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
Before this patch, it did not cooperate with Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); into: aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); and only a second format step would lead to the desired (with that option): aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); This could even lead to clang-format breaking the string at a different character and thus leading to a completely different end result. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186154 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
clang-format used to treat array subscript expressions much like function call (just replacing () with []). However, this is not really appropriate especially for expressions with multiple subscripts. Although it might seem counter-intuitive, the most consistent solution seems to be to always (if necessary) break before a square bracket, never after it. Also, multiple subscripts of the same expression should be aligned if they are on subsequent lines. Before: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa][ bbbbbbbbbbbbbbbbbbbbbbbbb] = c; aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa][ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc; After: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa] [bbbbbbbbbbbbbbbbbbbbbbbbb] = c; aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186153 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jul 11, 2013
-
-
Daniel Jasper authored
Before: int i; // indented 2 space more than clang-format would use. SomeReturnType // clang-format invoked on this line. SomeFunctionMakingLBraceEndInColumn80() { } // This is the indent clang-format would prefer. After: int i; // indented 2 space more than clang-format would use. SomeReturnType // clang-format invoked on this line. SomeFunctionMakingLBraceEndInColumn80() { } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186120 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
This puts a slight penalty on the linebreak before the first "<<", so that clang-format generally tries to keep things on the first line. User feedback has shown that this is generally desirable. Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa; After: llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186115 91177308-0d34-0410-b5e6-96231b3b80d8
-