Daniel Jasper
0955cb41eb
clang-format: FIXME that led to access of uninitialized memory.
...
I have so far not succeeded in finding a nicely reduced test case or an
observable difference which could help me create a test failure without
msan.
Committing without test to unblock kcc's further fuzzing progress.
llvm-svn: 227433
2015-01-29 13:11:47 +00:00
Daniel Jasper
47b35aeaa1
clang-format: Fix crasher caused by not properly setting dry-run.
...
llvm-svn: 227427
2015-01-29 10:47:14 +00:00
Daniel Jasper
d1c13736e0
clang-format: Fix another crasher caused by incomplete macro code.
...
We did't properly mark all of an AnnotatedLine's children as finalized
and thus would reformat the same tokens in different branches of #if/#else
sequences leading to invalid replacements.
llvm-svn: 226930
2015-01-23 19:37:25 +00:00
Daniel Jasper
7509216a41
clang-format: Fix incorrect classification of "*".
...
Before:
*a = b *c;
After:
*a = b * c;
llvm-svn: 226923
2015-01-23 19:04:49 +00:00
Daniel Jasper
e4b48c635c
clang-format: Fix crasher when splitting incomplete escape sequences.
...
llvm-svn: 226698
2015-01-21 19:50:35 +00:00
Daniel Jasper
04b979dd81
clang-format: Fix crasher caused by incorrect resetting of token info.
...
llvm-svn: 226685
2015-01-21 18:35:47 +00:00
Daniel Jasper
d1debfc2bb
clang-format: Fix bad memory access.
...
llvm-svn: 226680
2015-01-21 18:04:02 +00:00
Daniel Jasper
fd725c060b
clang-format: Fix use-heap-after-free bug.
...
Discovered by the awesome test case and ASAN.
llvm-svn: 226678
2015-01-21 17:35:29 +00:00
Daniel Jasper
6fd5d646cc
clang-format: Fix AlwaysBreakBeforeMultilineStrings with ColumnLimit=0
...
Before:
const char *x =
"hello llvm";
After:
const char *x = "hello llvm";
This fixes llvm.org/PR22245.
Patch by Bill Meltsner, thank you!
llvm-svn: 226564
2015-01-20 12:59:20 +00:00
Daniel Jasper
9b79efb51f
clang-format: Fix crasher on weird comments.
...
Crashing input:
/\
/ comment
llvm-svn: 226454
2015-01-19 11:49:32 +00:00
Daniel Jasper
193cdd381b
clang-format: Fix crasher on incomplete condition compilation.
...
Previously crashing input:
void f(
#if A
);
#else
#endif
llvm-svn: 226451
2015-01-19 10:52:16 +00:00
Daniel Jasper
20e8c3be3c
clang-format: Fix crash on invalid code.
...
Input "a<," made clang-format crash.
llvm-svn: 226450
2015-01-19 10:51:42 +00:00
Daniel Jasper
675b4f8350
clang-format: Fix clang-format crash on invalid code.
...
llvm-svn: 226449
2015-01-19 10:51:23 +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
b1567c106f
clang-format: Remove assert that isn't helpful.
...
This assert would trigger on:
#d , = }
llvm-svn: 226446
2015-01-19 10:50:08 +00:00
Daniel Jasper
1cd3c71c01
clang-format: Disable flag for Google's Java and Javascript styles.
...
Disable AlwaysBreakBeforeMultilineString, as the style guides don't
really say to do so.
llvm-svn: 225982
2015-01-14 12:24:59 +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
190fbda6de
clang-format: [Java] Prefer not to break in parameter annotations.
...
Before:
boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
String aaaaa,
String bbbbbbbbbbbbbbb) {}
After:
boolean someFunction(
@Param(aaaaaaaaaaaaaaaa) String aaaaa,
String bbbbbbbbbbbbbbb) {}
llvm-svn: 225971
2015-01-14 10:36:31 +00:00
Daniel Jasper
16dbe0bc44
clang-format: [Java] Understand "import static".
...
llvm-svn: 225965
2015-01-14 10:02:49 +00:00
Daniel Jasper
404658aede
clang-format: [Java] Don't let annotations confuse return type analysis.
...
Before:
@Test
ReturnType
doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
After:
@Test
ReturnType doSomething(
String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
llvm-svn: 225964
2015-01-14 10:00:20 +00:00
Daniel Jasper
3e1bd1407b
clang-format: [Java] Don't line-wrap before annotations' l_parens.
...
Before:
@SomeAnnotation
(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
int i;
After:
@SomeAnnotation(
aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
int i;
llvm-svn: 225963
2015-01-14 09:51:32 +00:00
Daniel Jasper
a831c58e53
clang-format: [Java] Don't get confused by leading annotations.
...
Before:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaa);
After:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 225962
2015-01-14 09:47:57 +00:00
Nico Weber
ed50166b6b
clang-format: [Java] Detect `native` keyword.
...
Before:
public native<X> Foo foo();
After:
public native <X> Foo foo();
llvm-svn: 225839
2015-01-13 22:32:50 +00:00
Alexander Kornienko
00691cf3bb
Fix assertion in BreakableBlockComment ( http://llvm.org/PR21916 ).
...
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6894
llvm-svn: 225628
2015-01-12 13:11:12 +00:00
Daniel Jasper
d6a1cab1bc
clang-format: Improve format of lambdas in ctor initializers.
...
Before:
Constructor()
: Constructor([] { // comment
int i;
}) {}
After:
Constructor()
: Constructor([] { // comment
int i;
}) {}
llvm-svn: 225625
2015-01-12 10:23:24 +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
Nico Weber
beb03938e9
clang-format: [Java] Support formatting qualified annotations.
...
llvm-svn: 225559
2015-01-09 23:25:06 +00:00
Daniel Jasper
d05d3a8919
clang-format: Force line break between "endl" and "<<".
...
This makes piped output easier to read in many instances.
Before:
llvm::errs() << aaaa << std::endl << bbbb << std::endl;
After:
llvm::errs() << aaaa << std::endl
<< bbbb << std::endl;
Also fix a few instance of "don't use else after return" as per the
coding standards.
llvm-svn: 225444
2015-01-08 13:56:57 +00:00
Daniel Jasper
b13135bc08
clang-format: Improve template parameter detection.
...
Before:
struct A < std::enable_if<sizeof(T2) <sizeof(int32)>::type>;
After:
struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>;
llvm-svn: 225435
2015-01-08 08:48:21 +00:00
Nico Weber
ece3d3c26e
clang-format: Let Chromium use the Google default for AlignTrailingComments.
...
r225141 changed the defaults of AllowShortIfStatementsOnASingleLine and
AlignTrailingComments for Google style and added explicit overrides for
Chromium style to undo these changes. For AllowShortIfStatementsOnASingleLine
that's good as the Android style guide (which Chromium uses for Java) explicitly
permits single-line ifs. But it's silent on trailing comments, to it makes
sense for Chromium style to just follow Google style.
llvm-svn: 225363
2015-01-07 18:41:10 +00:00
Daniel Jasper
4953210478
clang-format: Understand single-line comments at the end of blocks.
...
This prevents clang-format from moving/aligning the comment in the
snippet:
void f() {
int i; // some comment
// some unrelated comment
}
llvm-svn: 225352
2015-01-07 14:00:11 +00:00
Daniel Jasper
6a9682038f
clang-format: Fix unary operator detection.
...
Before:
** outparam = 1;
After:
**outparam = 1;
llvm-svn: 225349
2015-01-07 12:19:53 +00:00
Daniel Jasper
77ef2be2e4
clang-format: [Java] Fix incorrect detection of cast.
...
After:
return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaa)
: aaaaaaaaaaaaaaaaaaaaaaa;
After:
return (a instanceof List<?>)
? aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
: aaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 225161
2015-01-05 10:33:39 +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
fd4ed18402
clang-format: [Java] Change a few flags for Google's Java style.
...
No tests added as all of these are already tested separately.
llvm-svn: 225141
2015-01-04 20:40:45 +00:00
Daniel Jasper
428f0b1430
clang-format: Re-enable comment re-indentation for Java/JS.
...
This was broken by r224120.
llvm-svn: 225130
2015-01-04 09:11:17 +00:00
Daniel Jasper
3a623dbd2a
clang-format: Fix incorrect detection of ObjC "in" keyword.
...
Before:
for (auto v : in [1]) { ..
After:
for (auto v : in[1]) { ..
llvm-svn: 224513
2014-12-18 12:11:01 +00:00
NAKAMURA Takumi
e9ac8b4d63
Exclude printLineState() in -Asserts. [-Wunused-function]
...
llvm-svn: 224430
2014-12-17 14:46:56 +00:00
Daniel Jasper
0580ff0ec6
clang-format: Fix incorrect calculation of token lenghts.
...
This led, e.g. to break JavaScript regex literals too early.
llvm-svn: 224419
2014-12-17 09:11:08 +00:00
Alexander Kornienko
732b6bd4d1
Don't break single-line raw string literals.
...
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6636
llvm-svn: 224223
2014-12-14 20:47:11 +00:00
Alexander Kornienko
ff2437fe84
Don't break string literals in Java and JavaScript.
...
The proper way to break string literals in these languages is by inserting a "+"
between parts which we don't support yet. So we disable string literal breaking
until then.
llvm-svn: 224120
2014-12-12 13:03:22 +00:00
Daniel Jasper
11a0ac66e1
clang-format: Revamp nested block formatting.
...
This fixed llvm.org/PR21804 and hopefully a few other strange cases.
Before:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
After:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
llvm-svn: 224112
2014-12-12 09:40:58 +00:00
Daniel Jasper
0df50938be
clang-format: Factor out UnwrappedLineFormatter into a separate file.
...
No functional changes intended.
llvm-svn: 223936
2014-12-10 19:00:42 +00:00
Daniel Jasper
24a147776e
clang-format: Remove a few else after return statements.
...
They are against the LLVM coding conventions. No functional changes
intended.
llvm-svn: 223930
2014-12-10 17:24:34 +00:00
Daniel Jasper
a536df4b28
clang-format: Indent correctly in conditional expressions after return.
...
This only applies when not aligning after the return itself (which is
commonly done for C++.
Before:
return aaaaaaaaaa
? bbbbbbbbbb(
bbbbbb) // This is indented relative to aaaaaaaaaa.
: b;
After:
return aaaaaaaaaa
? bbbbbbbbbb(
bbbbbb)
: b;
llvm-svn: 223694
2014-12-08 21:28:31 +00:00
Daniel Jasper
211e1329cc
clang-format: [Java] Always break after annotations of multiline decls.
...
Before:
@Mock DataLoader loooooooooooooooooooooooader =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
@Mock
DataLoader loooooooooooooooooooooooader =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 223688
2014-12-08 20:08:04 +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
55aed6777f
clang-format: Don't merge lines with comments.
...
Before:
int f() { // comment return 42; }
After:
int f() { // comment
return 42;
}
This fixes llvm.org/PR21769.
llvm-svn: 223609
2014-12-07 16:44:49 +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
a4e55f4d1e
clang-format: [JS] Don't put top-level dict literals on a single line.
...
These are often used for enums which apparently are easier to read if
formatted with one element per line.
llvm-svn: 223367
2014-12-04 16:07:17 +00:00
Daniel Jasper
86ee0b6daa
clang-format: More restrictively classify import declarations.
...
Before:
import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 223345
2014-12-04 08:57:27 +00:00
Daniel Jasper
c095663ec1
clang-format: Fix fake parentheses placement with comments.
...
Before:
return (a > b
// comment1
// comment2
|| c);
After:
return (a > b
// comment1
// comment2
|| c);
llvm-svn: 223234
2014-12-03 14:02:59 +00:00
Daniel Jasper
8379107afe
clang-format: Fix expression parser not closing stuff at end of stmt.
...
Uncovered by a Java test case:
Before:
public some.package.Type someFunction( // comment
int parameter) {}
After:
public some.package.Type someFunction( // comment
int parameter) {}
llvm-svn: 223228
2014-12-03 13:20:49 +00:00
Daniel Jasper
3219e43c94
clang-format: Add option to suppress operator alignment.
...
With alignment:
int aaaaaa = aa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
* cccccccccccccccccccccccccccccccc;
Without alignment:
int aaaaaa = aa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
* cccccccccccccccccccccccccccccccc;
This fixes llvm.org/PR21666.
llvm-svn: 223117
2014-12-02 13:24:51 +00:00
Daniel Jasper
8c6e9ef676
clang-format: precedence-based indentation when breaking before operators.
...
Before:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
== aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
* bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
&& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> ccccccccccccccccccccccccccccccccccccccccc;
After:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
== aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
* bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
&& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> ccccccccccccccccccccccccccccccccccccccccc;
Not particularly pretty, but can probably help to uncover bugs. And if this
bugs somebody, parentheses can help.
llvm-svn: 223111
2014-12-02 09:46:56 +00:00
Daniel Jasper
41368e9e07
clang-format: [JS] Contract fewer functions to a single line.
...
Before:
var someVariable =
function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); };
After:
var someVariable = function(x) {
return x.zIsTooLongForOneLineWithTheDeclarationLine();
};
llvm-svn: 222893
2014-11-27 15:37:42 +00:00
Daniel Jasper
4087432f8b
clang-format: [JS] Try not to break in container literals.
...
Before:
var obj = {
fooooooooo:
function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); }
};
After:
var obj = {
fooooooooo: function(x) {
return x.zIsTooLongForOneLineWithTheDeclarationLine();
}
};
llvm-svn: 222892
2014-11-27 15:24:48 +00:00
Daniel Jasper
7912123893
clang-format: [JS] new and delete are valid function names.
...
Before:
someObject.new ();
someObject.delete ();
After:
someObject.new();
someObject.delete();
llvm-svn: 222890
2014-11-27 14:55:17 +00:00
Daniel Jasper
53c38f4e79
clang-format: [JS] Make Closure module detection more narrow.
...
Before:
var MyLongClassName = goog.module.get('my.long.module.name.followedBy.MyLongClassName');
After:
var MyLongClassName =
goog.module.get('my.long.module.name.followedBy.MyLongClassName');
llvm-svn: 222888
2014-11-27 14:46:03 +00:00
Daniel Jasper
13404dad0d
clang-format: Don't use column layout with AlignAfterOpenBrackets.
...
This fixes llvm.org/PR21676.
llvm-svn: 222886
2014-11-27 14:40:48 +00:00
Daniel Jasper
9b9e07608d
clang-format: [Java] Don't line-wrap package declarations.
...
This fixes llvm.org/PR21677.
llvm-svn: 222843
2014-11-26 18:03:42 +00:00
Nico Weber
450425c980
clang-format: Tweak -style=Chromium for Java files.
...
For Java, don't do any of the deviations from Google Style that Chromium style
does for C++.
Chromium's Java follows Android Java style [1], which is roughly Google Java
style with an indent of 4 and a continuation indent of 8.
1: https://source.android.com/source/code-style.html
llvm-svn: 222839
2014-11-26 16:43:18 +00:00
Daniel Jasper
375815d24b
clang-format: [Java] Improve formatting of throws declarations.
...
Before:
public void doSoooooooooo() throws LoooooooooongException,
LooooooooooongException {}
After:
public void doSoooooooooo()
throws LoooooooooongException, LooooooooooongException {}
llvm-svn: 222829
2014-11-26 12:31:19 +00:00
Daniel Jasper
4f56b0bb88
clang-format: [Java] Improve cast detection.
...
Before:
a[b >> 1] = (byte)(c() << 4);
After:
a[b >> 1] = (byte) (c() << 4);
llvm-svn: 222827
2014-11-26 12:23:10 +00:00
Daniel Jasper
07013a42d2
clang-format: [Java] Fix breaking after annotations.
...
Before:
@Annotation1 // comment
@Annotation2 class C {}
After:
@Annotation1 // comment
@Annotation2
class C {}
llvm-svn: 222825
2014-11-26 11:20:43 +00:00
Daniel Jasper
9e709351c5
clang-format: Add SFS_Empty to only empty functions on a single line.
...
Activated for and tested by Google's Java style.
This fixes llvm.org/PR21667.
llvm-svn: 222819
2014-11-26 10:43:58 +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
a98b7b01be
clang-format: Refactoring.
...
Re-apply r222638 and r222641 without variadic templates.
llvm-svn: 222747
2014-11-25 10:05:17 +00:00
Aaron Ballman
484ee9b404
Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 does not support variadic templates. Also reverting r222641 because it was relying on 222638.
...
llvm-svn: 222656
2014-11-24 15:42:34 +00:00
Daniel Jasper
79f226e780
clang-format: Make short case labels work with #ifs
...
Before:
switch (a) {
#if FOO
case 0: return 0; #endif
}
After:
switch (a) {
#if FOO
case 0: return 0;
#endif
}
This fixed llvm.org/PR21544.
llvm-svn: 222642
2014-11-23 21:45:03 +00:00
Daniel Jasper
325e486f9b
clang-format: [Java] Treat 'instanceof' like other binary operators.
...
This fixes llvm.org/PR21436.
llvm-svn: 222641
2014-11-23 21:34:25 +00:00
Daniel Jasper
a0143fab5e
clang-format: [Java] Space before array initializers.
...
Before:
new int[]{1, 2, 3, 4};
After:
new int[] {1, 2, 3, 4};
llvm-svn: 222640
2014-11-23 20:54:37 +00:00
Daniel Jasper
bb86d847ba
clang-format: Improve ObjC blocks with return type.
...
Before:
Block b = ^int * (A * a, B * b) {}
After:
Block b = ^int *(A *a, B *b) {}
This fixed llvm.org/PR21619.
llvm-svn: 222639
2014-11-23 19:15:35 +00:00
Daniel Jasper
7198b0c778
clang-format: Refactoring.
...
Provide more overloads to simplify testing the type of a token. No
functional changes intended.
llvm-svn: 222638
2014-11-23 19:03:25 +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
4b444495ed
clang-format: Use nested block special case for all languages.
...
Previously this was only used for JavaScript.
Before:
functionCall({
int i;
int j;
},
aaaa, bbbb, cccc);
After:
functionCall({
int i;
int j;
}, aaaa, bbbb, cccc);
llvm-svn: 222531
2014-11-21 13:38:53 +00:00
Daniel Jasper
d081e88e79
clang-format: Handle comments in short case labels.
...
With AllowShortCaseLabelsOnASingleLine set to true:
This gets now left unchanged:
case 1:
// comment
return;
Whereas before it was changed into:
case 1: // comment return;
This fixes llvm.org/PR21630.
llvm-svn: 222529
2014-11-21 12:36:25 +00:00
Daniel Jasper
82c9275344
clang-format: [Java] Support more Java keywords.
...
Before:
public final<X> Foo foo() {
}
public abstract<X> Foo foo();
After:
public final <X> Foo foo() {
}
public abstract <X> Foo foo();
Patch by Harry Terkelsen. Thank you.
llvm-svn: 222527
2014-11-21 12:19:07 +00:00
Daniel Jasper
8354ea84dd
clang-format: [Java] Basic lambda support.
...
llvm-svn: 222524
2014-11-21 12:14:12 +00:00
Daniel Jasper
6cab6784b9
clang-format: [Java] Don't align after "return".
...
Doesn't seem to be common practice in Java.
Before:
return aaaaaaaaaaaaaaaaaaa
&& bbbbbbbbbbbbbbbbbbb
&& ccccccccccccccccccc;
After:
return aaaaaaaaaaaaaaaaaaa
&& bbbbbbbbbbbbbbbbbbb
&& ccccccccccccccccccc;
Patch by Harry Terkelsen.
llvm-svn: 222424
2014-11-20 09:54:49 +00:00
Daniel Jasper
caf8685958
clang-format: [Java] Don't force break before generic type method.
...
Before:
Foo.bar()
.<X>
baz();
After:
Foo.bar()
.<X>baz();
Patch by Harry Terkelsen.
llvm-svn: 222423
2014-11-20 09:48:11 +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
fe2cf6673a
clang-format: [Java] Ignore C++-specific keywords
...
Before:
public void union
(Object o);
public void struct
(Object o);
public void delete (Object o);
After:
public void union(Object o);
public void struct(Object o);
public void delete(Object o);
Patch by Harry Terkelsen, thank you!
llvm-svn: 222357
2014-11-19 14:11:11 +00:00
Daniel Jasper
3aa9a6a126
clang-format: Add option to disable alignment after opening brackets
...
Before:
SomeFunction(parameter,
parameter);
After:
SomeFunction(parameter,
parameter);
Patch by Harry Terkelsen, thank you!
llvm-svn: 222284
2014-11-18 23:55:27 +00:00
Daniel Jasper
6761b42b90
clang-format: Fix space between generic type parameter and square
...
bracket
Before:
public Foo<X, Y> [] foos;
After:
public Foo<X, Y>[] foos;
Patch by Harry Terkelsen. Thank you!
llvm-svn: 222283
2014-11-18 23:48:01 +00:00
Daniel Jasper
e1e348b857
clang-format: Fix more incorrect pointer detection.
...
Before:
Constructor() : a(a), b(c, d *e) {}
After:
Constructor() : a(a), b(c, d * e) {}
llvm-svn: 222158
2014-11-17 18:42:22 +00:00
Daniel Jasper
6a3fd8361f
clang-format: Fix regression introduced in r221609.
...
Before:
void f() { f(a, c *d); }
After:
void f() { f(a, c * d); }
llvm-svn: 222128
2014-11-17 13:55:04 +00:00
Daniel Jasper
4bfa736f1b
clang-format: [Java] Further improve generics formatting.
...
llvm-svn: 222011
2014-11-14 17:30:15 +00:00
Daniel Jasper
d127e3b6af
clang-format: Correctly detect multiplication in ctor initializer.
...
Before:
Constructor() : a(a), area(width *height) {}
After:
Constructor() : a(a), area(width * height) {}
llvm-svn: 222010
2014-11-14 17:26:49 +00:00
Daniel Jasper
6c0ee17b89
clang-format: Improve function parameter packing.
...
Before:
void SomeLoooooooooooongFunction(
std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb);
After:
void SomeLoooooooooooongFunction(
std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaaaa,
int bbbbbbbbbbbbb);
llvm-svn: 221989
2014-11-14 13:14:45 +00:00
Daniel Jasper
6c22c44e12
clang-format: Support assignments as conditional operands.
...
Before:
return a != b
// comment
? a
: a = a != b
// comment
? a =
b : a;
After:
return a != b
// comment
? a
: a = a != b
// comment
? a = b
: a;
llvm-svn: 221987
2014-11-14 13:03:40 +00:00
Daniel Jasper
119ff533e4
clang-format: Improve indentation of comments in expressions.
...
Before:
int i = (a)
// comment
+ b;
return aaaa == bbbb
// comment
? aaaa
: bbbb;
After:
int i = (a)
// comment
+ b;
return aaaa == bbbb
// comment
? aaaa
: bbbb;
llvm-svn: 221985
2014-11-14 12:31:14 +00:00
Daniel Jasper
734d52b58b
clang-format: [Java] Fix line break behavior of class declarations.
...
Change breaking preferences:
1. Break before "extends"
2. Break before "implements"
3. Break within the implements list.
llvm-svn: 221981
2014-11-14 10:15:56 +00:00
Daniel Jasper
09f6abe8d8
clang-format: [Java] Improve generic return type formatting.
...
Before:
public<R> ArrayList<R> get() {
After:
public <R> ArrayList<R> get() {
llvm-svn: 221979
2014-11-14 09:05:32 +00:00
Daniel Jasper
30a2406e65
clang-format: [Java] No altnerative operator names in Java.
...
Before:
someObject.and ();
After:
someObject.and();
llvm-svn: 221978
2014-11-14 09:02:28 +00:00
Daniel Jasper
61d81973c1
clang-format: [Java] Improve formatting of generics.
...
Before:
Function < F, ? extends T > function;
After:
Function<F, ? extends T> function;
llvm-svn: 221976
2014-11-14 08:22:46 +00:00
Nico Weber
34272657de
clang-format: Format extern "C" blocks like namespace blocks.
...
namespace blocks act as if KeepEmptyLinesAtTheStartOfBlocks is always true,
and aren't collapsed to a single line even if they would fit. Do the same
for extern "C" blocks.
Before,
extern "C" {
void ExternCFunction();
}
was collapsed into `extern "C" { void ExternCFunction(); }`. Now it stays like
it was.
Fixes http://crbug.com/432640 and part of PR21419.
llvm-svn: 221897
2014-11-13 16:25:37 +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