| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
template <typename T>
// T should be one of {A, B}.
void f() {}
After:
template <typename T>
// T should be one of {A, B}.
void f() {}
llvm-svn: 191492
|
|
|
|
|
|
| |
Patch contributed by Aaron Wishnick. Thank you!
llvm-svn: 191375
|
|
|
|
|
|
|
|
|
|
| |
Before:
size = sizeof * a;
After:
size = sizeof *a;
llvm-svn: 191139
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR17265.
Before:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif {
}
After:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif
{
}
llvm-svn: 190861
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
if () {
}
else {
}
After:
if () {
} else {
}
This fixed llvm.org/PR17262.
llvm-svn: 190855
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before (with column limit 60):
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
> aaaaa);
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);
(Not sure how that could have stayed in that long without being
detected..)
llvm-svn: 190854
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the _T() part around each fragment. This addresses http://llvm.org/PR17122
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek, rsmith
Differential Revision: http://llvm-reviews.chandlerc.com/D1640
llvm-svn: 190804
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
template <template <typename>
class Fooooooo, template <typename>
class Baaaaaaar>
struct C {};
After:
template <template <typename> class Fooooooo,
template <typename> class Baaaaaaar>
struct C {};
llvm-svn: 190747
|
|
|
|
|
|
|
|
|
|
| |
Before (even with Style.Cpp11BracedListStyle):
f(MyMap[{ composite, key }]);
After:
f(MyMap[{composite, key}]);
llvm-svn: 190678
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
enum {
Bar = Foo < int,
int > ::value
};
After:
enum {
Bar = Foo<int, int>::value
};
llvm-svn: 190674
|
|
|
|
|
|
|
|
|
| |
Before:
for (int i = 0; i* 2 < z; i *= 2) {}
After:
for (int i = 0; i * 2 < z; i *= 2) {}
llvm-svn: 190546
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
reformat() tries to determine the newline style used in the input
(either LF or CR LF), and uses it for the output. Maybe not every single case is
supported, but at least the bug described in http://llvm.org/PR17182 should be
resolved.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1643
llvm-svn: 190519
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1639
llvm-svn: 190408
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: This also unifies the handling of escaped newlines for all tokens.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1638
llvm-svn: 190405
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
typedef typeof(int(int, int)) * MyFunc;
After:
typedef typeof(int(int, int)) *MyFunc;
This fixes llvm.org/PR17178.
llvm-svn: 190401
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
This fixes various issues with mixed tabs and spaces handling, e.g.
when realigning block comments.
Reviewers: klimek, djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1608
llvm-svn: 190395
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Let clang-format consistently keep up to one empty line (configured via
FormatStyle::MaxEmptyLinesToKeep) in nested blocks, e.g. lambdas. Also,
actually format single statements in nested blocks.
Before:
DEBUG({ int i; });
DEBUG({
int i;
// an empty line here would just be removed.
int j;
});
After:
DEBUG({ int i; });
DEBUG({
int i;
int j;
});
llvm-svn: 190278
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
llvm-svn: 190209
|
|
|
|
|
|
|
|
|
| |
The explicit type specified for an enum can actually have a nested name
specifier.
This fixes llvm.org/PR17125.
llvm-svn: 190208
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
double &operator[](int i) { return 0; } int i;
After:
double &operator[](int i) { return 0; }
int i;
This fixes llvm.org/PR17134.
llvm-svn: 190207
|
|
|
|
| |
llvm-svn: 190175
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
FirstToken->WhitespaceRange.getBegin()
.getLocWithOffset(First->LastNewlineOffset);
After:
FirstToken->WhitespaceRange.getBegin().getLocWithOffset(
First->LastNewlineOffset);
Re-add logic to prevent breaking after an empty set of parentheses.
Basically it seems that calling a function without parameters is more
like navigating along the same object than it is a separate step of a
builder-type call.
We might need to extends this in future to allow "short" parameters that
e.g. are an index accessing a specific element.
llvm-svn: 190126
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) ...
After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
== 5) ...
Also precompute startsBinaryExpression() to improve performance.
llvm-svn: 190124
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes two issues:
1) The indent of a line comment was not adapted to the subsequent
statement as it would be outside of a nested block.
2) A missing DryRun flag caused actualy breaks to be inserted in
overly long comments while trying to come up with the best line
breaking decisions.
llvm-svn: 190123
|
|
|
|
| |
llvm-svn: 190075
|
|
|
|
|
|
| |
builds.
llvm-svn: 190061
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
enum X : int { A, B, C };
After:
enum X : int {
A,
B,
C
};
llvm-svn: 190054
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Count column width instead of the number of code points. This also
includes correct handling of tabs inside string literals and comments (with an
exception of multiline string literals/comments, where tabs are present before
the first escaped newline).
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1601
llvm-svn: 190052
|
|
|
|
|
|
|
|
|
|
| |
Before:
constexpr char hello [] { "hello" };
After:
constexpr char hello[]{ "hello" };
llvm-svn: 190046
|
|
|
|
|
|
| |
Mostly additional comments :-).
llvm-svn: 190042
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}
After:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}
llvm-svn: 190039
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Among other things, this enables (better) formatting lambdas and
constructs like:
MACRO({
long_statement();
long_statement_2();
},
{
long_statement();
long_statement_2();
},
{ short_statement(); }, "");
This fixes llvm.org/PR15381.
llvm-svn: 190038
|
|
|
|
|
|
|
| |
consistency of serialized form with the actual enum member names without
a prefix.
llvm-svn: 189936
|
|
|
|
| |
llvm-svn: 189933
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch makes sure we produce the right number of unwrapped lines,
a follow-up patch will make the whitespace formatting consistent.
Before:
void f() {
int i = {[operation setCompletionBlock : ^{ [self onOperationDone];
}]
}
;
}
After:
void f() {
int i = {[operation setCompletionBlock : ^{
[self onOperationDone];
}] };
}
llvm-svn: 189932
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
int c = [ &, &a, a]{
[ =, c, &d]{
return b++;
}();
}();
After:
int c = [&, &a, a] {
[=, c, &d] {
return b++;
}();
}();
llvm-svn: 189924
|
|
|
|
|
|
|
|
|
|
| |
Implements parsing of lambdas in the UnwrappedLineParser.
This introduces the correct line breaks; the formatting of
lambda captures are still incorrect, and the braces are also
still formatted as if they were braced init lists instead of
blocks.
llvm-svn: 189818
|
|
|
|
|
|
| |
messages.
llvm-svn: 189765
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
and comments.
Summary:
Store first and last newline position in the token text for string literals and
comments to avoid doing .find('\n') for each possible solution.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1556
llvm-svn: 189758
|
|
|
|
|
|
|
|
|
| |
Before, constructs like:
using A::operator+;
caused a segfault. This fixes llvm.org/PR17050.
llvm-svn: 189749
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name
After:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name
llvm-svn: 189743
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Almost by accident, clang-format seems to be able to format protocol
buffer definitions (https://code.google.com/p/protobuf/).
The only change is that a space is required between numeric constants
and opening square brackets (for default values). While this might in
theory be used for array subscripts (int val = 4[MyArray]), I have not
seen this pattern in practice much. If this is wrong, we can make this
smarter in the future.
llvm-svn: 189663
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
namespace n {
enum Type {
One,
Two, // missing };
int i;
} void g() {
}
After:
namespace n {
enum Type {
One,
Two, // missing };
int i;
}
void g() {}
llvm-svn: 189662
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));
After:
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));
This was overlooked when interducing the new builder-type call
detection in r189337. Also, some minor reorganization of a test.
llvm-svn: 189658
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While this looks kind of nice, it wastes horizontal space and does not
seem to be common in the LLVM codebase.
Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
llvm-svn: 189657
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()->aaaaaaaaaaaaaae(
0)->aaaaaaaaaaaaaaa();
After:
aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()
->aaaaaaaaaaaaaae(0)
->aaaaaaaaaaaaaaa();
llvm-svn: 189655
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
literals).
Summary:
Calculate characters in the first and the last line correctly so that
we only break before the literal when needed.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1544
llvm-svn: 189595
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now count the original token's column directly when lexing the
tokens, where we already have all knowledge about where lines start.
Before this patch, formatting:
void f() {
\tg();
\th();
}
would incorrectly count the \t's as 1 character if only the line
containing h() was reformatted, and thus indent h() at offset 1.
llvm-svn: 189585
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two changes:
* Don't add an extra penalty on breaking the same token multiple times.
Generally, we should prefer not to break, but once we break, the
normal line breaking penalties apply.
* Slightly increase the penalty for breaking comments. In general, the
author has put some thought into how to break the comment and we
should not overwrite this unnecessarily.
With a 40-column column limit, formatting
aaaaaa("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa");
Leads to:
Before:
aaaaaa(
"aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa");
After:
aaaaaa("aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa");
llvm-svn: 189466
|
|
|
|
|
|
|
|
|
| |
The code leading to a segfault was:
#pragma omp threadprivate(y)), // long comment leading to a line break
This fixes llvm.org/PR16513.
llvm-svn: 189460
|