#
62e68174 |
| 25-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Re-add hack that caused regression.
This fixes llvm.org/PR15350.
Before: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaa
Re-add hack that caused regression.
This fixes llvm.org/PR15350.
Before: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}
After: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}
I think the correct solution is to put the VariablePos into ParenState, not LineState. Added FIXME.
llvm-svn: 176027
show more ...
|
#
26d1b1db |
| 24-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Allow breaking between a type and name in variable declarations.
This fixes llvm.org/PR14967 and is generall necessary to avoid situations where the column limit is exceeded. The challenge is restri
Allow breaking between a type and name in variable declarations.
This fixes llvm.org/PR14967 and is generall necessary to avoid situations where the column limit is exceeded. The challenge is restricting such lines splits, otherwise clang-format suddenly starts breaking at bad places.
Before: ReallyLongReturnType<TemplateParam1, TemplateParam2> ReallyReallyLongFunctionName( const std::string &SomeParameter, const SomeType<string, SomeOtherTemplateParameter> &ReallyReallyLongParameterName, const SomeType<string, SomeOtherTemplateParameter> &AnotherLongParameterName) {}
After: ReallyLongReturnType<TemplateParam1, TemplateParam2> ReallyReallyLongFunctionName( const std::string &SomeParameter, const SomeType<string, SomeOtherTemplateParameter> & ReallyReallyLongParameterName, const SomeType<string, SomeOtherTemplateParameter> & AnotherLongParameterName) {}
llvm-svn: 175999
show more ...
|
#
cd8599e8 |
| 23-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Better formatting of conditional expressions.
In conditional expressions, if the condition is split over multiple lines, also break before both operands.
This prevents formattings like:
aaaaaaaa
Better formatting of conditional expressions.
In conditional expressions, if the condition is split over multiple lines, also break before both operands.
This prevents formattings like:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c;
Which are bad, because they suggestion incorrect operator precedence:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c);
This lead to the discovery that the expression parser incorrectly handled conditional operators and that it could also handle semicolons (which in turn reduced the amount of special casing for for-loops). As a side-effect, we can now apply the bin-packing configuration to the sections of for-loops.
llvm-svn: 175973
show more ...
|
#
ba0bda97 |
| 23-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Don't recognize unnamed pointer parameters as casts.
This fixes llvm.org/PR15061.
Before: virtual void f(int *)const; After: virtual void f(int *) const; llvm-svn: 175960
|
#
af5ba0ed |
| 23-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Allow splitting between string literals and identifiers.
Also don't break in long include directives as that is not desired.
We can now format:
#include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Allow splitting between string literals and identifiers.
Also don't break in long include directives as that is not desired.
We can now format:
#include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" #define LL_FORMAT "ll" printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT "d, ddddddddd: %" LL_FORMAT "d\n");
Before, this led to weird results.
llvm-svn: 175959
show more ...
|
#
12ef4e59 |
| 21-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Consistently put {} onto the same line for empty functions.
This fixes llvm.org/PR15167.
Before: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10), BBBBBBBBB(10) { } L
Consistently put {} onto the same line for empty functions.
This fixes llvm.org/PR15167.
Before: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10), BBBBBBBBB(10) { } LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}
After: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10), BBBBBBBBB(10) {} LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}
llvm-svn: 175800
show more ...
|
#
37905f71 |
| 21-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Allow breaking between type and name in for loops.
This fixes llvm.org/PR15033.
Also: Always break before a parameter, if the previous parameter was split over multiple lines. This was necessary to
Allow breaking between type and name in for loops.
This fixes llvm.org/PR15033.
Also: Always break before a parameter, if the previous parameter was split over multiple lines. This was necessary to make the right decisions in for-loops, almost always makes the code more readable and also fixes llvm.org/PR14873.
Before: for (llvm::ArrayRef<NamedDecl *>::iterator I = FD->getDeclsInPrototypeScope() .begin(), E = FD->getDeclsInPrototypeScope().end(); I != E; ++I) { } foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccc), d, bar(e, f));
After: for (llvm::ArrayRef<NamedDecl *>::iterator I = FD->getDeclsInPrototypeScope().begin(), E = FD->getDeclsInPrototypeScope().end(); I != E; ++I) { } foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccc), d, bar(e, f));
llvm-svn: 175741
show more ...
|
#
0c91571d |
| 20-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Fix regression in string literal alignment.
Now correctly indents (again): a = a + "a" "a" "a";
llvm-svn: 175630
|
#
02f640a3 |
| 20-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Fixes bug in string literal alignment.
We now indent the following correctly: 1. some + "literal" /* comment */ "literal"; 2. breaking string literals after which we have another string li
Fixes bug in string literal alignment.
We now indent the following correctly: 1. some + "literal" /* comment */ "literal"; 2. breaking string literals after which we have another string literal.
llvm-svn: 175628
show more ...
|
#
dc7d5817 |
| 20-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Don't remove blank lines within unwrapped lines.
If the code author decides to put empty lines anywhere into the code we should treat them equally, i.e. reduce them to the configured MaxEmptyLinesTo
Don't remove blank lines within unwrapped lines.
If the code author decides to put empty lines anywhere into the code we should treat them equally, i.e. reduce them to the configured MaxEmptyLinesToKeep.
With this change, we e.g. keep the newline in: SomeType ST = { // First value a,
// Second value b };
llvm-svn: 175620
show more ...
|
#
1998ea2c |
| 20-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Implements breaking of string literals if they stick out.
An alternative strategy to calculating the break on demand when hitting a token that would need to be broken would be to put all possible br
Implements breaking of string literals if they stick out.
An alternative strategy to calculating the break on demand when hitting a token that would need to be broken would be to put all possible breaks inside the token into the optimizer.
Currently only supports breaking at spaces; more break points to come.
llvm-svn: 175613
show more ...
|
#
6db1b7ca |
| 19-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Add missing clang-format null pointer check..
.. and a test that triggers it in valid albeit questionable code.
llvm-svn: 175554
|
#
0047596c |
| 19-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Correctly format macro with unfinished template declaration.
We can now format: #define A template <typename T>
Before this created a segfault :-/.
llvm-svn: 175533
|
#
e53beb26 |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Improve indentation of builder type calls.
In builder-type calls, it can be very confusing to just indent parameters from the start of the line. Instead, indent 4 from the correct function call.
Be
Improve indentation of builder type calls.
In builder-type calls, it can be very confusing to just indent parameters from the start of the line. Instead, indent 4 from the correct function call.
Before: aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break aaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ->aaaaaaaaaaaaaaaaa();
After: aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break aaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa() ->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ->aaaaaaaaaaaaaaaaa();
llvm-svn: 175444
show more ...
|
#
9ed9ade0 |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of builder-type calls.
Before: aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);
After: aaaaaaa->aaaaaaa ->a
Improve formatting of builder-type calls.
Before: aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);
After: aaaaaaa->aaaaaaa ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ->aaaaaaaa(aaaaaaaaaaaaaaa);
llvm-svn: 175441
show more ...
|
#
55d7ba6b |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Reformat lines if they were "moved around".
An unwrapped line can get moved around if there is no newline before it and the previous line was formatted.
Example:
template<typename T> // Cursor
Reformat lines if they were "moved around".
An unwrapped line can get moved around if there is no newline before it and the previous line was formatted.
Example:
template<typename T> // Cursor is on this line when hitting "format" T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }
"return .." is the second unwrapped line in this scenario. I does not touch any reformatted region. Thus, the result of formatting is:
template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); }
After second format (and arguably desired end-result):
template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); }
This fixes: llvm.org/PR15060.
llvm-svn: 175440
show more ...
|
#
5065bc4b |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Correctly determine */& usage in more cases.
This fixes llvm.org/PR15248.
Before: Test::Test(int b) : a(b *b) {} for (int i = 0; i < a *a; ++i) {}
After: Test::Test(int b) : a(b * b) {} for (int i
Correctly determine */& usage in more cases.
This fixes llvm.org/PR15248.
Before: Test::Test(int b) : a(b *b) {} for (int i = 0; i < a *a; ++i) {}
After: Test::Test(int b) : a(b * b) {} for (int i = 0; i < a * a; ++i) {}
llvm-svn: 175439
show more ...
|
#
2ec3ffb8 |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Always break after multi-line string literals.
Otherwise, other parameters can be quite hidden. Reformatted unittests/Format/FormatTest.cpp after this.
Before: someFunction("Always break between mu
Always break after multi-line string literals.
Otherwise, other parameters can be quite hidden. Reformatted unittests/Format/FormatTest.cpp after this.
Before: someFunction("Always break between multi-line" " string literals", and, other, parameters);
After: someFunction("Always break between multi-line" " string literals", and, other, parameters);
llvm-svn: 175436
show more ...
|
#
40c36c54 |
| 18-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Prevent line breaks that make stuff hard to read.
Before: aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaa, aa
Prevent line breaks that make stuff hard to read.
Before: aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After: aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 175432
show more ...
|
#
eb50c676 |
| 15-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Recognize < and > as binary expressions in builder-type calls.
The current heuristic assumes that there can't be binary operators in builder-type calls (excluding assigments). However, it also exclu
Recognize < and > as binary expressions in builder-type calls.
The current heuristic assumes that there can't be binary operators in builder-type calls (excluding assigments). However, it also excluded < and > in general, which is wrong. Now they are only excluded if they are template parameters.
Before: return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa()i .aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
After: return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
llvm-svn: 175291
show more ...
|
#
0af92ebb |
| 15-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Done break between 'operator' and '<<'.
Before: ostream &operator <<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);
After: ostream &operator<<(ostream &out,
Done break between 'operator' and '<<'.
Before: ostream &operator <<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);
After: ostream &operator<<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);
llvm-svn: 175286
show more ...
|
#
23e8e0c7 |
| 15-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.
This got lost and was untested as the same effect is achieved by avoiding bin packing, which is active in Google style by default. Ho
Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.
This got lost and was untested as the same effect is achieved by avoiding bin packing, which is active in Google style by default. However, moving forward, we want more control over the bin packing option(s) and thus, this flag should work as expected.
llvm-svn: 175277
show more ...
|
#
54a8602a |
| 15-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Prevent only breaking before "?" in conditional expressions.
This is almost always more readable.
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : a
Prevent only breaking before "?" in conditional expressions.
This is almost always more readable.
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa;
After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 175262
show more ...
|
#
e11095af |
| 14-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix counting of parameters so that r175162 works as expected.
Before: aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() .aaaaaaaaaaaaaaaaa());
After: aaaaa
Fix counting of parameters so that r175162 works as expected.
Before: aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() .aaaaaaaaaaaaaaaaa());
After: aaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa());
Not sure which of the formattings above is better, but we should not pick one by accident.
llvm-svn: 175165
show more ...
|
#
687af3bb |
| 14-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Reduce penalty for breaking before ./-> after complex calls.
This gives a clearer separation of the context, e.g. in GMOCK statements.
Before: EXPECT_CALL(SomeObject, SomeFunction(Param
Reduce penalty for breaking before ./-> after complex calls.
This gives a clearer separation of the context, e.g. in GMOCK statements.
Before: EXPECT_CALL(SomeObject, SomeFunction(Parameter)).WillRepeatedly(Return(SomeValue));
After: EXPECT_CALL(SomeObject, SomeFunction(Parameter)) .WillRepeatedly(Return(SomeValue));
Minor format cleanups.
llvm-svn: 175162
show more ...
|