#
8369aa5e |
| 16-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Improve handling of unterminated string literals.
Before, clang-format would simply eat these as they were recognized as whitespace. With this patch, they are mostly left alone.
llvm-
clang-format: Improve handling of unterminated string literals.
Before, clang-format would simply eat these as they were recognized as whitespace. With this patch, they are mostly left alone.
llvm-svn: 186454
show more ...
|
#
6ab54686 |
| 16-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Revamp the formatting of C++11 braced init lists.
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 be
Revamp the formatting of C++11 braced init lists.
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.
llvm-svn: 186433
show more ...
|
#
fa21c072 |
| 15-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Improvement of change r186320.
Fixed a test that by now passed for the wrong reason.
Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
Improvement of change r186320.
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).
llvm-svn: 186322
show more ...
|
#
0d5e44df |
| 15-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of operator<< chains.
Before: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaa
Improve formatting of operator<< chains.
Before: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;
After: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;
llvm-svn: 186320
show more ...
|
#
77d5d313 |
| 12-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Improve <<-formatting.
This fixes a regression caused by r186115.
Before: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
clang-format: Improve <<-formatting.
This fixes a regression caused by r186115.
Before: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 186164
show more ...
|
#
5aad4e56 |
| 12-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Fix string literal breaking.
Before this patch, it did not cooperate with Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn
aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa
clang-format: Fix string literal breaking.
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.
llvm-svn: 186154
show more ...
|
#
aea3bde0 |
| 12-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Break before/between array subscript expressions.
clang-format used to treat array subscript expressions much like function call (just replacing () with []). However, this is not reall
clang-format: Break before/between array subscript expressions.
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;
llvm-svn: 186153
show more ...
|
#
51efbad7 |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Fix bug concerning the alignment of "}".
Before: int i; // indented 2 space more than clang-format would use. SomeReturnType // clang-format invoked on this line. SomeFun
clang-format: Fix bug concerning the alignment of "}".
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() { }
llvm-svn: 186120
show more ...
|
#
4e9678f7 |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Avoid line breaks before the first <<.
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 f
clang-format: Avoid line breaks before the first <<.
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;
llvm-svn: 186115
show more ...
|
#
185de249 |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Fix indentation problem for comments in call chains
Before: SomeObject // Calling someFunction on SomeObject .someFunction();
After: SomeObject // Calling someFunction on SomeObject
Fix indentation problem for comments in call chains
Before: SomeObject // Calling someFunction on SomeObject .someFunction();
After: SomeObject // Calling someFunction on SomeObject .someFunction();
llvm-svn: 186085
show more ...
|
#
b10cbc45 |
| 10-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Add experimental flag for adaptive parameter bin-packing.
This is not activated for any style, might change or go away completely.
For those that want to play around with it, set ExperimentalAutoDe
Add experimental flag for adaptive parameter bin-packing.
This is not activated for any style, might change or go away completely.
For those that want to play around with it, set ExperimentalAutoDetectBinPacking to true.
clang-format will then: Look at whether function calls/declarations/definitions are currently formatted with one parameter per line (on a case-by-case basis). If so, clang-format will avoid bin-packing the parameters. If all parameters are on one line (thus that line is "inconclusive"), clang-format will make the choice dependent on whether there are other bin-packed calls/declarations in the same file.
The reason for this change is that bin-packing in some situations can be really bad and an author might opt to put one parameter on each line. If the author does that, he might want clang-format not to mess with that. If the author is unhappy with the one-per-line formatting, clang-format can easily be convinced to bin-pack by putting any two parameters on the same line.
llvm-svn: 186003
show more ...
|
#
6cdec7cf |
| 09-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Initial support for formatting trailing return types.
This fixes llvm.org/PR15170.
For now, the basic formatting rules are (based on the C++11 standard): * Surround the "->" with spaces. * Break be
Initial support for formatting trailing return types.
This fixes llvm.org/PR15170.
For now, the basic formatting rules are (based on the C++11 standard): * Surround the "->" with spaces. * Break before "->".
Also fix typo.
llvm-svn: 185938
show more ...
|
#
bd05888f |
| 09-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Avoid confusing indentations for chained function calls.
Basically treat a function with a trailing call similar to a function with multiple parameters.
Before: aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa
Avoid confusing indentations for chained function calls.
Basically treat a function with a trailing call similar to a function with multiple parameters.
Before: aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
After: aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
Also fix typo.
llvm-svn: 185930
show more ...
|
#
b1f74a81 |
| 09-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Fix alignment of closing brace in braced initializers.
Before: someFunction(OtherParam, BracedList{ // comment 1 (Forcing intersting break) para
Fix alignment of closing brace in braced initializers.
Before: someFunction(OtherParam, BracedList{ // comment 1 (Forcing intersting break) param1, param2, // comment 2 param3, param4 }); After: someFunction(OtherParam, BracedList{ // comment 1 (Forcing intersting break) param1, param2, // comment 2 param3, param4 });
To do so, the UnwrappedLineParser now stores the information about the kind of brace in the FormatToken.
llvm-svn: 185914
show more ...
|
#
6331da06 |
| 09-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Format overloaded operators like other functions.
This fixes llvm.org/PR16328 (at least partially).
Before: SomeLoooooooooooooooooooooooooooooogType operator<<( const SomeLooooooooogType &a, co
Format overloaded operators like other functions.
This fixes llvm.org/PR16328 (at least partially).
Before: SomeLoooooooooooooooooooooooooooooogType operator<<( const SomeLooooooooogType &a, const SomeLooooooooogType &b);
After: SomeLoooooooooooooooooooooooooooooogType operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b);
llvm-svn: 185908
show more ...
|
Revision tags: llvmorg-3.3.1-rc1 |
|
#
3ac9b9e2 |
| 08-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Reformat clang-format's source files after r185822 and others.
llvm-svn: 185823
|
#
ee7539a3 |
| 08-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Prefer similar line breaks.
This adds a penalty for clang-format for each break that occurs in a set of parentheses (including fake parenthesis that determine the range of certain operator precenden
Prefer similar line breaks.
This adds a penalty for clang-format for each break that occurs in a set of parentheses (including fake parenthesis that determine the range of certain operator precendences) that have not yet been broken. Thereby, clang-format prefers similar line breaks.
This fixes llvm.org/PR15506.
Before: const int kTrackingOptions = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways;
After: const int kTrackingOptions = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways;
Also removed ParenState::ForFakeParenthesis which has become unused.
llvm-svn: 185822
show more ...
|
#
61ac906b |
| 08-Jul-2013 |
Craig Topper <craig.topper@gmail.com> |
Use SmallVectorImpl::reverse_iterator instead of SmallVector to avoid specifying the vector size.
llvm-svn: 185784
|
#
0e90c3d9 |
| 05-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Improve detection for preventing certain kind of formatting patterns.
This is a better implementation of r183097. The main purpose is to prevent certain constructs to be formatted "like a block of t
Improve detection for preventing certain kind of formatting patterns.
This is a better implementation of r183097. The main purpose is to prevent certain constructs to be formatted "like a block of text".
Before: aaaaaaaaaaaaa< aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa< aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(bbbbbbbbbbbbbbbbbbbbbbbb); aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[ dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];
After: aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>( bbbbbbbbbbbbbbbbbbbbbbbb); aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[ dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];
llvm-svn: 185687
show more ...
|
#
1efe0a07 |
| 04-Jul-2013 |
Alexander Kornienko <alexfh@google.com> |
Fixed typo: NoneComment -> NonComment, no other changes.
llvm-svn: 185640
|
#
58611718 |
| 04-Jul-2013 |
Alexander Kornienko <alexfh@google.com> |
Added AlwaysBreakBeforeMultilineStrings option.
Summary: Always breaking before multiline strings can help format complex expressions containing multiline strings more consistently, and avoid consum
Added AlwaysBreakBeforeMultilineStrings option.
Summary: Always breaking before multiline strings can help format complex expressions containing multiline strings more consistently, and avoid consuming too much horizontal space.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1097
llvm-svn: 185622
show more ...
|
#
7ae41cdd |
| 03-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Don't insert confusing line breaks in comparisons.
In general, clang-format breaks after an operator if the LHS spans multiple lines. Otherwise, this can lead to confusing effects and effectively hi
Don't insert confusing line breaks in comparisons.
In general, clang-format breaks after an operator if the LHS spans multiple lines. Otherwise, this can lead to confusing effects and effectively hide the operator precendence, e.g. in
if (aaaaaaaaaaaaaa == bbbbbbbbbbbbbb && c) { ...
This patch removes this rule for comparisons, if the LHS is not a binary expression itself as many users were wondering why clang-format inserts an unnecessary linebreak.
Before: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ...
After: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ...
In the long run, we might: - Want to do this for other binary expressions as well. - Do this only if the RHS is short or even only if it is a literal.
llvm-svn: 185530
show more ...
|
#
aa620e18 |
| 01-Jul-2013 |
Alexander Kornienko <alexfh@google.com> |
Avoid column limit violation in block comments in certain cases.
Summary: Add penalty when an excessively long line in a block comment can not be broken on a leading whitespace. Lack of this additio
Avoid column limit violation in block comments in certain cases.
Summary: Add penalty when an excessively long line in a block comment can not be broken on a leading whitespace. Lack of this addition can lead to severe column width violations when they can be easily avoided.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1071
llvm-svn: 185337
show more ...
|
#
af35e852 |
| 30-Jun-2013 |
Craig Topper <craig.topper@gmail.com> |
Put helper classes into anonymous namespace.
llvm-svn: 185295
|
#
1e80887d |
| 28-Jun-2013 |
Alexander Kornienko <alexfh@google.com> |
Use lexing mode based on FormatStyle.Standard.
Summary: Some valid pre-C++11 constructs change meaning when lexed in C++11 mode, e.g. #define x(_a) printf("foo"_a); (example from http://llvm.org/bug
Use lexing mode based on FormatStyle.Standard.
Summary: Some valid pre-C++11 constructs change meaning when lexed in C++11 mode, e.g. #define x(_a) printf("foo"_a); (example from http://llvm.org/bugs/show_bug.cgi?id=16342). "foo"_a is treated as a user-defined string literal when parsed in C++11 mode. In order to deal with this correctly, we need to set lexing mode according to which standard the code conforms to. We already have a configuration value for this (FormatStyle.Standard), which seems to be appropriate to use in this case as well.
Reviewers: klimek
CC: cfe-commits, gribozavr
Differential Revision: http://llvm-reviews.chandlerc.com/D1028
llvm-svn: 185149
show more ...
|