Daniel Jasper
8951908218
clang-format: [JS] Fix spacing in dict literals.
...
Before:
someVariable = {'a':[{}]};
After:
someVariable = {'a': [{}]};
llvm-svn: 208403
2014-05-09 10:26:08 +00:00
Daniel Jasper
04a71a45ff
clang-format: Initial support for try-catch.
...
Most of this patch was created by Alexander Rojas in
http://reviews.llvm.org/D2555
Thank you!
Synced and addressed review comments.
llvm-svn: 208302
2014-05-08 11:58:24 +00:00
Daniel Jasper
c03e16a7bc
clang-format: [JS] support closures in container literals.
...
Before:
return {body: {setAttribute: function(key, val) {this[key] = val;
}
, getAttribute : function(key) { return this[key]; }
, style : {
direction:
''
}
}
}
;
After:
return {
body: {
setAttribute: function(key, val) { this[key] = val; },
getAttribute: function(key) { return this[key]; },
style: {direction: ''}
}
};
llvm-svn: 208292
2014-05-08 09:25:39 +00:00
Daniel Jasper
ea2d042f89
clang-format: Fix binary operator detection before lambdas.
...
Before:
bool foo = true&& [] { return false; }();
After:
bool foo = true && [] { return false; }();
llvm-svn: 208288
2014-05-08 08:50:10 +00:00
Daniel Jasper
f7405c129e
clang-format: [JS] Support regex literals after 'return'.
...
llvm-svn: 208285
2014-05-08 07:45:18 +00:00
Daniel Jasper
f9ae312fc0
clang-format: [JS] Initial support for regex literals.
...
llvm-svn: 208281
2014-05-08 07:01:45 +00:00
Nikola Smiljanic
e08a91ecd2
Enable alternative tokens by default for clang-format.
...
Patch by Bobby Moretti.
llvm-svn: 208269
2014-05-08 00:05:13 +00:00
Daniel Jasper
79dffb4128
clang-format: Be slightly more aggressive on single-line functions.
...
So that JS functions can also be merged into a single line.
Before:
var func = function() {
return 1;
};
After:
var func = function() { return 1; };
llvm-svn: 208176
2014-05-07 09:48:30 +00:00
Daniel Jasper
8acf822b6f
clang-format: Fix corner cases for comments in if conditions.
...
Before:
if ( // a
x + 3) { ..
After:
if ( // a
x + 3) { ..
llvm-svn: 208175
2014-05-07 09:23:05 +00:00
Daniel Jasper
7a2d60e328
clang-format: Fix bad space before braced initializer.
...
Before:
new int {1};
After:
new int{1};
llvm-svn: 208168
2014-05-07 07:59:03 +00:00
Daniel Jasper
484033b188
clang-format: [JS] Keep space after closure style comments.
...
Before:
var x = /** @type {foo} */ (bar);
After:
var x = /** @type {foo} */(bar);
llvm-svn: 208093
2014-05-06 14:41:29 +00:00
Daniel Jasper
166c19bd37
clang-format: [JS] Keep space between 'return' and '['.
...
llvm-svn: 208090
2014-05-06 14:12:21 +00:00
Daniel Jasper
4a39c84c91
clang-format: [JS] Don't indent in goog.scope blocks.
...
Before:
goog.scope(function() {
var x = a.b;
var y = c.d;
}); // goog.scope
After:
goog.scope(function() {
var x = a.b;
var y = c.d;
}); // goog.scope
llvm-svn: 208088
2014-05-06 13:54:10 +00:00
Dinesh Dwivedi
2e92e66f66
Fixed one issue with casting
...
Before:
(void) SimplifyICmpOperands(Cond, LHS, RHS);
After:
(void)SimplifyICmpOperands(Cond, LHS, RHS);
Differential Revision: http://reviews.llvm.org/D3615
llvm-svn: 208080
2014-05-06 11:46:49 +00:00
Daniel Jasper
f10a28d705
clang-format: Understand functions with decltype return type.
...
Before:
decltype(long_name_forcing_break)
f() {}
After:
decltype(long_name_forcing_break)
f() {}
llvm-svn: 207965
2014-05-05 13:48:09 +00:00
Dinesh Dwivedi
76f98f8047
Added some heuristics to identify c style casting
...
Before:
void f() { my_int a = (my_int) * b; }
void f() { return P ? (my_int) * P : (my_int)0; }
After:
void f() { my_int a = (my_int)*b; }
void f() { return P ? (my_int)*P : (my_int)0; }
Differential Revision: http://reviews.llvm.org/D3576
llvm-svn: 207964
2014-05-05 13:14:35 +00:00
Daniel Jasper
0e6c51c889
clang-format: Improve understanding of decltype.
...
Before:
SomeFunction([](decltype(x), A * a) {});
After:
SomeFunction([](decltype(x), A *a) {});
llvm-svn: 207961
2014-05-05 12:36:29 +00:00
Dinesh Dwivedi
afe6fb6f05
Fix bug in clang-format while merging short function
...
Before:
#ifdef _DEBUG
int foo( int i = 0 )
#else
int foo( int i = 5 )
#endif { return i; }
After:
#ifdef _DEBUG
int foo( int i = 0 )
#else
int foo( int i = 5 )
#endif
{
return i;
}
llvm-svn: 207958
2014-05-05 11:36:35 +00:00
Daniel Jasper
9509f18836
clang-format: Fix import statements with ColumnLimit: 0
...
These used to interact badly with AlwaysBreakBeforeMultilineStrings.
llvm-svn: 207955
2014-05-05 08:08:07 +00:00
Dinesh Dwivedi
ea3aca8b67
Fixes issue with Allman BreakBeforeBraces for Objective C @interface
...
Before:
@interface BSApplicationController () {
@private
id _extraIvar;
}
@end
After:
@interface BSApplicationController ()
{
@private
id _extraIvar;
}
@end
llvm-svn: 207849
2014-05-02 17:01:46 +00:00
Daniel Jasper
883ae9d9a3
clang-format: Don't bin-pack text-proto-formatted options.
...
Before:
repeated double value = 1
[(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,
bbbbbbb: BBBB, bbbb: BBB}];
After:
repeated double value = 1
[(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,
bbbbbbb: BBBB,
bbbb: BBB}];
llvm-svn: 207538
2014-04-29 15:54:14 +00:00
Daniel Jasper
35995679c6
clang-format: Allow single-line function in WebKit style.
...
Before:
void f() {
return; }
After:
void f() { return; }
llvm-svn: 207527
2014-04-29 14:05:20 +00:00
Daniel Jasper
942d971c84
clang-format: Improve binary operator detection.
...
Before:
*(int *)(p &~3UL) = 0;
After:
*(int *)(p & ~3UL) = 0;
This fixes llvm.org/PR19464.
llvm-svn: 207405
2014-04-28 09:19:28 +00:00
Daniel Jasper
031e2409f9
clang-format: Fixes spaces in case statements.
...
This fixes llvm.org/PR19482.
Before:
switch (a) {
case(B) :
return;
}
After:
switch (a) {
case (B):
return;
}
llvm-svn: 207402
2014-04-28 07:48:36 +00:00
Daniel Jasper
437c3f5188
clang-format: Don't wrap after @interface.
...
This fixes llvm.org/PR19450.
Before:
@interface
BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate,
BookmarkFolderCollectionViewDelegate,
BookmarkMenuViewControllerDelegate,
BookmarkSearchViewControllerDelegate> {
}
After:
@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {
}
llvm-svn: 207400
2014-04-28 07:34:48 +00:00
Daniel Jasper
66935020c4
clang-format: Fix bug when aligning trailing /**/-comments in macros.
...
Previously this could lead to a column limit violation with the
required escaped newlines.
llvm-svn: 207351
2014-04-27 10:03:19 +00:00
Chandler Carruth
1034666777
[Modules] Fix potential ODR violations by sinking the DEBUG_TYPE
...
definition below all of the header #include lines, clang edition.
If you want more details about this, you can see some of the commits to
Debug.h in LLVM recently. This is just the clang section of a cleanup
I've done for all uses of DEBUG_TYPE in LLVM.
llvm-svn: 206849
2014-04-22 03:17:02 +00:00
Alexander Kornienko
67d9c8c87e
Fix alignment of trailing block comments.
...
Summary:
This patch ensures that the lines of the block comments retain relative
column offsets. In order to do this WhitespaceManager::Changes representing
continuation of block comments keep a pointer on the change representing the
whitespace change before the block comment, and a relative column offset to this
change, so that the correct column can be reconstructed at the end of alignment
process.
Fixes http://llvm.org/PR19325
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D3408
llvm-svn: 206472
2014-04-17 16:12:46 +00:00
Daniel Jasper
ae8e0d8da9
clang-format: Respect BinPackParameters in Cpp11BracedListStyle.
...
With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly
for Chromium):
Before:
const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff,
ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk};
After:
const Aaaaaa aaaaa = {aaaaa,
bbbbb,
ccccc,
ddddd,
eeeee,
ffffff,
ggggg,
hhhhhh,
iiiiii,
jjjjjj,
kkkkkk};
This fixes llvm.org/PR19359. I am not sure we'll want this in all cases
in the long run, but I'll guess we'll get feedback on that.
llvm-svn: 206458
2014-04-17 11:32:02 +00:00
Daniel Jasper
0e61784ae5
clang-format: Add special case to reduce indentaiton in streams.
...
This is similar to how we treat assignments and seems to be generally
desirable.
Before:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 206384
2014-04-16 12:26:54 +00:00
Alexander Kornienko
64a42b8dd2
Fix assertion when breaking string literals with tab characters.
...
Summary: Fixes http://llvm.org/PR19368
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D3379
llvm-svn: 206295
2014-04-15 14:52:43 +00:00
Daniel Jasper
783bac6bba
clang-format: Understand proto text format without commas.
...
Also removed spaces before colons as they don't seem to be used
frequently.
Before:
optional int32 b = 2
[(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb :
"baz"}];
After:
optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123,
bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}];
llvm-svn: 206269
2014-04-15 09:54:30 +00:00
Daniel Jasper
9d3adc06c6
x
...
llvm-svn: 206268
2014-04-15 09:54:24 +00:00
Daniel Jasper
20fd3c6ff7
clang-format: Basic support for C++1y.
...
Before:
int bi{1 '000' 000};
After:
int bi{1'000'000};
This fixes llvm.org/PR19342.
llvm-svn: 206263
2014-04-15 08:49:21 +00:00
Daniel Jasper
866468ae4d
clang-format: Fix regression caused by r206165.
...
llvm-svn: 206173
2014-04-14 13:15:29 +00:00
Daniel Jasper
72ab43b28b
clang-format: Fix incorrect &&-detection in macros.
...
Before:
#define A(a, b) (a &&b)
After:
#define A(a, b) (a && b)
This fixes llvm.org/PR19343.
llvm-svn: 206165
2014-04-14 12:50:02 +00:00
Daniel Jasper
db8804b32b
clang-format: Improve array literal formatting fix in r206161.
...
Instead of choosing based on the number of elements, simply respect the
user's choice of where to wrap array literals.
llvm-svn: 206162
2014-04-14 12:11:07 +00:00
Daniel Jasper
af4fee2636
clang-format: With ColumnLimit=0, keep short array literals on a line.
...
Before:
NSArray* a = [[NSArray alloc] initWithArray:@[
@"a"
]
copyItems:YES];
After:
NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ]
copyItems:YES];
This fixed llvm.org/PR19080.
llvm-svn: 206161
2014-04-14 12:05:05 +00:00
Daniel Jasper
c0d606a584
clang-format: Don't allow hanging indentation for operators on new lines
...
Before:
if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
After:
if (aaaaaaaa
&& bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
The same rule has already be implemented for BreakBeforeBinaryOperators
set to false in r205527.
llvm-svn: 206159
2014-04-14 11:08:45 +00:00
Manuel Klimek
68b03049e0
Format code around VCS conflict markers.
...
Now correctly formats:
{
int a;
void f() {
callme(some(parameter1,
<<<<<<< text by the vcs
parameter2),
||||||| text by the vcs
parameter2),
parameter3,
======= text by the vcs
parameter2, parameter3),
>>>>>>> text by the vcs
otherparameter);
}
}
llvm-svn: 206157
2014-04-14 09:14:11 +00:00
Daniel Jasper
35ec2b244a
clang-format: Improve formatting of annotated variables.
...
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =
aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 206155
2014-04-14 08:15:20 +00:00
Daniel Jasper
220c0d1f5e
clang-format: Fix false positive in braced list detection in protos.
...
llvm-svn: 205954
2014-04-10 07:27:12 +00:00
Daniel Jasper
f9fc215f82
clang-format: Treat a trailing comment like a trailing comma in braced lists.
...
Before:
static StructInitInfo module = {MODULE_BUILTIN, /* type */
"streams" /* name */
};
After:
static StructInitInfo module = {
MODULE_BUILTIN, /* type */
"streams" /* name */
};
This fixes llvm.org/PR19378.
llvm-svn: 205851
2014-04-09 13:18:49 +00:00
Daniel Jasper
21397a3232
clang-format: Fix bug where clang-format would break the code.
...
Before, it would turn:
SomeFunction([]() { // Cool function..
return 43;
});
Into this:
SomeFunction([]() { // Cool function.. return 43; });
llvm-svn: 205849
2014-04-09 12:21:48 +00:00
Daniel Jasper
3ae6f5a47b
clang-format: Improve format of calls with several lambdas.
...
Before:
SomeFunction([]() {
int i = 42;
return i;
},
[]() {
int j = 43;
return j;
});
After:
SomeFunction([]() {
int i = 42;
return i;
},
[]() {
int j = 43;
return j;
});
llvm-svn: 205848
2014-04-09 12:08:39 +00:00
Daniel Jasper
f9a0906b98
clang-format: Allow breaking between trailing annotations in more cases.
...
Before:
void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(
aaaaaaaaaaaaaaa);
After:
void aaaaaaaaaaaaaa(aaaaaaaa aaa) override
AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa);
llvm-svn: 205846
2014-04-09 10:29:11 +00:00
Daniel Jasper
b48d3afcd5
clang-format: Keep more trailing annotations on the same line.
...
More precisely keep all short annotations (<10 characters) on the same
line if possible. Previously, clang-format would only prefer to do so
for "const", "override" and "final". However, it seems to be generally
preferable, especially because some codebases have to wrap those in
macros for backwards compatibility.
Before:
void someLongFunction(int someLongParameter)
OVERRIDE {}
After:
void someLongFunction(
int someLongParameter) OVERRIDE {}
This fixes llvm.org/PR19363.
llvm-svn: 205845
2014-04-09 10:01:49 +00:00
Daniel Jasper
b175d57edc
clang-format: Recognize lists ending in trailing commas correctly.
...
Previously, this did not look through trailing comments leading to a few
formatting oddities.
llvm-svn: 205843
2014-04-09 09:53:23 +00:00
Daniel Jasper
b77105d2ce
clang-format: Fix incorrect multi-block-parameter computation.
...
llvm-svn: 205763
2014-04-08 14:04:31 +00:00
Daniel Jasper
139d4a3875
clang-format: Correctly understand arrays of pointers.
...
Before:
A<int * []> a;
After:
A<int *[]> a;
This fixes llvm.org/PR19360.
llvm-svn: 205761
2014-04-08 13:07:41 +00:00