#
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 ...
|
#
9271650e |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Add additional test-case for one-line-function.
This ensures that we format: void longFunctionName { } // long comment here
And not: void longFunctionName {} // long comment here
As requested in p
Add additional test-case for one-line-function.
This ensures that we format: void longFunctionName { } // long comment here
And not: void longFunctionName {} // long comment here
As requested in post-commit-review.
llvm-svn: 182024
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
|
#
997af660 |
| 16-May-2013 |
Daniel Jasper <djasper@google.com> |
Add config parsing test for new parameter.
llvm-svn: 182001
|
#
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 ...
|
#
6f05e59f |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve recognition of template definitions.
In the long run, this will probably be better fixed by a proper expression parser..
Before: template <typename F> Matcher(const Matcher<F> & Other,
Improve recognition of template definitions.
In the long run, this will probably be better fixed by a proper expression parser..
Before: template <typename F> Matcher(const Matcher<F> & Other, typename enable_if_c < is_base_of<F, T>::value && !is_same<F, T>::value > ::type * = 0) : Implementation(new ImplicitCastMatcher<F>(Other)) {}
After: template <typename F> Matcher(const Matcher<F> & Other, typename enable_if_c<is_base_of<F, T>::value && !is_same<F, T>::value>::type * = 0) : Implementation(new ImplicitCastMatcher<F>(Other)) {}
llvm-svn: 181884
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
|
#
5dad58e9 |
| 15-May-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of function types.
The function type detection in r181438 and r181764 detected function types too eagerly. This led to inconsistent formatting of inline assembly and (together wit
Improve formatting of function types.
The function type detection in r181438 and r181764 detected function types too eagerly. This led to inconsistent formatting of inline assembly and (together with r181687) to an incorrect formatting of calls in macros.
Before: #define DEREF_AND_CALL_F(parameter) f (*parameter) After: #define DEREF_AND_CALL_F(parameter) f(*parameter) llvm-svn: 181870
show more ...
|
#
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 ...
|
#
abc34214 |
| 14-May-2013 |
Daniel Jasper <djasper@google.com> |
Don't format sizeof/alignof as function types.
Before: A<sizeof (*x)> a; After: A<sizeof(*x)> a; llvm-svn: 181764
|
#
76aca647 |
| 14-May-2013 |
Patrik Hagglund <patrik.h.hagglund@ericsson.com> |
Replace EXPECT_EQ with EXPECT_FALSE to avoid gcc warning [-Wconversion-null], introduced in r181326.
llvm-svn: 181761
|
#
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 ...
|
#
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 ...
|
#
b9eae4c1 |
| 13-May-2013 |
Manuel Klimek <klimek@google.com> |
Implements UseTab for clang-format.
This is required for kernel linux kernel style formatting.
llvm-svn: 181693
|
#
cc3044cf |
| 13-May-2013 |
Daniel Jasper <djasper@google.com> |
Further improve optimization for nested calls.
Fake parentheses (i.e. emulated parentheses used to correctly handle binary expressions) used to prevent the optimization implemented in r180264.
llvm
Further improve optimization for nested calls.
Fake parentheses (i.e. emulated parentheses used to correctly handle binary expressions) used to prevent the optimization implemented in r180264.
llvm-svn: 181692
show more ...
|