#
34d15151 |
| 28-May-2013 |
Manuel Klimek <klimek@google.com> |
Disable tab expansion when counting the columns in block comments.
To fully support this, we also need to expand tabs in the text before the block comment. This patch breaks indentation when there w
Disable tab expansion when counting the columns in block comments.
To fully support this, we also need to expand tabs in the text before the block comment. This patch breaks indentation when there was a non-standard mixture of spaces and tabs used for indentation, but fixes a regression in the simple case: { /* * Comment. */ int i; } Is now formatted correctly, if there were tabs used for indentation before.
llvm-svn: 182760
show more ...
|
#
281dcbe0 |
| 28-May-2013 |
Manuel Klimek <klimek@google.com> |
Fixes indentation of empty lines in block comments.
Block comment indentation of empty lines regressed, as we did not have a test for it. /* Comment with... * * empty line. */ is now formatted
Fixes indentation of empty lines in block comments.
Block comment indentation of empty lines regressed, as we did not have a test for it. /* Comment with... * * empty line. */ is now formatted correctly again.
llvm-svn: 182757
show more ...
|
#
3719428c |
| 28-May-2013 |
Daniel Jasper <djasper@google.com> |
Clean up formatting of function types.
Before: int (*func)(void*); void f() { int(*func)(void*); }
After (consistent space after "int"): int (*func)(void*); void f() { int (*func)(void*); }
llvm-s
Clean up formatting of function types.
Before: int (*func)(void*); void f() { int(*func)(void*); }
After (consistent space after "int"): int (*func)(void*); void f() { int (*func)(void*); }
llvm-svn: 182756
show more ...
|
#
9f82df29 |
| 28-May-2013 |
Daniel Jasper <djasper@google.com> |
Fix formatting of expressions containing ">>".
This gets turned into two ">" operators at the beginning in order to simplify template parameter handling. Thus, we need a special case to handle those
Fix formatting of expressions containing ">>".
This gets turned into two ">" operators at the beginning in order to simplify template parameter handling. Thus, we need a special case to handle those two binary operators correctly.
With this patch, clang-format can now correctly handle cases like: aaaaaa = aaaaaaa(aaaaaaa, // break aaaaaa) >> bbbbbb;
llvm-svn: 182754
show more ...
|
#
1eff9080 |
| 27-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of templates.
Before: A < int&& > a; After: A<int &&> a;
Also remove obsolete FIXMEs.
llvm-svn: 182741
|
#
9043c74f |
| 27-May-2013 |
Manuel Klimek <klimek@google.com> |
Major refactoring of BreakableToken.
Unify handling of whitespace when breaking protruding tokens with other whitespace replacements.
As a side effect, the BreakableToken structure changed signific
Major refactoring of BreakableToken.
Unify handling of whitespace when breaking protruding tokens with other whitespace replacements.
As a side effect, the BreakableToken structure changed significantly: - have a common base class for single-line breakable tokens, as they are much more similar - revamp handling of multi-line comments; we now calculate the information about lines in multi-line comments similar to normal tokens, and always issue replacements
As a result, we were able to get rid of special casing of trailing whitespace deletion for comments in the whitespace manager and the BreakableToken and fixed bugs related to tab handling and escaped newlines.
llvm-svn: 182738
show more ...
|
#
7b27a10b |
| 27-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve indentation of assignments.
Before: unsigned OriginalStartColumn = SourceMgr.getSpellingColumnNumber( Current.FormatTok.getStartOfNonWhitespace()) - 1;
Af
Improve indentation of assignments.
Before: unsigned OriginalStartColumn = SourceMgr.getSpellingColumnNumber( Current.FormatTok.getStartOfNonWhitespace()) - 1;
After: unsigned OriginalStartColumn = SourceMgr.getSpellingColumnNumber( Current.FormatTok.getStartOfNonWhitespace()) - 1;
llvm-svn: 182733
show more ...
|
#
32a796bc |
| 27-May-2013 |
Daniel Jasper <djasper@google.com> |
Fix hacky way of preventing a certain type of line break.
In general, we like to avoid line breaks like:
... SomeParameter, OtherParameter).DoSomething( ...
as they tend to make code really
Fix hacky way of preventing a certain type of line break.
In general, we like to avoid line breaks like:
... SomeParameter, OtherParameter).DoSomething( ...
as they tend to make code really hard to read (how would you even indent the next line?). Previously we have implemented this in a hacky way, which has now shown to lead to problems. This fixes a few weird looking formattings, such as:
Before: aaaaa( aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaa(aaaaa), aaaaaaaaaaaaaaaaaaaaa); After: aaaaa(aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa).aaaaa(aaaaa), aaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 182731
show more ...
|
#
ced7d41b |
| 26-May-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter/ObjC: In dictionary literals, break after ':', not before it.
Before: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, };
Now: @{ NSFontAttributeNa
Formatter/ObjC: In dictionary literals, break after ':', not before it.
Before: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, };
Now: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, };
':'s in dictionary literals (and the corresponding {}s) are now marked as TT_ObjCDictLiteral too, which makes further improvements to dict literal layout possible.
llvm-svn: 182716
show more ...
|
#
f2e02123 |
| 24-May-2013 |
Alexander Kornienko <alexfh@google.com> |
Ignore contents of #if 0 blocks.
Summary: Added stack of preprocessor branching directives, and ignore all tokens inside #if 0 except for preprocessor directives.
Reviewers: klimek, djasper
Review
Ignore contents of #if 0 blocks.
Summary: Added stack of preprocessor branching directives, and ignore all tokens inside #if 0 except for preprocessor directives.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D855
llvm-svn: 182658
show more ...
|
#
f632f692 |
| 23-May-2013 |
Daniel Jasper <djasper@google.com> |
More tests and a fix for braced init lists.
Before: f(new vector<int> { 1, 2, 3 }); After: f(new vector<int>{ 1, 2, 3 }); llvm-svn: 182614
|
#
75ef31f6 |
| 23-May-2013 |
Manuel Klimek <klimek@google.com> |
Fix aligning of comments.
Previously we started sequences to align for single line comments when the previous line had a trailing comment, but the sequence was broken for other reasons.
Now we re-f
Fix aligning of comments.
Previously we started sequences to align for single line comments when the previous line had a trailing comment, but the sequence was broken for other reasons.
Now we re-format: // a // b f(); // c to: // a // b f(); // c
llvm-svn: 182608
show more ...
|
#
b27375fc |
| 23-May-2013 |
Manuel Klimek <klimek@google.com> |
Fix aligning of comments that are at the start of the line.
Now correctly leaves: f(); // comment // comment g(); // comment ... alone if the middle comment was aligned with g() before formatting.
Fix aligning of comments that are at the start of the line.
Now correctly leaves: f(); // comment // comment g(); // comment ... alone if the middle comment was aligned with g() before formatting.
llvm-svn: 182605
show more ...
|
#
d4432394 |
| 23-May-2013 |
Daniel Jasper <djasper@google.com> |
Increase test coverage for braced init lists.
Also fix a minor bug for constructor initializers with braced init lists.
llvm-svn: 182601
|
#
5bd0b9e5 |
| 23-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of braced lists.
Before: vector<int> v{ -1}; After: vector<int> v{-1}; llvm-svn: 182597
|
#
c573080d |
| 23-May-2013 |
Manuel Klimek <klimek@google.com> |
Stop aligning trailing comments which are aligned with the next line.
Previously we would align: f(); // comment // other comment g();
Even if // other comment was at the start of the line. No
Stop aligning trailing comments which are aligned with the next line.
Previously we would align: f(); // comment // other comment g();
Even if // other comment was at the start of the line. Now we do not align trailing comments if they have been already aligned correctly with the next line.
Thus, f(); // comment // other comment g(); will not be changed, while: f(); // comment // other commment g(); will lead to the two trailing comments being aligned.
llvm-svn: 182577
show more ...
|
#
5c24cca0 |
| 23-May-2013 |
Manuel Klimek <klimek@google.com> |
Use a SourceRange for the whitespace location in FormatToken.
Replaces the use of WhitespaceStart + WhitspaceLength. This made a bug in the formatter obvous where we would incorrectly calculate the
Use a SourceRange for the whitespace location in FormatToken.
Replaces the use of WhitespaceStart + WhitspaceLength. This made a bug in the formatter obvous where we would incorrectly calculate the next column.
FIXME: There's a similar bug left regarding TokenLength. We should probably also move to have a TokenRange instead.
llvm-svn: 182572
show more ...
|
#
e5777d25 |
| 23-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of braced lists.
Before: vector<int> x { 1, 2, 3 }; After: vector<int> x{ 1, 2, 3 };
Also add a style option to remove the spaces inside braced lists, so that the above becomes:
Improve formatting of braced lists.
Before: vector<int> x { 1, 2, 3 }; After: vector<int> x{ 1, 2, 3 };
Also add a style option to remove the spaces inside braced lists, so that the above becomes: std::vector<int> v{1, 2, 3};
llvm-svn: 182570
show more ...
|
#
ab41991c |
| 23-May-2013 |
Manuel Klimek <klimek@google.com> |
Expand parsing of braced init lists.
Allows formatting of C++11 braced init list constructs, like: vector<int> v { 1, 2, 3 }; f({ 1, 2 });
This involves some changes of how tokens are handled in th
Expand parsing of braced init lists.
Allows formatting of C++11 braced init list constructs, like: vector<int> v { 1, 2, 3 }; f({ 1, 2 });
This involves some changes of how tokens are handled in the UnwrappedLineFormatter. Note that we have a plan to evolve the design of the token flow into one where we create all tokens up-front and then annotate them in the various layers (as we currently already have to create all tokens at once anyway, the current abstraction does not help). Thus, this introduces FIXMEs towards that goal.
llvm-svn: 182568
show more ...
|
Revision tags: llvmorg-3.3.0-rc2 |
|
#
4fe43002 |
| 22-May-2013 |
Manuel Klimek <klimek@google.com> |
Makes whitespace management more consistent.
Instead of selectively storing some changes and directly generating replacements for others, we now notify the WhitespaceManager of the whitespace before
Makes whitespace management more consistent.
Instead of selectively storing some changes and directly generating replacements for others, we now notify the WhitespaceManager of the whitespace before every token (and optionally with more changes inside tokens).
Then, we run over all whitespace in the very end in original source order, where we have all information available to correctly align comments and escaped newlines.
The future direction is to pull more of the comment alignment implementation that is now in the BreakableToken into the WhitespaceManager.
This fixes a bug when aligning comments or escaped newlines in unwrapped lines that are handled out of order: #define A \ f({ \ g(); \ }); ... now gets correctly layouted.
llvm-svn: 182467
show more ...
|
#
a4c571cd |
| 22-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve clang-format's stream formatting.
clang-format was a bit too aggressive when trying to keep labels and values on the same line.
Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
Improve clang-format's stream formatting.
clang-format was a bit too aggressive when trying to keep labels and values on the same line.
Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 182458
show more ...
|
#
53e8d854 |
| 22-May-2013 |
Daniel Jasper <djasper@google.com> |
Fix function declaration behavior.
This only affects styles that prevent bin packing. There, a break after a template declaration also forced a line break after the function name.
Before: template
Fix function declaration behavior.
This only affects styles that prevent bin packing. There, a break after a template declaration also forced a line break after the function name.
Before: template <class SomeType, class SomeOtherType> SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}
After: template <class SomeType, class SomeOtherType> SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}
This fixes llvm.org/PR16072.
llvm-svn: 182457
show more ...
|
#
13c37b34 |
| 22-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve handling of trailing 'const'.
Reduce the preference for breaking before a trailing 'const' according to review comments on r182362.
llvm-svn: 182455
|
#
f8114cf6 |
| 22-May-2013 |
Daniel Jasper <djasper@google.com> |
Cut-off clang-format analysis.
If clang-format is confronted with long and deeply nested lines (e.g. complex static initializers or function calls), it can currently try too hard to find the optimal
Cut-off clang-format analysis.
If clang-format is confronted with long and deeply nested lines (e.g. complex static initializers or function calls), it can currently try too hard to find the optimal solution and never finish. The reason is that the memoization does not work effectively for deeply nested lines.
This patch removes an earlier workaround and instead opts for accepting a non-optimal solution in rare cases. However, it only does so only in cases where it would have to analyze an excessive number of states (currently set to 10000 - the most complex line in Format.cpp requires ~800 states) so this should not change the behavior in a relevant way.
llvm-svn: 182449
show more ...
|
#
5be31f72 |
| 21-May-2013 |
Daniel Jasper <djasper@google.com> |
Allow breaking before a trailing const.
Before: void someLongFunction( int someLongParameter) const;
After: void someLongFunction(int someLongParameter) const;
Also slightly cleanup tests.
Allow breaking before a trailing const.
Before: void someLongFunction( int someLongParameter) const;
After: void someLongFunction(int someLongParameter) const;
Also slightly cleanup tests.
llvm-svn: 182362
show more ...
|