Daniel Jasper
6a5d38d2ee
clang-format: [JS] Allow periods and commata in class declarations.
...
Patch by Martin Probst. Thank you.
llvm-svn: 234752
2015-04-13 14:56:54 +00:00
Alexander Kornienko
34eb20725d
Use 'override/final' instead of 'virtual' for overridden methods
...
Summary:
The patch is generated using clang-tidy misc-use-override check.
This command was used:
tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
-checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix
Reviewers: dblaikie
Reviewed By: dblaikie
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D8926
llvm-svn: 234678
2015-04-11 02:00:23 +00:00
Daniel Jasper
53395406da
clang-format: Fix regression formatting QT's "signals:" from r234318.
...
llvm-svn: 234320
2015-04-07 15:04:40 +00:00
Daniel Jasper
676e516354
clang-format: Don't allow labels when expecting declarations.
...
This fixes formatting unnamed bitfields (llvm.org/PR21999).
Before:
struct MyStruct {
uchar data;
uchar:
8;
uchar:
8;
uchar other;
};
After:
struct MyStruct {
uchar data;
uchar : 8;
uchar : 8;
uchar other;
};
llvm-svn: 234318
2015-04-07 14:36:33 +00:00
Daniel Jasper
f46dec86b6
clang-format: [JS] Support getters, setters and methods in object literals.
...
llvm-svn: 233698
2015-03-31 14:34:15 +00:00
Daniel Jasper
02c7bca5d1
clang-format: [JS] Fix comment formatting in goog.scopes.
...
Before:
goog.scope(function() {
// test
var x = 0;
// test
});
After:
goog.scope(function() {
// test
var x = 0;
// test
});
llvm-svn: 233530
2015-03-30 09:56:50 +00:00
Benjamin Kramer
53f5e893c2
Explicitly include raw_ostream.h instead of relying on transitive inclusion.
...
NFC.
llvm-svn: 232975
2015-03-23 18:05:43 +00:00
Daniel Jasper
6acf513099
clang-format: [Java] Support anonymous classes after = and return.
...
Before:
A a = new A(){public String toString(){return "NotReallyA";
}
}
;
After:
A a = return new A() {
public String toString() {
return "NotReallyA";
}
};
This fixes llvm.org/PR22878.
llvm-svn: 232042
2015-03-12 14:44:29 +00:00
Benjamin Kramer
8407df72a3
Make helper functions static. NFC.
...
Found by -Wmissing-prototypes.
llvm-svn: 231668
2015-03-09 16:47:52 +00:00
Benjamin Kramer
33335df819
Add missing include.
...
llvm-svn: 230910
2015-03-01 21:36:40 +00:00
Daniel Jasper
fca735cd58
clang-format: [js] Support ES6 module exports.
...
Patch by Martin Probst, thank you!
llvm-svn: 229865
2015-02-19 16:14:18 +00:00
Daniel Jasper
354aa51587
clang-format: [js] Support ES6 module imports.
...
Patch by Martin Probst.
llvm-svn: 229863
2015-02-19 16:07:32 +00:00
Daniel Jasper
6fa9ec7885
clang-format: [js] Do not fall through for JS structural elements.
...
Patch by Martin Probst. Thank you.
llvm-svn: 229862
2015-02-19 16:03:16 +00:00
Daniel Jasper
8370908667
clang-format: [JS] Support classes.
...
This adds support for JavaScript class definitions (again following
TypeScript & AtScript style). This only required support for
visibility modifiers in JS, everything else was already working.
Patch by Martin Probst, thank you.
llvm-svn: 229701
2015-02-18 17:14:05 +00:00
Daniel Jasper
29d39d54e7
clang-format: Correctly mark preprocessor lines in child blocks.
...
This prevents contracting:
auto lambda = []() {
int a = 2
#if A
+ 2
#endif
;
};
into:
auto lambda = []() { int a = 2
#if A + 2
#endif ; };
Which is obviously BAD.
This fixes llvm.org/PR22496.
llvm-svn: 228522
2015-02-08 09:34:49 +00:00
Nico Weber
33381f5e0b
clang-format: Format Objective-C try blocks like all the other try blocks.
...
Before:
@try {
// ...
}
@finally {
// ...
}
Now:
@try {
// ...
} @finally {
// ...
}
This is consistent with how we format C++ try blocks and SEH try blocks.
clang-format not doing this before was an implementation oversight.
This is dependent on BraceBreakingStyle. The snippet above is with the
Attach style. Style Stroustrip for example still results in the "Before:"
snippet, which makes sense since other blocks (try, else) break after '}' too.
llvm-svn: 228483
2015-02-07 01:57:32 +00:00
Nico Weber
fac2371be3
clang-format: Add support for SEH __try / __except / __finally blocks.
...
This lets clang-format format
__try {
} __except(0) {
}
and
__try {
} __finally {
}
correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set,
so this turns this on. This also enables a few other keywords, but it
shouldn't overly perturb regular clang-format operation. __except is a
context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to
a few more places.
Fixes PR22321.
llvm-svn: 228148
2015-02-04 15:26:27 +00:00
Daniel Jasper
9d22bcc53e
clang-format: Fix assertion when trying to build a nullptr StringRef.
...
llvm-svn: 226448
2015-01-19 10:51:05 +00:00
Daniel Jasper
2bd7a64d12
clang-format: Fix endless loop on incomplete try-catch-block.
...
llvm-svn: 226447
2015-01-19 10:50:51 +00:00
Daniel Jasper
e189d46512
clang-format: [Java] Support try blocks with resources.
...
Before:
try
(SomeResource rs = someFunction()) {
Something();
}
After:
try (SomeResource rs = someFunction()) {
Something();
}
llvm-svn: 225973
2015-01-14 10:48:41 +00:00
Daniel Jasper
2337f28063
clang-format: Fix formatting of inline asm.
...
Specifically, adjust the leading "__asm {" and trailing "}" while still
leaving the assembly inside it alone.
This fixes llvm.org/PR22190.
llvm-svn: 225623
2015-01-12 10:14:56 +00:00
Daniel Jasper
5f1fa85e5b
clang-format: [Java] Fix incorrect recognition of annonymous classes.
...
Before:
someFunction(new Runnable() { public void run() { System.out.println(42);
}
});
After:
someFunction(new Runnable() {
public void run() {
System.out.println(42);
}
});
llvm-svn: 225142
2015-01-04 20:40:51 +00:00
Daniel Jasper
3431b75069
clang-format: Support commas in lambda return types.
...
Before:
auto next_pair = [](A * a) -> pair<A*, A*>{};
After:
auto next_pair = [](A* a) -> pair<A*, A*>{};
llvm-svn: 223652
2014-12-08 13:22:37 +00:00
Daniel Jasper
31f6c54733
clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.
...
This fixes llvm.org/PR21756.
llvm-svn: 223458
2014-12-05 10:42:21 +00:00
Daniel Jasper
e5d74867aa
clang-format: [Java] Support Foo.class;
...
Before:
SomeClass.
class.getName();
After:
SomeClass.class.getName();
This fixes llvm.org/PR21665.
llvm-svn: 222813
2014-11-26 08:17:08 +00:00
Daniel Jasper
616de864da
clang-format: [JS] Support Closure's module statements.
...
These are like import statements and should not be line-wrapped. Minor
restructuring of the handling of other import statements.
llvm-svn: 222637
2014-11-23 16:46:28 +00:00
Daniel Jasper
bcb55eec3a
clang-format: Understand more lambda return types.
...
Before:
auto a = [&b, c ](D * d) -> D * {}
After:
auto a = [&b, c](D* d) -> D* {}
llvm-svn: 222534
2014-11-21 14:08:38 +00:00
Daniel Jasper
ccb68b487e
clang-format: [Java] Accept generic types in enum declaration
...
Before:
enum Foo implements Bar<X, Y> {
ABC {
...
}
, CDE {
...
};
}
After:
enum Foo implements Bar<X, Y> {
ABC {
...
},
CDE {
...
};
}
Patch by Harry Terkelsen.
llvm-svn: 222394
2014-11-19 22:38:18 +00:00
Daniel Jasper
6be0f55d44
clang-format: [Java] Support Java enums.
...
In Java, enums can contain a class body and enum constants can have
arguments as well as class bodies. Support most of that.
llvm-svn: 221895
2014-11-13 15:56:28 +00:00
Daniel Jasper
680b09ba88
clang-format: Improve free-standing macro detection.
...
Before:
SOME_WEIRD_LOG_MACRO
<< "Something long enough to cause a line break";
After:
SOME_WEIRD_LOG_MACRO
<< "Something long enough to cause a line break";
llvm-svn: 221338
2014-11-05 10:48:04 +00:00
Daniel Jasper
d0ec0d62d6
clang-format: Use identifier table for keywords in other languages.
...
Slightly easier to write, more efficient and prevents bugs by
misspelling them.
No functional changes intended.
llvm-svn: 221259
2014-11-04 12:41:02 +00:00
Daniel Jasper
82f9df9eb4
Revert "clang-format: [Java] Allow trailing semicolons after enums."
...
This reverts commit b5bdb2ef59ab922bcb4d6e843fffaee1f7f68a8c.
This doesn't really seem necessary on second though and causes problems
with C++ enum formatting.
llvm-svn: 221158
2014-11-03 15:42:11 +00:00
Daniel Jasper
5f2764d886
clang-format: [Java] Allow trailing semicolons after enums.
...
Before:
enum SomeThing { ABC, CDE }
;
After:
enum SomeThing { ABC, CDE };
llvm-svn: 221125
2014-11-03 03:00:42 +00:00
Daniel Jasper
8022226db7
clang-format: Fix false positive in lambda detection.
...
Before:
delete [] a -> b;
After:
delete[] a->b;
This fixes part of llvm.org/PR21419.
llvm-svn: 221114
2014-11-02 22:46:42 +00:00
Daniel Jasper
df2ff002f0
clang-format: [Java] Support enums without trailing semicolon.
...
Before:
class SomeClass {
enum SomeThing { ABC, CDE } void f() {
}
}
After:
class SomeClass {
enum SomeThing { ABC, CDE }
void f() {
}
}
This fixed llvm.org/PR21458.
llvm-svn: 221113
2014-11-02 22:31:39 +00:00
Daniel Jasper
a3ddf86dd4
clang-format: [Java] Support try/catch/finally blocks.
...
llvm-svn: 221104
2014-11-02 19:21:48 +00:00
Daniel Jasper
50b4bd7c0e
clang-format: [Java] Don't break after extends/implements.
...
Before:
abstract class SomeClass extends SomeOtherClass implements
SomeInterface {}
After:
abstract class SomeClass extends SomeOtherClass
implements SomeInterface {}
llvm-svn: 221103
2014-11-02 19:16:41 +00:00
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