Daniel Jasper
4bf9d470cb
clang-format: [Java] Support extending inner classes.
...
Before:
class A extends B
.C {}
After:
class A extends B.C {}
llvm-svn: 220280
2014-10-21 09:31:29 +00:00
Daniel Jasper
c58c70e2f3
clang-format: Basic support for Java.
...
llvm-svn: 217759
2014-09-15 11:21:46 +00:00
Daniel Jasper
3f69ba1075
clang-format: [JS] Better support for empty function literals.
...
Before:
SomeFunction(function(){});
After:
SomeFunction(function() {});
llvm-svn: 217236
2014-09-05 08:42:27 +00:00
Daniel Jasper
4429f14906
clang-format: Address review comments of r216501.
...
llvm-svn: 216565
2014-08-27 17:16:46 +00:00
Daniel Jasper
8f46365481
clang-format: Don't butcher __asm blocks.
...
Instead completely cop out of formatting them for now.
This fixes llvm.org/PR20618.
llvm-svn: 216501
2014-08-26 23:15:12 +00:00
Roman Kashitsyn
a043cedf0a
Fixes bug 20587 - Add K&R break before braces style
...
Summary:
http://llvm.org/bugs/show_bug.cgi?id=20587
Added K&R style. It could be enabled by the following option:
```
BreakBeforeBraces: KernighanRitchie
```
This style is like `Attach`, but break *only* before function
declarations.
As I can see, no additional logic required to support this style, any
style different from other styles automagically satisfies K&R.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D4837
llvm-svn: 215354
2014-08-11 12:18:01 +00:00
David Blaikie
efb6eb2697
Use std::unique_ptr to handle transient ownership of UnwrappedLine in ScopedLineState
...
llvm-svn: 215294
2014-08-09 20:02:07 +00:00
Daniel Jasper
d9670878d4
clang-format: Break before 'else' in Stroustrup style.
...
Seems to be the desired thing to do according to:
http://www.stroustrup.com/Programming/PPP-style-rev3.pdf
Patch by Jarkko Hietaniemi, thank you!
llvm-svn: 214857
2014-08-05 12:06:20 +00:00
Daniel Jasper
65df5aa918
clang-format: Understand parameter pack initialization.
...
Before:
Constructor(A... a) : a_(X<A> { std::forward<A>(a) }...) {}
After:
Constructor(A... a) : a_(X<A>{std::forward<A>(a)}...) {}
llvm-svn: 214720
2014-08-04 14:51:02 +00:00
Manuel Klimek
45bf56cdf9
Fix parsing of classes where the class name is an absolute nested name specifier.
...
llvm-svn: 214393
2014-07-31 07:19:30 +00:00
Daniel Jasper
ad9eb0d79d
clang-format: [JS] support free-standing functions again.
...
This worked initially but was broken by r210887.
Before:
function outer1(a, b) {
function inner1(a, b) { return a; } inner1(a, b);
} function outer2(a, b) { function inner2(a, b) { return a; } inner2(a, b); }
After:
function outer1(a, b) {
function inner1(a, b) { return a; }
inner1(a, b);
}
function outer2(a, b) {
function inner2(a, b) { return a; }
inner2(a, b);
}
Thanks to Adam Strzelecki for working on this.
llvm-svn: 212038
2014-06-30 13:24:54 +00:00
Daniel Jasper
5217a8b84f
clang-format: [JS] Understand named function literals.
...
Before:
return {a: function SomeFunction(){// ...
return 1;
}
}
;
After:
return {
a: function SomeFunction() {
// ...
return 1;
}
};
llvm-svn: 210887
2014-06-13 07:02:04 +00:00
Daniel Jasper
da18fd86c7
clang-format: Support variadic lambda captures.
...
Before:
return [ i, args... ]{};
After:
return [i, args...] {};
llvm-svn: 210514
2014-06-10 06:39:03 +00:00
Daniel Jasper
91b032ab55
clang-format: Fix braced list detection.
...
Before:
static_assert(std::is_integral<int> {} + 0, "");
int a = std::is_integral<int> {}
+ 0;
After:
static_assert(std::is_integral<int>{} + 0, "");
int a = std::is_integral<int>{} + 0;
llvm-svn: 209431
2014-05-22 12:46:38 +00:00
Daniel Jasper
438059e509
clang-format: Fix incorrect braced init identification.
...
Before:
int foo(int i) {
return fo1 {}
(i);
}
int foo(int i) {
return fo1 {}
(i);
}
After:
int foo(int i) { return fo1{}(i); }
int foo(int i) { return fo1{}(i); }
This fixes llvm.org/PR19812.
llvm-svn: 209428
2014-05-22 12:11:13 +00:00
Daniel Jasper
5ebb2f3625
clang-format: Fix incorrect macro call detection.
...
In:
struct A {
A()
noexcept(....) {}
};
'A()' is not a macro call.
This fixes llvm.org/PR19814.
llvm-svn: 209294
2014-05-21 13:08:17 +00:00
Daniel Jasper
069e5f4858
clang-format: [JS] Understand top-level function literals properly.
...
llvm-svn: 209205
2014-05-20 11:14:57 +00:00
Daniel Jasper
b05a81debb
clang-format: Fix bug introduced by r208392.
...
Also run clang-format over clang-format's files.
llvm-svn: 208409
2014-05-09 13:11:16 +00:00
Craig Topper
2145bc0229
[C++11] Use 'nullptr'.
...
llvm-svn: 208392
2014-05-09 08:15:10 +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
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
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
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
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
Manuel Klimek
1fcbe675fa
Correctly handle escaped newlines when the next token starts without a space.
...
We will need this to correctly handle conflict markers inside macro
definitions.
llvm-svn: 206029
2014-04-11 12:27:47 +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
e1e4319ab7
clang-format: Support configurable list of foreach-macros.
...
This fixes llvm.org/PR17242.
Patch by Brian Green, thank you!
llvm-svn: 205307
2014-04-01 12:55:11 +00:00
Daniel Jasper
240dfda352
clang-format: Solve issues found and fixed by clang-tidy.
...
llvm-svn: 205193
2014-03-31 14:23:49 +00:00
Daniel Jasper
395193c7a0
clang-format: Recognize more ObjC blocks with parameters/return type.
...
llvm-svn: 204990
2014-03-28 07:48:59 +00:00
Alexander Kornienko
ce08126733
clang-format: Detect function-like macros only when upper case is used.
...
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D3110
llvm-svn: 204156
2014-03-18 14:35:20 +00:00
Craig Topper
fb6b25b5e4
[C++11] Add 'override' keyword to virtual methods that override their base class.
...
llvm-svn: 203999
2014-03-15 04:29:04 +00:00
Alexander Kornienko
c2ee9cf861
Remove an unnecessary check for FormatTok not being null.
...
Summary:
This check hints clang analyzer, that FormatTok may be null, and it
reports a null pointer dereference error:
http://buildd-clang.debian.net/scan-build/report-827c64.html#Path28
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D3040
llvm-svn: 203800
2014-03-13 13:59:48 +00:00
Daniel Jasper
ac7e34e778
clang-format: Prevent ObjC code from confusing the braced-init detection
...
This was leading to bad formatting, e.g.:
Before:
f(^{
@autoreleasepool {
if (a) {
g();
}
}
});
After:
f(^{
@autoreleasepool {
if (a) {
g();
}
}
});
llvm-svn: 203777
2014-03-13 10:11:17 +00:00
Daniel Jasper
a58dd5db29
clang-format: Fix another false positive in the lambda detection.
...
Before:
int i = (*b)[a] -> f();
After:
int i = (*b)[a]->f();
llvm-svn: 203557
2014-03-11 10:03:33 +00:00
Daniel Jasper
d3c7ab975f
clang-format: Fix incorrect lambda recognition exposed by r203452.
...
Before:
int i = a[a][a] -> f();
After:
int i = a[a][a]->f();
llvm-svn: 203556
2014-03-11 09:59:36 +00:00
Daniel Jasper
81a20787db
clang-format: Add spaces around trailing/lambda return types.
...
Before:
int c = []()->int { return 2; }();
After:
int c = []() -> int { return 2; }();
llvm-svn: 203452
2014-03-10 10:02:02 +00:00
Ahmed Charles
9a16beb8bc
Change OwningPtr::take() to OwningPtr::release().
...
This is a precursor to moving to std::unique_ptr.
llvm-svn: 203275
2014-03-07 19:33:25 +00:00
Daniel Jasper
1067ab0a1a
clang-format: Support lambdas with namespace-qualified return types.
...
E.g.:
Foo([]()->std::vector<int> { return { 2 }; }());
llvm-svn: 201139
2014-02-11 10:16:55 +00:00
Daniel Jasper
a88f80a1be
clang-format: Support ObjC's NS_ENUMs.
...
Before:
typedef NS_ENUM(NSInteger, MyType) {
/// Information about someDecentlyLongValue.
someDecentlyLongValue,
/// Information about anotherDecentlyLongValue.
anotherDecentlyLongValue,
/// Information about aThirdDecentlyLongValue.
aThirdDecentlyLongValue};
After:
typedef NS_ENUM(NSInteger, MyType) {
/// Information about someDecentlyLongValue.
someDecentlyLongValue,
/// Information about anotherDecentlyLongValue.
anotherDecentlyLongValue,
/// Information about aThirdDecentlyLongValue.
aThirdDecentlyLongValue
};
llvm-svn: 200469
2014-01-30 14:38:37 +00:00
Manuel Klimek
14bd917470
Fix crash on unmatched #endif's.
...
The following snippet would crash:
#endif
#if A
llvm-svn: 200381
2014-01-29 08:49:02 +00:00
Manuel Klimek
421147ec65
Get rid of special parsing for return statements.
...
This was done when we were not able to parse lambdas to handle some
edge cases for block formatting different in return statements, but is
not necessary any more.
llvm-svn: 199982
2014-01-24 09:25:23 +00:00
Daniel Jasper
6b70ec0d46
clang-format: Fix incorrect lambda recognition.
...
Before:
std::unique_ptr<int[]> foo() {}
After:
std::unique_ptr<int []> foo() {}
Also, the formatting could go severely wrong after such a function
before.
llvm-svn: 199817
2014-01-22 17:01:47 +00:00
Daniel Jasper
cb51cf409b
clang-format: Enable formatting of lambdas with explicit return type.
...
So clang-format can now format:
int c = []()->int { return 2; }();
int c = []()->vector<int> { return { 2 }; }();
llvm-svn: 199368
2014-01-16 09:11:55 +00:00
Benjamin Kramer
e21cb74224
clang-format: Don't hang forever when encountering a stray "}" in an @implementation block.
...
PR18406.
llvm-svn: 198770
2014-01-08 15:59:42 +00:00
Daniel Jasper
352dae199a
clang-format: Recognize single-line macro usages inside macros.
...
Before:
#define LIST(L) \
L(FirstElement) L(SecondElement) L(ThirdElement) L(FourthElement) \
L(FifthElement)
After:
#define LIST(L) \
L(FirstElement) \
L(SecondElement) \
L(ThirdElement) \
L(FourthElement) \
L(FifthElement)
llvm-svn: 198407
2014-01-03 11:50:46 +00:00
Daniel Jasper
b88b25feec
clang-format: Fix various problems in formatting ObjC blocks.
...
Among other things, this fixes llvm.org/PR15269.
llvm-svn: 197900
2013-12-23 07:29:06 +00:00
Alexander Kornienko
3a33f0292b
Implemented GNU-style formatting for compound statements.
...
Summary:
Added BraceBreakingStyle::BS_GNU. I'm not sure about the correctness of
static initializer formatting, but compound statements should be fine.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2372
llvm-svn: 197138
2013-12-12 09:49:52 +00:00
Daniel Jasper
1556b59338
clang-format: Correctly handle Qt's Q_SLOTS.
...
This should fix llvm.org/PR17241. Maybe it sticks this time :-).
llvm-svn: 195953
2013-11-29 08:51:56 +00:00
Daniel Jasper
84c47a1074
clang-format: Support Qt's slot access specifiers.
...
This fixes llvm.org/PR17241.
llvm-svn: 195555
2013-11-23 17:53:41 +00:00