#
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 ...
|
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 ...
|
#
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 ...
|
#
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 ...
|
#
06e00334 |
| 20-May-2013 |
Alexander Kornienko <alexfh@google.com> |
Minor fix: don't crash on empty configuration file, consider empty configuration files invalid.
llvm-svn: 182290
|
#
006b5c89 |
| 19-May-2013 |
Alexander Kornienko <alexfh@google.com> |
Clang-format: allow -style="{yaml/json}" on command line
Summary: + improved handling of default style and predefined styles.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Diffe
Clang-format: allow -style="{yaml/json}" on command line
Summary: + improved handling of default style and predefined styles.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D813
llvm-svn: 182205
show more ...
|
#
473c62c4 |
| 17-May-2013 |
Daniel Jasper <djasper@google.com> |
Slightly modify the formatting rules for braced lists.
Basically, the new rule is: The opening "{" always has to be on the same line as the first element if the braced list is nested (e.g. in anothe
Slightly modify the formatting rules for braced lists.
Basically, the new rule is: The opening "{" always has to be on the same line as the first element if the braced list is nested (e.g. in another braced list or in a function).
The solution that clang-format produces almost always adheres to this rule anyway and this makes clang-format significantly faster for larger lists. Added a test cases for the only exception I could find (which doesn't seem to be very important at first sight).
llvm-svn: 182082
show more ...
|
#
8bb99e89 |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Don't insert a break into include lines with trailing comments.
llvm-svn: 182003
|
#
3a685df7 |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Add option to put short loops on a single line.
This enables things like:
for (int &v : vec) v *= 2;
Enabled for Google style.
llvm-svn: 182000
|
#
ec04c0db |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Add a more convenient interface to use clang-format.
It turns out that several implementations go through the trouble of setting up a SourceManager and Lexer and abstracting this into a function mak
Add a more convenient interface to use clang-format.
It turns out that several implementations go through the trouble of setting up a SourceManager and Lexer and abstracting this into a function makes usage easier.
Also abstracts SourceManager-independent ranges out of tooling::Refactoring and provides a convenience function to create them from line ranges.
llvm-svn: 181997
show more ...
|
#
f9eb9b18 |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Comments should not prevent single-line functions.
Before: void f() {} void g() { } // comment
After: void f() {} void g() {} // comment
llvm-svn: 181996
|
#
7dd22c51 |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Add back accidentally deleted line and add test for it.
Before: f("a", "b" "c"); After: f("a", "b" "c");
llvm-svn: 181980
|
#
abca58c9 |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Don't put short namespace on a single line.
Before: namespace abc { class SomeClass; } namespace def { void someFunction() {} }
After: namespace abc { class Def; } namespace def { void someFunction
Don't put short namespace on a single line.
Before: namespace abc { class SomeClass; } namespace def { void someFunction() {} }
After: namespace abc { class Def; } namespace def { void someFunction() {} }
Rationale: a) Having anything other than forward declaration on the same line as a namespace looks confusing. b) Formatting namespace-forward-declaration-combinations different from other stuff is inconsistent. c) Wasting vertical space close to such forward declarations really does not affect readability.
llvm-svn: 181887
show more ...
|
#
c6fbc219 |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Break function declarations after multi-line return types.
Before: template <typename A> SomeLoooooooooooooooooooooongType< typename some_namespace::SomeOtherType<A>::Type> Function() {}
After:
Break function declarations after multi-line return types.
Before: template <typename A> SomeLoooooooooooooooooooooongType< typename some_namespace::SomeOtherType<A>::Type> Function() {}
After: template <typename A> SomeLoooooooooooooooooooooongType< typename some_namespace::SomeOtherType<A>::Type> Function() {}
llvm-svn: 181877
show more ...
|
#
00aca707 |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Don't merge one-line functions in weird brace styles.
llvm-svn: 181872
|
#
d2ae41a7 |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Remove diagnostics from clang-format.
We only ever implemented one and that one is not actually all that helpful (e.g. gets incorrectly triggered by macros).
llvm-svn: 181871
|
#
571f1af0 |
| 14-May-2013 |
Daniel Jasper <djasper@google.com> |
Fix expression breaking for one-parameter-per-line styles.
Before: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaa
Fix expression breaking for one-parameter-per-line styles.
Before: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} After: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
llvm-svn: 181828
show more ...
|
#
cdd0662b |
| 14-May-2013 |
Daniel Jasper <djasper@google.com> |
Correctly determine ranges for clang-format.
We have been assuming that CharSourceRange::getTokenRange() by itself expands a range until the end of a token, but in fact it only sets IsTokenRange to
Correctly determine ranges for clang-format.
We have been assuming that CharSourceRange::getTokenRange() by itself expands a range until the end of a token, but in fact it only sets IsTokenRange to true. Thus, we have so far only considered the first character of the last token to belong to an unwrapped line. This did not really manifest in symptoms as all edit integrations expand ranges to fully lines.
llvm-svn: 181778
show more ...
|
#
12f9d8ef |
| 14-May-2013 |
Daniel Jasper <djasper@google.com> |
Fix clang-format bug in unwrapped-line merging.
Before (in styles that allow it), clang-format would not merge an if statement onto a single line, if only the second line was format (e.g. in an edit
Fix clang-format bug in unwrapped-line merging.
Before (in styles that allow it), clang-format would not merge an if statement onto a single line, if only the second line was format (e.g. in an editor integration):
if (a) return; // clang-format invoked on this line.
With this patch, this gets properly merged to:
if (a) return; // ...
llvm-svn: 181770
show more ...
|
#
5ecb5fd7 |
| 14-May-2013 |
Manuel Klimek <klimek@google.com> |
Implement string literal breaking on unbreakable token sequences.
This fixes indentation where there are for example multiple closing parentheses after a string literal, and where those parentheses
Implement string literal breaking on unbreakable token sequences.
This fixes indentation where there are for example multiple closing parentheses after a string literal, and where those parentheses run over the end of the line.
During testing this revealed a bug in the implementation of breakProtrudingToken: we don't want to change the state if we didn't actually do anything.
llvm-svn: 181767
show more ...
|
#
47a04442 |
| 13-May-2013 |
Daniel Jasper <djasper@google.com> |
Align a multiline string literal with the first part.
Before: #define A(X) \ "aaaaa" #X "bbbbbb" \ "ccccc"
After: #define A(X) \ "aaaaa" #X "bbbbbb" \
Align a multiline string literal with the first part.
Before: #define A(X) \ "aaaaa" #X "bbbbbb" \ "ccccc"
After: #define A(X) \ "aaaaa" #X "bbbbbb" \ "ccccc"
llvm-svn: 181732
show more ...
|
#
9a38ec26 |
| 13-May-2013 |
Alexander Kornienko <alexfh@google.com> |
A better version of r181699: use raw_string_ostream.str() instead of manually calling .flush().
llvm-svn: 181702
|
#
a8eb9149 |
| 13-May-2013 |
Manuel Klimek <klimek@google.com> |
Implements brace breaking styles.
We now support "Linux" and "Stroustrup" brace breaking styles, which gets us one step closer to support formatting WebKit, KDE & Linux code.
Linux brace breaking s
Implements brace breaking styles.
We now support "Linux" and "Stroustrup" brace breaking styles, which gets us one step closer to support formatting WebKit, KDE & Linux code.
Linux brace breaking style: namespace a { class A { void f() { if (x) { f(); } else { g(); } } } }
Stroustrup brace breaking style: namespace a { class A { void f() { if (x) { f(); } else { g(); } } } }
llvm-svn: 181700
show more ...
|
#
31f75e3f |
| 13-May-2013 |
Alexander Kornienko <alexfh@google.com> |
Fixes [Bug 15960] YAMLTraits doesn't roundtrip on Windows. Thanks to Kim Gräsman for help!
llvm-svn: 181699
|