#
58f427ee |
| 19-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix bug in LineState comparison function.
The key bug was
if (Other.StartOfLineLevel < StartOfLineLevel) ..
instead of
if (Other.StartOfLineLevel != StartOfLineLevel) ..
Also cleaned up the
Fix bug in LineState comparison function.
The key bug was
if (Other.StartOfLineLevel < StartOfLineLevel) ..
instead of
if (Other.StartOfLineLevel != StartOfLineLevel) ..
Also cleaned up the function to be more consistent in the comparisons.
llvm-svn: 175500
show more ...
|
#
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 ...
|
#
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 ...
|
#
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 ...
|
#
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 ...
|
#
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 ...
|
#
2457010b |
| 14-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Remove the trailing whitespace of formatted lines.
So far, clang-format has always assumed the whitespace belonging to the subsequent token. This has the negative side-effect that when clang-format
Remove the trailing whitespace of formatted lines.
So far, clang-format has always assumed the whitespace belonging to the subsequent token. This has the negative side-effect that when clang-format formats a line, it does not remove its trailing whitespace, as it belongs to the next token.
Thus, this patch fixes most of llvm.org/PR15062.
We are not zapping a file's trailing whitespace so far, as this does not belong to any token we see during formatting. We need to fix this in a subsequent patch.
llvm-svn: 175152
show more ...
|
#
66e9dee7 |
| 14-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Get less confused by trailing comma in Google style.
The formatter can now format: void aaaaaaaaaaaaaaaaaa(int level, double *min_x, double *max_x,
Get less confused by trailing comma in Google style.
The formatter can now format: void aaaaaaaaaaaaaaaaaa(int level, double *min_x, double *max_x, double *min_y, double *max_y, double *min_z, double *max_z, ) { }
Although this is invalid code, it frequently happens during development and clang-format should be nicer :-).
llvm-svn: 175151
show more ...
|
#
eead02b1 |
| 14-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Align superclasses for multiple inheritence.
This fixes llvm.org/PR15179.
Before: class ColorChooserMac : public content::ColorChooser, public content::WebContentsObserver { };
After: class Co
Align superclasses for multiple inheritence.
This fixes llvm.org/PR15179.
Before: class ColorChooserMac : public content::ColorChooser, public content::WebContentsObserver { };
After: class ColorChooserMac : public content::ColorChooser, public content::WebContentsObserver { };
llvm-svn: 175147
show more ...
|
#
b9caeacd |
| 13-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Allow breaking after the return type in function declarations.
This has so far been disabled for Google style, but should be done before breaking at nested name specifiers or in template parameters.
Allow breaking after the return type in function declarations.
This has so far been disabled for Google style, but should be done before breaking at nested name specifiers or in template parameters.
Before (in Google style): template <typename T> aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa< T>::aaaaaaa() {}
After: template <typename T> aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}
llvm-svn: 175074
show more ...
|
#
525264c3 |
| 13-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix comment alignment close to the column limit.
Due to an error in one of the expressions, we used to not align comments although it would have been possible.
llvm-svn: 175068
|
#
af491072 |
| 13-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Pull search state out as class members.
Fix some comments.
llvm-svn: 175052
|
#
2ef908e4 |
| 13-Feb-2013 |
Manuel Klimek <klimek@google.com> |
An attempt to make the search algorithm easier to understand.
- clear ownership: the SpecificBumpPtrAllocator owns all StateNodes - this allows us to simplify the memoization data structure into a
An attempt to make the search algorithm easier to understand.
- clear ownership: the SpecificBumpPtrAllocator owns all StateNodes - this allows us to simplify the memoization data structure into a std::set (FIXME: figure out whether we want to use a hash based data structure). - introduces StateNode as recursive data structure, instead of using Edge and the Seen-map combined to drill through the graph - using a count to stabilize the penalty instead of relying on the container - pulled out a method to forward-apply states in the end
This leads to a ~40% runtime decrease on Nico's benchmark.
Main FiXME is that the parameter lists of some function get too long. I'd vote for either pulling the Queue etc into the Formatter proper, or creating an inner class just for the search algorithm.
llvm-svn: 175051
show more ...
|
#
2204562a |
| 12-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix bug in the adjustment to existing lines.
Before (if only the second line was reformatted): void f() {} void g() {}
After: void f() {} void g() {}
llvm-svn: 174978
|
#
29f9dea1 |
| 11-Feb-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter: Detect ObjC message expressions after 'in' in loop
Before: for (id foo in[self getStuffFor : bla]) { }
Now: for (id foo in [self getStuffFor:bla]) { }
"in" is treated as loop ke
Formatter: Detect ObjC message expressions after 'in' in loop
Before: for (id foo in[self getStuffFor : bla]) { }
Now: for (id foo in [self getStuffFor:bla]) { }
"in" is treated as loop keyword if the line starts with "for", and as a regular identifier else. To check for "in", its IdentifierInfo is handed through a few layers.
llvm-svn: 174889
show more ...
|
#
2549956e |
| 11-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Get rid of manual debug output, now that the test runner supports it.
You can run tests with -debug instead now.
llvm-svn: 174880
|
#
eef30490 |
| 11-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix invalid formatting with spaces before trailing comments.
In google style, trailing comments are separated by two spaces. This patch fixes the counting of these spaces and prevents clang-format f
Fix invalid formatting with spaces before trailing comments.
In google style, trailing comments are separated by two spaces. This patch fixes the counting of these spaces and prevents clang-format from creating a line with 81 columns.
llvm-svn: 174879
show more ...
|
#
0c13795f |
| 11-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Fixes handling of empty lines in macros.
Now correctly formats: #define A \ \ b; to #define A b;
Added the state whether an unwrapped line is a macro to the debug output.
llvm-svn: 174878
|
#
d076dcd5 |
| 08-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Fix indentation-detection at indent level 0.
This correctly formats: { a; } where { is incorrectly indented by 2, but is at level 0, when reformatting only 'a;'.
llvm-svn: 174737
|
#
b95f5450 |
| 08-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Takes the context into account when re-indenting regions.
Fixes llvm.org/PR14916.
llvm-svn: 174720
|
#
400adc64 |
| 08-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Implement a tiny expression parser to improve formatting decisions.
With this patch, the formatter introduces 'fake' parenthesis according to the operator precedence of binary operators.
Before: re
Implement a tiny expression parser to improve formatting decisions.
With this patch, the formatter introduces 'fake' parenthesis according to the operator precedence of binary operators.
Before: return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC || dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD; f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);
After: return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC || dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD; f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);
Future improvements: - Get rid of some of the hacky ways to nicely format certain constructs. - Merge this parser and the AnnotatingParser as we now have several parsers that analyze (), [], etc.
llvm-svn: 174714
show more ...
|
#
acc33666 |
| 08-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Avoid unnecessary line breaks in nested ObjC calls.
Before: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonD
Avoid unnecessary line breaks in nested ObjC calls.
Before: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType]; After: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType];
llvm-svn: 174701
show more ...
|
#
f79f935f |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix bug in the alignment of comments.
Before: const char *test[] = { // A "aaaa", // B "aaaaa", };
After: const char *test[] = { // A "aaaa", // B "aaaaa", };
llvm-svn
Fix bug in the alignment of comments.
Before: const char *test[] = { // A "aaaa", // B "aaaaa", };
After: const char *test[] = { // A "aaaa", // B "aaaaa", };
llvm-svn: 174549
show more ...
|