| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
| |
Before, clang-format would simply eat these as they were recognized as
whitespace. With this patch, they are mostly left alone.
llvm-svn: 186454
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.
This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.
llvm-svn: 186433
|
|
|
|
|
|
|
|
|
|
| |
This fixes an incorrect detection that led to a formatting error.
Before:
some_var = function (*some_pointer_var)[0];
After:
some_var = function(*some_pointer_var)[0];
llvm-svn: 186402
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
#define x ((int) - 1)
#define p(q) ((int *) & q)
After:
#define x ((int)-1)
#define p(q) ((int *)&q)
llvm-svn: 186324
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixed a test that by now passed for the wrong reason.
Before:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
Also reformatted Format.cpp with the latest changes (1 formatting fix
and 1 layout change of a <<-chain).
llvm-svn: 186322
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;
After:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;
llvm-svn: 186320
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang-format used to treat array subscript expressions much like
function call (just replacing () with []). However, this is not really
appropriate especially for expressions with multiple subscripts.
Although it might seem counter-intuitive, the most consistent solution
seems to be to always (if necessary) break before a square bracket,
never after it. Also, multiple subscripts of the same expression should
be aligned if they are on subsequent lines.
Before:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;
After:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;
llvm-svn: 186153
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(if they are not function-like).
Before:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;
After:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;
llvm-svn: 186117
|
|
|
|
|
|
|
|
|
|
|
|
| |
Trailing return types can only occur in declaration contexts.
Before:
void f() { auto a = b -> c(); }
After:
void f() { auto a = b->c(); }
llvm-svn: 186087
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa);
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GUARDED_BY(aaaaaaaaaaaa);
llvm-svn: 186077
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is not activated for any style, might change or go away
completely.
For those that want to play around with it, set
ExperimentalAutoDetectBinPacking to true.
clang-format will then:
Look at whether function calls/declarations/definitions are currently
formatted with one parameter per line (on a case-by-case basis). If so,
clang-format will avoid bin-packing the parameters. If all parameters
are on one line (thus that line is "inconclusive"), clang-format will
make the choice dependent on whether there are other bin-packed
calls/declarations in the same file.
The reason for this change is that bin-packing in some situations can be
really bad and an author might opt to put one parameter on each line. If
the author does that, he might want clang-format not to mess with that.
If the author is unhappy with the one-per-line formatting, clang-format
can easily be convinced to bin-pack by putting any two parameters on the
same line.
llvm-svn: 186003
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR15170.
For now, the basic formatting rules are (based on the C++11 standard):
* Surround the "->" with spaces.
* Break before "->".
Also fix typo.
llvm-svn: 185938
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR16328 (at least partially).
Before:
SomeLoooooooooooooooooooooooooooooogType operator<<(
const SomeLooooooooogType &a, const SomeLooooooooogType &b);
After:
SomeLoooooooooooooooooooooooooooooogType
operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b);
llvm-svn: 185908
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR16534.
Before:
aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION;
After:
aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;
llvm-svn: 185828
|
|
|
|
| |
llvm-svn: 185823
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
T **t = new T * ;
T **q = new T * ();
After:
T **t = new T *;
T **q = new T *();
llvm-svn: 185699
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Additionally, allow breaking after c-style casts, but with a high
penalty.
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (
aaaaaaaaaaaaaaaaa *)bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (aaaaaaaaaaaaaaaaa *)
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
This fixes llvm.org/PR16049.
llvm-svn: 185685
|
|
|
|
| |
llvm-svn: 185640
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Always breaking before multiline strings can help format complex
expressions containing multiline strings more consistently, and avoid consuming
too much horizontal space.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1097
llvm-svn: 185622
|
|
|
|
|
|
|
|
|
|
|
| |
Before (exceeding the column limit):
LoooooooooooooooooooooooooooooooooooooooongType const LoooooooooooooooooooooooooooooooooooooooongVariable;
After:
LoooooooooooooooooooooooooooooooooooooooongType const
LoooooooooooooooooooooooooooooooooooooooongVariable;
llvm-svn: 185418
|
|
|
|
|
|
|
|
|
|
|
| |
Before (for styles where the pointer binds to the type):
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts* ... ts) {}
After:
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts*... ts) {}
llvm-svn: 185321
|
|
|
|
|
|
|
|
|
|
| |
Before: void f(int */* unused */) {}
After: void f(int * /* unused */) {}
The previous version seems to be valid C++ code but confuses many syntax
highlighters.
llvm-svn: 185320
|
|
|
|
| |
llvm-svn: 185301
|
|
|
|
| |
llvm-svn: 184896
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before: f(a, b, /*doFoo=*/ false);
Now: f(a, b, /*doFoo=*/false);
This style is a lot more common:
$ ack -H '=\*\/\w' lib | wc -l
1281
$ ack -H '=\*\/ \w' lib | wc -l
70
llvm-svn: 184894
|
|
|
|
| |
llvm-svn: 184804
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
indentation of an expression after a line break.
Summary:
E.g. the second line in
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b; //
is indented 4 characters more than in
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b;
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D984
llvm-svn: 184078
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Basically, don't special-case line comments in this regard. And fixed
an incorrect test, that relied on the wrong behavior.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D962
llvm-svn: 183851
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Introduced two new style parameters: PenaltyBreakComment and
PenaltyBreakString. Add penalty for each character of a breakable token beyond
the column limit (this relates mainly to comments, as they are broken only on
whitespace). Tuned PenaltyBreakComment to prefer comment breaking over breaking
inside most binary expressions.
Fixed a bug that prevented *, & and && from being considered TT_BinaryOperator
in the presense of adjacent comments.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D933
llvm-svn: 183530
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, clang-format would happily move a trailing block comment to a
new line, which normally changes the perceived binding of that comment.
E.g., it would move:
void f() { /* comment */
...
}
to:
void f() {
/* comment */
...
}
llvm-svn: 183420
|
|
|
|
|
|
|
|
| |
The leading "}" in the construct "} else if (..) {" was confusing the
expression parser. Thus, no fake parentheses were generated and the
indentation was broken in some cases.
llvm-svn: 183393
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
return (my_int) aaaa;
template <> void f<int>(int i)SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa)"aaaa");
After:
return (my_int)aaaa;
template <> void f<int>(int i) SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa) "aaaa");
llvm-svn: 183389
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Detect if the file is valid UTF-8, and if this is the case, count code
points instead of just using number of bytes in all (hopefully) places, where
number of columns is needed. In particular, use the new
FormatToken.CodePointCount instead of TokenLength where appropriate.
Changed BreakableToken implementations to respect utf-8 character boundaries
when in utf-8 mode.
Reviewers: klimek, djasper
Reviewed By: djasper
CC: cfe-commits, rsmith, gribozavr
Differential Revision: http://llvm-reviews.chandlerc.com/D918
llvm-svn: 183312
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These lines almost never aid readability.
Before:
void f() {
int i; // some variable
}
After:
void f() {
int i; // some variable
}
llvm-svn: 183112
|
|
|
|
|
|
| |
Before: return a<b &&c> d;
After: return a < b && c > d;
llvm-svn: 183077
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
x[(uint8) y];
x = (uint8) y;
void f() { x = (uint8) y; }
#define AA(X) sizeof(((X *) NULL)->a)
After:
x[(uint8)y];
x = (uint8)y;
void f() { x = (uint8)y; }
#define AA(X) sizeof(((X *)NULL)->a)
llvm-svn: 183014
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;
After:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;
llvm-svn: 183007
|
|
|
|
|
|
|
|
|
|
| |
Gets rid of AnnotatedToken, putting everything into FormatToken.
FormatTokens are created once, and only referenced by pointer. This
enables multiple future features, like having tokens shared between
multiple UnwrappedLines (while there's still work to do to fully enable
that).
llvm-svn: 182859
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With option enabled (e.g. in Google-style):
template <typename T>
void f() {}
With option disabled:
template <typename T> void f() {}
Enabling this for Google-style and Chromium-style, not sure which other
styles would prefer that.
llvm-svn: 182849
|
|
|
|
|
|
|
|
|
| |
Before: f( (*PointerToArray)[10]);
After: f((*PointerToArray)[10]);
This fixes llvm.org/PR16163
llvm-svn: 182777
|
|
|
|
|
|
| |
The FormatToken is now not copyable any more.
llvm-svn: 182772
|
|
|
|
| |
llvm-svn: 182767
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
Before: A < int&& > a;
After: A<int &&> a;
Also remove obsolete FIXMEs.
llvm-svn: 182741
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
Before: f(new vector<int> { 1, 2, 3 });
After: f(new vector<int>{ 1, 2, 3 });
llvm-svn: 182614
|
|
|
|
|
|
| |
Before: vector<int> v{ -1};
After: vector<int> v{-1};
llvm-svn: 182597
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|