| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
| |
Before:
int count = set<int> { f(), g(), h() }
.size();
After:
int count = set<int>{f(), g(), h()}.size();
llvm-svn: 195417
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
The AllowShortFunctionsOnASingleLine option now controls short function
body placement on a single line independent of the BreakBeforeBraces option.
Updated tests using BreakBeforeBraces other than BS_Attach.
Addresses http://llvm.org/PR17888
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2230
llvm-svn: 195256
|
|
|
|
|
|
|
|
|
|
| |
If we run into the second preprocessor branch chain, the first branch
chain might have already set the maximum branch count on that level to
something > 0.
Fixes PR17645.
llvm-svn: 193153
|
|
|
|
|
|
|
|
| |
While it is mostly a user error to have the extra semicolon,
formatting it graciously will correctly format in the cases
where we do not fully understand the code (macros).
llvm-svn: 192543
|
|
|
|
| |
llvm-svn: 192535
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now correctly format:
void SomeFunction(int param1,
#ifdef X
NoTemplate param2,
#else
template <
#ifdef A
MyType<Some> >
#else
Type1, Type2>
#endif
param2,
#endif
param3) {
f();
}
llvm-svn: 192503
|
|
|
|
| |
llvm-svn: 192094
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
builds.
llvm-svn: 190061
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
enum X : int { A, B, C };
After:
enum X : int {
A,
B,
C
};
llvm-svn: 190054
|
|
|
|
|
|
|
|
|
|
| |
Before:
constexpr char hello [] { "hello" };
After:
constexpr char hello[]{ "hello" };
llvm-svn: 190046
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In
@implementation ObjcClass
- (void)method;
{
}
@end
the ObjC compiler seems to accept the superfluous comma after "method",
but clang-format used to assert on the subsequent "{".
This fixes llvm.org/PR16604.
llvm-svn: 189453
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
std::this_thread::sleep_for(std::chrono::nanoseconds{
std::chrono::seconds { 1 }
} /
5);
After:
std::this_thread::sleep_for(
std::chrono::nanoseconds{ std::chrono::seconds{ 1 } } / 5);
This fixes llvm.org/PR16554.
llvm-svn: 189451
|
|
|
|
|
|
| |
Patch by Joe Hermaszewski. Thank you!
llvm-svn: 188794
|
|
|
|
|
|
|
|
|
|
|
| |
In particular, left braces after an enum declaration now occur on their
own line. Further, when short ifs/whiles are allowed these no longer
cause the left brace to be on the same line as the if/while when a
brace is included.
Patch by Thomas Gibson-Robinson.
llvm-svn: 187901
|
|
|
|
|
|
| |
Patch by Frank Miller.
llvm-svn: 187678
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this patch, clang-format can be configured to:
* not indent in namespace at all (former behavior).
* indent in namespace as in other blocks.
* indent only in inner namespaces (as required by WebKit style).
Also fix alignment of access specifiers in WebKit style.
Patch started by Marek Kurdej. Thank you!
llvm-svn: 187540
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name
switch (OpCode) {
CASE(Add);
CASE(Subtract);
default:
return operations::Unknown;
}
After:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name;
switch (OpCode) {
CASE(Add);
CASE(Subtract);
default:
return operations::Unknown;
}
llvm-svn: 187118
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
someFunction(OtherParam, BracedList{
// comment 1 (Forcing intersting break)
param1, param2,
// comment 2
param3, param4
});
After:
someFunction(OtherParam, BracedList{
// comment 1 (Forcing intersting break)
param1, param2,
// comment 2
param3, param4
});
To do so, the UnwrappedLineParser now stores the information about the
kind of brace in the FormatToken.
llvm-svn: 185914
|
|
|
|
|
|
|
|
|
|
|
|
| |
This lead to weird formatting.
Before:
DoSomethingWithVector({ {} /* No data */ }, {
{ 1, 2 }
});
After:
DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });
llvm-svn: 185346
|
|
|
|
|
|
|
|
|
|
| |
Before:
DoSomethingWithVector({
} /* No data */);
After:
DoSomethingWithVector({} /* No data */);
llvm-svn: 185319
|
|
|
|
| |
llvm-svn: 185303
|
|
|
|
| |
llvm-svn: 184896
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If a "}" is found inside parenthesis, this is probably a case of
missing parenthesis. This enables continuing to format after stuff code
like:
class A {
void f(
};
..
llvm-svn: 183009
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
foo = aaaaaaaaaaa ? vector<int> {
aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaa
}
: vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb, bbbbbbbbbbbbbbbbbbbb, bbbbb };
After:
foo = aaaaaaaaaaa ? vector<int>{ aaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa, aaaaa }
: vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb,
bbbbbbbbbbbbbbbbbbbb, bbbbb };
llvm-svn: 182992
|
|
|
|
| |
llvm-svn: 182856
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If an identifier is on its own line and it is all upper case, it is highly
likely that this is a macro that is meant to stand on a line by itself.
Before:
class A : public QObject {
Q_OBJECT A() {}
};
Ater:
class A : public QObject {
Q_OBJECT
A() {}
};
llvm-svn: 182855
|
|
|
|
| |
llvm-svn: 182796
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This made it necessary to remove an error detection which would let us
bail out of braced lists in certain situations of missing "}". However,
as we always entirely escape from the braced list on finding ";", this
should not be a big problem.
With this, we can no format braced lists with uniformat inits:
return { arg1, SomeType { parameter } };
llvm-svn: 182788
|
|
|
|
|
|
| |
The FormatToken is now not copyable any more.
llvm-svn: 182772
|
|
|
|
|
|
|
|
|
|
|
| |
With this patch, we create all tokens in one go before parsing and pass
an ArrayRef<FormatToken*> to the UnwrappedLineParser. The
UnwrappedLineParser is switched to use pointer-to-token internally.
The UnwrappedLineParser still copies the tokens into the UnwrappedLines.
This will be fixed in an upcoming patch.
llvm-svn: 182768
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Added stack of preprocessor branching directives, and ignore all tokens
inside #if 0 except for preprocessor directives.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D855
llvm-svn: 182658
|
|
|
|
|
|
| |
Also fix a minor bug for constructor initializers with braced init lists.
llvm-svn: 182601
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allows formatting of C++11 braced init list constructs, like:
vector<int> v { 1, 2, 3 };
f({ 1, 2 });
This involves some changes of how tokens are handled in the
UnwrappedLineFormatter. Note that we have a plan to evolve the
design of the token flow into one where we create all tokens
up-front and then annotate them in the various layers (as we
currently already have to create all tokens at once anyway, the
current abstraction does not help). Thus, this introduces
FIXMEs towards that goal.
llvm-svn: 182568
|
|
|
|
|
|
|
| |
We only ever implemented one and that one is not actually all that
helpful (e.g. gets incorrectly triggered by macros).
llvm-svn: 181871
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we'd only detect structural errors on the very first level.
This leads to incorrectly balanced braces not being discovered, and thus
incorrect indentation.
This change fixes the problem by:
- changing the parser to use an error state that can be detected
anywhere inside the productions, for example if we get an eof on
SOME_MACRO({ some block <eof>
- previously we'd never break lines when we discovered a structural
error; now we break even in the case of a structural error if there
are two unwrapped lines within the same line; thus,
void f() { while (true) { g(); y(); } }
will still be re-formatted, even if there's missing braces somewhere
in the file
- still exclude macro definitions from generating structural error;
macro definitions are inbalanced snippets
llvm-svn: 179379
|
|
|
|
|
|
|
| |
Before we would build huge unwrapped lines which take a long time
to optimze.
llvm-svn: 179168
|