| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
Leave a quick "// Uncomment this." hint to enable the debug output in
tests. FIXME: figure out whether we want to enable debug command line
handling for all tests.
llvm-svn: 172608
|
|
|
|
| |
llvm-svn: 172606
|
|
|
|
|
|
|
|
|
|
| |
This makes the tedious fitsIntoLimit() method unnecessary and I can
replace one hack (constructor initializers) by a slightly better hack.
Furthermore, this will enable calculating whether a certain part of a
line fits into the limit for future modifications.
llvm-svn: 172604
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was quite convoluted leading to us accidentally introducing O(N^2)
complexity while copying from UnwrappedLine to AnnotatedLine. We might
still want to improve the datastructure in AnnotatedLine (most
importantly not put them in a vector where they need to be copied on
vector resizing but that will be done as a follow-up.
This fixes most of the regression in llvm.org/PR14959.
No formatting changes intended.
llvm-svn: 172602
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
This is an optimization that djasper spottet. For now, we do not format
anything after the first token that belongs to such an implicit string
literal. All our state is not made for handling that anyway, so we'll
revisit this if we find a problem.
llvm-svn: 172537
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
Main difference, add an AnnotatedLine class to hold information about a
line while formatting. At the same time degrade the UnwrappedLine class
to a class solely used for communicating between the UnwrappedLineParser
and the Formatter.
No functional changes intended.
llvm-svn: 172403
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
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
|
|
|
|
|
|
| |
brought into 'clang' namespace by clang/Basic/LLVM.h
llvm-svn: 172323
|
|
|
|
| |
llvm-svn: 172314
|
|
|
|
| |
llvm-svn: 172308
|
|
|
|
|
|
|
|
| |
canBreakBefore() does not allow breaking after ':' for LT_ObjCMethodDecl lines,
so if Newline is true in addTokenToState() for ':' then LT_ObjCMethodDecl
cannot be set. No functionality change.
llvm-svn: 172307
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
for that.
llvm-svn: 172254
|
|
|
|
| |
llvm-svn: 172239
|
|
|
|
|
|
|
| |
Puts blocks always into multiple lines when they start with an ObjC
keyword or minus.
llvm-svn: 172238
|
|
|
|
|
|
|
| |
if { foo; }
would previously crash clang-format.
llvm-svn: 172232
|
|
|
|
|
|
|
|
| |
Now we correctly parse and format:
verifyFormat("struct foo a = { bar };
int n;
llvm-svn: 172229
|
|
|
|
|
|
|
|
| |
void f() { return 42; }
The final change that implements the feature.
llvm-svn: 172225
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR14913.
Before: A *a = new(placement) A;
After: A *a = new (placement) A;
llvm-svn: 172212
|
|
|
|
| |
llvm-svn: 172211
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) GUARDED_BY(
aaaaaaaaaaaaa);
After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
GUARDED_BY(aaaaaaaaaaaaa);
Also did some formatting cleanups with clang-format on the way.
llvm-svn: 172200
|