| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
| |
Before:
#include <a> // for x
#include <a/b/c> // for yz
After:
#include <a> // for x
#include <a/b/c> // for yz
llvm-svn: 172799
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
int a; // comment
int bbbbb; // comment
After:
int a; // comment
int bbbbb; // comment
llvm-svn: 172798
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
switch (foo) {
case a: {
int a = g();
h(a);
}
break;
}
Now:
switch (foo) {
case a: {
int a = g();
h(a);
} break;
}
llvm-svn: 172789
|
|
|
|
|
|
|
| |
This doesn't work right with pointers to pointers, but that's likely just a
dupe of PR14884.
llvm-svn: 172785
|
|
|
|
|
|
| |
Before: @selector(foo: )
Now: @selector(foo:)
llvm-svn: 172781
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.
Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.
Before:
if (a& b)
if (int* b = f())
Now:
if (a & b)
if (int* b = f())
llvm-svn: 172731
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
aaaaaaaaaaaaa);
After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const
GUARDED_BY(aaaaaaaaaaaaa);
llvm-svn: 172718
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Also adding more tests.
We can now keep the formatting of something like:
static SomeType type = { aaaaaaaaaaaaaaaaaaaa, /* comment */
aaaaaaaaaaaaaaaaaaaa /* comment */,
/* comment */ aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa, // comment
aaaaaaaaaaaaaaaaaaaa };
Note that the comment in the first line is handled like a trailing line comment
as that is likely what the user intended.
llvm-svn: 172711
|
|
|
|
|
|
|
|
|
|
| |
r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions
as reference. But now that I look at that link again, it seems I didn't
read it very carefully the first time round.
llvm-svn: 172703
|
|
|
|
|
|
|
|
|
|
|
| |
Before: Constructor() : a(a), // comment a(a) {}
After: Constructor() : a(a), // comment
a(a) {}
Needed this as a quick fix. Will add more tests for this in a future
commit.
llvm-svn: 172624
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to incorrectly parse
aaaaaa ? aaaaaa(aaaaaa) : aaaaaaaa;
Due to an l_paren being followed by a colon, we assumed it to be part of
a constructor initializer. Thus, we never found the colon belonging to
the conditional expression, marked the line as bing incorrect and did
not format it.
llvm-svn: 172621
|
|
|
|
|
|
| |
Before: int x = ** a;
After: int x = **a;
llvm-svn: 172619
|
|
|
|
|
|
|
|
|
| |
Various reasons seem to speak against it, so I am disabling this for
now.
Changed tests to still test this option.
llvm-svn: 172618
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"Bin-packing" here means allowing multiple parameters on one line, if a
function call/declaration is spread over multiple lines.
This is required by the Chromium style guide and probably desired for
the Google style guide. Not making changes to LLVM style as I don't have
enough data.
With this enabled, we format stuff like:
aaaaaaaaaaaaaaa(aaaaaaaaaa,
aaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaa();
llvm-svn: 172617
|
|
|
|
| |
llvm-svn: 172616
|
|
|
|
| |
llvm-svn: 172607
|
|
|
|
| |
llvm-svn: 172606
|
|
|
|
|
|
| |
Before: vector<::Type> t;
After: vector< ::Type> t;
llvm-svn: 172601
|
|
|
|
|
|
|
| |
Before: if (a) // This comment confused clang-format f();
After: if (a) // No more confusion
f();
llvm-svn: 172600
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Treat tokens inside <> for includes and everything from the second token
of a warning / error on as an implicit string literal, e.g. do not
change its whitespace at all.
Now correctly formats:
#include < path with space >
#error Leave all white!!!!! space* alone!
Note that for #error and #warning we still format the space up to the
first token of the text, so:
# error Text
will become
#error Text
llvm-svn: 172536
|
|
|
|
|
|
|
|
|
|
|
| |
We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.
Example:
Before: int a = /**/ - 1;
After: int a = /**/ -1;
llvm-svn: 172533
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This switches to parsing record definitions only if we can clearly
identify them. We're specifically allowing common patterns for
visibility control through macros and attributes, but we cannot
currently fix all instances. This fixes all known bugs we have though.
Before:
static class A f() {
return g();
} int x;
After:
static class A f() {
return g();
}
int x;
llvm-svn: 172530
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now format this correctly:
Status::Rep Status::global_reps[3] = {
{ kGlobalRef, OK_CODE, NULL, NULL, NULL },
{ kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL },
{ kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL }
};
- fixed a bug where BreakBeforeClosingBrace would be set on the wrong
state
- added penalties for breaking between = and {, and between { and any
other non-{ token
llvm-svn: 172433
|
|
|
|
|
|
|
|
|
| |
Now, "if (a) return;" is only allowed, if this option is set.
Also add a Chromium style which is currently identical to Google style
except for this option.
llvm-svn: 172431
|
|
|
|
|
|
|
| |
If the first line of a merge would exactly fit into the column limit,
an unsigned overflow made us not break.
llvm-svn: 172426
|
|
|
|
|
|
|
| |
Before: #include "a.h" #include "b.h"
After: #include "a.h"
#include "b.h"
llvm-svn: 172424
|
|
|
|
|
|
|
| |
Before: #define A \
A
After: #define A A
llvm-svn: 172423
|
|
|
|
|
|
|
|
|
|
|
| |
Before: if (a)
return;
After: if (a) return;
Not yet sure, whether this is always desired, but we can add options and
make this a style parameter as we go along.
llvm-svn: 172413
|
|
|
|
|
|
|
|
| |
Before: (a->f()) ++;
a[42] ++;
After: (a->f())++;
a[42]++;
llvm-svn: 172400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
unit tests.
Summary:
Added tests for clang-format diagnostics. Added DiagnosticConsumer
argument to clang::format::reformat().
Reviewers: klimek, djasper
Reviewed By: djasper
CC: cfe-commits, thakis, rafael.espindola
Differential Revision: http://llvm-reviews.chandlerc.com/D290
llvm-svn: 172399
|
|
|
|
|
|
|
| |
While reviewing r172303 I noticed that I wasn't sure whether we still
format those correctly and didn't see any tests.
llvm-svn: 172396
|
|
|
|
|
|
|
|
| |
They work fine, but this fifth use of colons (after labels, in ?:,
in initalizer lists in constructors, in objc method expressions, and in
bitfields) wasn't covered by tests yet.
llvm-svn: 172377
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang-format should not change whether or not there is a line break
before a line comment as this strongly influences the percieved binding.
User input: void f(int a,
// b is awesome
int b);
void g(int a, // a is awesome
int b);
Before: void f(int a, // b is awesome
int b);
void g(int a, // a is awesome
int b);
After: <unchanged from input>
llvm-svn: 172361
|
|
|
|
|
|
|
|
|
|
|
| |
Note that I don't know whether we should put {} on a single line in this
case, but it is probably a theoretical issue as in practice such
structs, classes or unions won't be empty.
Before: union A {}
a;
After: union A {} a;
llvm-svn: 172355
|
|
|
|
|
|
|
|
|
|
| |
I am not aware of a case where that would be wrong. The specific case I
am fixing are function parameters wrapped in parenthesis (e.g. in
macros).
Before: function(a,(b));
After: function(a, (b));
llvm-svn: 172351
|
|
|
|
|
|
| |
Before: #include <a - a>
After: #include <a-a>
llvm-svn: 172350
|
|
|
|
|
|
|
|
|
| |
A ")" before any of "=", "{" or ";" won't be a cast. This fixes issues
with the formatting of unnamed parameters.
Before: void f(int *){}
After: void f(int *) {}
llvm-svn: 172349
|
|
|
|
|
|
|
|
|
|
| |
Before:
[color getRed: &r green: &g blue: &b alpha: &a];
Now:
[color getRed:&r green:&g blue:&b alpha:&a];
llvm-svn: 172337
|
|
|
|
|
|
| |
happens to work already.
llvm-svn: 172335
|
|
|
|
| |
llvm-svn: 172334
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
if ((self = [super initWithContentRect:contentRect styleMask:
styleMask backing:NSBackingStoreBuffered defer:YES])) {
Now:
if ((self = [super initWithContentRect:contentRect styleMask:styleMask
backing:NSBackingStoreBuffered defer:YES])) {
llvm-svn: 172333
|
|
|
|
| |
llvm-svn: 172308
|
|
|
|
|
|
| |
The containing if checks for this already. No functionality change.
llvm-svn: 172306
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This follows the approach suggested by djasper in PR14911: When a '[' is
seen that's at the start of a line, follows a binary operator, or follows one
of : [ ( return throw, that '[' and its closing ']' are marked as
TT_ObjCMethodExpr and every ':' in that range that isn't part of a ternary
?: is marked as TT_ObjCMethodExpr as well.
Update the layout routines to not output spaces around ':' tokens that are
marked TT_ObjCMethodExpr, and only allow breaking after such tokens, not
before.
Before:
[self adjustButton : closeButton_ ofKind : NSWindowCloseButton];
Now:
[self adjustButton:closeButton_ ofKind:NSWindowCloseButton];
llvm-svn: 172304
|
|
|
|
| |
llvm-svn: 172303
|
|
|
|
| |
llvm-svn: 172302
|
|
|
|
| |
llvm-svn: 172301
|
|
|
|
| |
llvm-svn: 172289
|
|
|
|
|
|
| |
for that.
llvm-svn: 172254
|
|
|
|
| |
llvm-svn: 172239
|