#
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 ...
|
#
655d96ab |
| 16-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Improve detection of function types.
This fixes an incorrect detection that led to a formatting error. Before: some_var = function (*some_pointer_var)[0]; After: some_var = functio
clang-format: Improve detection of function types.
This fixes an incorrect detection that led to a formatting error. Before: some_var = function (*some_pointer_var)[0]; After: some_var = function(*some_pointer_var)[0];
llvm-svn: 186402
show more ...
|
#
49a9448d |
| 15-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Improve c-style cast detection.
Before: #define x ((int) - 1) #define p(q) ((int *) & q) After: #define x ((int)-1) #define p(q) ((int *)&q)
llvm-svn: 186324
|
#
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 ...
|
#
718bd366 |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Break before trailing annotations.
(if they are not function-like).
Before: SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;
After: SomeFunction(aaa
clang-format: Break before trailing annotations.
(if they are not function-like).
Before: SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;
After: SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;
llvm-svn: 186117
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 ...
|
#
a3501d4b |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Improve detection of trailing return types.
Trailing return types can only occur in declaration contexts.
Before: void f() { auto a = b -> c(); }
After: void f() { auto a = b->c(); }
llvm-svn
Improve detection of trailing return types.
Trailing return types can only occur in declaration contexts.
Before: void f() { auto a = b -> c(); }
After: void f() { auto a = b->c(); }
llvm-svn: 186087
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 ...
|
#
40db06af |
| 11-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Keep trailing annotations close to their argument.
Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa);
After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Keep trailing annotations close to their argument.
Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa);
After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa);
llvm-svn: 186077
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 |
|
#
6a09df79 |
| 08-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Fix incorrect incorrect cast identification in clang-format.
This fixes llvm.org/PR16534.
Before: aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION; After: aaaaa& operator+(const aaaaa&) LLVM_DEL
Fix incorrect incorrect cast identification in clang-format.
This fixes llvm.org/PR16534.
Before: aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION; After: aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;
llvm-svn: 185828
show more ...
|
#
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 ...
|
#
614d96a1 |
| 08-Jul-2013 |
Alexander Kornienko <alexfh@google.com> |
Fix for corner cases in code handling leading "* " decorations in block comments
Summary: Fixes problems that lead to incorrect formatting of these and similar snippets: /* ** */
/* **/
/* * *
Fix for corner cases in code handling leading "* " decorations in block comments
Summary: Fixes problems that lead to incorrect formatting of these and similar snippets: /* ** */
/* **/
/* * */
/* *test */
Clang-format used to think that all the cases above use "* " decoration, and failed to calculate insertion position properly. It also used to remove leading "* " in the last line.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1113
llvm-svn: 185818
show more ...
|
#
6f9c8d21 |
| 05-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Fix formatting for allocation of new pointer variables.
Before: T **t = new T * ; T **q = new T * ();
After: T **t = new T *; T **q = new T *();
llvm-svn: 185699
|
#
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 ...
|
#
1bc1b502 |
| 05-Jul-2013 |
Daniel Jasper <djasper@google.com> |
Don't break after a "(" following a binary operator.
Additionally, allow breaking after c-style casts, but with a high penalty.
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = ( aaaaaaaaaaaaaaa
Don't break after a "(" following a binary operator.
Additionally, allow breaking after c-style casts, but with a high penalty.
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = ( aaaaaaaaaaaaaaaaa *)bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (aaaaaaaaaaaaaaaaa *) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
This fixes llvm.org/PR16049.
llvm-svn: 185685
show more ...
|