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
Nico Weber
8afb37e1a1
Remove unused parameter, followup to r179639. No behavior change.
...
llvm-svn: 226128
2015-01-15 06:00:15 +00:00
Chandler Carruth
575bc3ba62
[cleanup] Re-sort the #include lines using llvm/utils/sort_includes.py
...
No functionality changed, this is a purely mechanical cleanup to ensure
the #include order remains consistent across the project.
llvm-svn: 225975
2015-01-14 11:23:58 +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
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
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
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
Samuel Benzaquen
b405c08bdb
Add voidType() matcher.
...
Summary: Add voidType() matcher.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6656
llvm-svn: 224250
2014-12-15 15:09:22 +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
Nico Weber
238462627e
clang-format: Add a test for PR19603 which seems fixed (maybe by r221338?).
...
llvm-svn: 223850
2014-12-09 23:22:35 +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
Richard Smith
a2686713ef
Make DiagnosticErrorTrap work even if SuppressAllDiagnostics is enabled.
...
Patch by Brad King!
llvm-svn: 223525
2014-12-05 21:52:58 +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
Alexander Kornienko
74e1c46a50
Make ArgumentsAdjuster an std::function.
...
Reviewers: klimek
Reviewed By: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6505
llvm-svn: 223248
2014-12-03 17:53:02 +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