| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
Before: SomeType &operator=(const SomeType & S);
After: SomeType &operator=(const SomeType &S);
llvm-svn: 179270
|
|
|
|
|
|
|
| |
Before we would build huge unwrapped lines which take a long time
to optimze.
llvm-svn: 179168
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
class A {
public : // test
};
After:
class A {
public: // test
};
Also remove duplicate methods calculating properties of AnnotatedTokens
and make them members of AnnotatedTokens so that they are in a common
place.
llvm-svn: 179167
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
switch (...) {
// a
// b
// c
case first:
break;
}
After:
switch (...) {
// a
// b
// c
case first:
break;
}
llvm-svn: 179107
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Some codebases use these kinds of macros in functions, e.g. Chromium's
IPC_BEGIN_MESSAGE_MAP, IPC_BEGIN_MESSAGE_HANDLER, etc.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D645
llvm-svn: 179099
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Preserve line breaks after function-like macro usages without
semicolon, e.g.:
QQQ(xxx)
class X {
};
Reviewers: djasper, klimek
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D638
llvm-svn: 179064
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The idea is to indent according to operator precedence and pretty much
identical to how stuff would be indented with parenthesis.
Before:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;
After:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;
llvm-svn: 179049
|
|
|
|
| |
llvm-svn: 179016
|
|
|
|
| |
llvm-svn: 179015
|
|
|
|
|
|
| |
(Don't ask, this was a user request).
llvm-svn: 178888
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
bool operator<
(const aaaaaaaaaaaaaaaaaaaaa &left, const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}
After:
bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,
const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}
llvm-svn: 178887
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixed llvm.org/PR15670
Before:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
c = cccccccccccccccccccc,
d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
*c = ccccccccccccccccccc,
*d = ddddddddddddddddddd;
After:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
c = cccccccccccccccccccc, d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
*c = ccccccccccccccccccc, *d = ddddddddddddddddddd;
llvm-svn: 178860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This combines several related changes:
a) Don't break before after the variable types in for loops with a
single variable.
b) Better indent DeclStmts defining multiple variables.
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaa = aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa =
aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}
llvm-svn: 178641
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
It turns out that we don't need to store CommentsBeforeNextToken in the
line state, but rather flush them before we start parsing preprocessor
directives. This fixes wrong comment indentation in code blocks in macro calls
(the test is included).
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D617
llvm-svn: 178638
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Basically we have always special-cased the top-level statement of an
unwrapped line (the one with ParenLevel == 0) and that lead to several
inconsistencies. All added tests were formatted in a strange way, for
example:
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}
llvm-svn: 178542
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Store comments in ScopedLineState
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D609
llvm-svn: 178537
|
|
|
|
|
|
| |
Before: void * (*a)(int *, SomeType *);
After: void *(*a)(int *, SomeType *);
llvm-svn: 178474
|
|
|
|
|
|
|
|
|
| |
Comments before preprocessor directives used to be stored with InPPDirective
flag set, which prevented correct comment splitting in this case. Fixed by
flushing comments before switching on InPPDirective. Added a new test and fixed
one of the existing tests.
llvm-svn: 178261
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Insert extra new line before access specifiers.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D581
llvm-svn: 178149
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Split line comments that exceed column limit + fixed leading whitespace
handling when splitting block comments.
Reviewers: djasper, klimek
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D577
llvm-svn: 178133
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that
-foo;
can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.
llvm-svn: 177740
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
int a; // not formatted
// formatting this line only
After:
int a; // not formatted
// formatting this line only
This makes clang-format stable independent of whether the whole
file or single lines are formatted in most cases.
llvm-svn: 177739
|
|
|
|
|
|
|
|
|
| |
Otherwise, +/- and the beginning of constants can be recognized
incorrectly.
Before: #define A - 1
After: #define A -1
llvm-svn: 177725
|
|
|
|
|
|
|
|
|
|
|
| |
Apparently one needs to set LangOptions.LineComment.
Before "//* */" got reformatted to "/ /* */" as the lexer was returning
the token sequence (slash, comment). This could also lead to weird other
stuff, e.g. for people that like to using comments like:
//****************
llvm-svn: 177720
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
1. When splitting one-line block comment, use indentation and *s.
2. Remove trailing whitespace from all lines of a comment, not only the ones being splitted.
3. Add backslashes for all lines if a comment is used insed a preprocessor directive.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D557
llvm-svn: 177635
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Added support for pointers-to-members usage via .* and a few tests.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D556
llvm-svn: 177537
|
|
|
|
|
|
|
| |
clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.
llvm-svn: 177530
|
|
|
|
|
|
| |
Discovered when accidentally formatting a python file :-).
llvm-svn: 177527
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before (when only reformatting "int b"):
int a; // comment
// comment
int b;
After:
int a; // comment
// comment
int b;
This also fixes llvm.org/PR15433.
llvm-svn: 177524
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 177521
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This seems to be generally more desired.
Before:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}
After:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}
Also: Some formatting cleanup on clang-format's files.
llvm-svn: 177514
|
|
|
|
|
|
|
|
|
|
| |
Otherwise, this can become hard to read.
Before: #define A \
case 1:
After: #define A \
case 1:
llvm-svn: 177509
|
|
|
|
|
|
| |
Before: A<int * (int)>;
After: A<int *(int)>;
llvm-svn: 177505
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
switch (x) {
case 1:
// Do amazing stuff
{
g();
f();
}
}
After:
switch (x) {
case 1:
// Do amazing stuff
{
g();
f();
}
}
llvm-svn: 177420
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: This is implementation for /* */ comments only.
Reviewers: djasper, klimek
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D547
llvm-svn: 177415
|
|
|
|
|
|
|
|
| |
When annotating "lines" starting with ":", clang-format would segfault.
This could actually happen in valid code, e.g.
#define A :
llvm-svn: 177283
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang-format already prevented sequences like:
...
SomeParameter).someFunction(
...
as those are quite confusing. This failed on:
...
SomeParameter).someFunction(otherFunction(
...
Fixed in this patch.
llvm-svn: 177157
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Do this to avoid spoling nicely formatted multi-line comments (e.g.
with code examples or similar stuff).
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D544
llvm-svn: 177153
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Aligns continuation lines of multi-line comments to the base
indentation level +1:
class A {
/*
* test
*/
void f() {}
};
The first revision is work in progress. The implementation is not yet complete.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D541
llvm-svn: 177080
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The stronger binding of a string ending in :/= does not really make
sense if it is the only character.
Before:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa
<< "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
After:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "="
<< bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
llvm-svn: 177075
|
|
|
|
| |
llvm-svn: 177073
|
|
|
|
|
|
| |
Before: for (char **a = b; * a; ++a) {}
After: for (char **a = b; *a; ++a) {}
llvm-svn: 177037
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((
unused));
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
__attribute__((unused));
llvm-svn: 177034
|
|
|
|
|
|
| |
Before: int a = sizeof(int *)+ b;"
After: int a = sizeof(int *) + b;
llvm-svn: 176957
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
switch (x) {
// if 1, do f()
case 1:
f();
}
After:
switch (x) {
// if 1, do f()
case 1:
f();
}
llvm-svn: 176953
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() - aaaaaaaaa()->aaaaaa()
->aaaaa());
After:
a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() -
aaaaaaaaa()->aaaaaa()->aaaaa());
llvm-svn: 176952
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
A = new SomeType * [Length];
A = new SomeType *[Length]();
After:
A = new SomeType *[Length];
A = new SomeType *[Length]();
Small formatting cleanups with clang-format.
llvm-svn: 176936
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Handle "&&" usage as rvalue reference, added tests and fixed incorrect
tests that interfere with this feature.
http://llvm.org/bugs/show_bug.cgi?id=15051
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D531
llvm-svn: 176874
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
switch (x) {
default : {}
}
After:
switch (x) {
default: {}
}
llvm-svn: 176861
|
|
|
|
|
|
|
|
|
| |
1. We now ignore all non-default string literals, including raw
literals.
2. We do not break inside escape sequences any more.
FIXME: We still break in trigraphs.
llvm-svn: 176710
|