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
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
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
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
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
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
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
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
e551bb70a3
Revert "clang-format: [js] Updates to Google's JavaScript style."
...
This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b.
Apparently, this change was a bit premature.
llvm-svn: 221365
2014-11-05 17:22:31 +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
39af6cd5a4
clang-format: [Java] Fix class declaration formatting.
...
Before:
@SomeAnnotation()
abstract
class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb implements cccccccccccc {
}
After:
@SomeAnnotation()
abstract class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb
implements cccccccccccc {
}
llvm-svn: 221121
2014-11-03 02:27:28 +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
e9ab42df0c
clang-format: [Java] Improve line breaks around annotations.
...
Before:
@SomeAnnotation("With some really looooooooooooooong text") private static final
long something = 0L;
void SomeFunction(@Nullable
String something) {}
After:
@SomeAnnotation("With some really looooooooooooooong text")
private static final long something = 0L;
void SomeFunction(@Nullable String something) {}
llvm-svn: 220984
2014-10-31 18:23:49 +00:00
Daniel Jasper
f739b0dbfa
clang-format: [js] Updates to Google's JavaScript style.
...
The style guide is changing..
llvm-svn: 220977
2014-10-31 17:50:40 +00:00
Daniel Jasper
50d634b343
clang-format: [ObjC] Add separate flag to control indentation in blocks
...
Apparently, people are very much divided on what the "correct"
indentation is. So, best to give them a choice.
The new flag is called ObjCBlockIndentWidth and the default is now set
to the same value as IndentWidth for the pre-defined styles.
llvm-svn: 220784
2014-10-28 16:53:38 +00:00
Daniel Jasper
e068ac77a2
clang-format: Don't break after very short return types.
...
Before:
void
SomeFunction(int parameter);
After:
void SomeFunction(
int parameter);
(Unless AlwaysBreakAfterDefinitionReturnType after type is set).
llvm-svn: 220686
2014-10-27 17:13:59 +00:00
Daniel Jasper
ce2fdb0a0a
clang-format: [Proto] Change formatting text-formatted options.
...
Before:
optional Type type = 1 [(mutate_options) = {vital : true
abc : false}];
After:
optional Type type = 1 [(mutate_options) = {
vital : true
abc : false
}];
llvm-svn: 220679
2014-10-27 13:25:59 +00:00
Daniel Jasper
fab69ff095
clang-format: [Java] Wrap after each function annotation.
...
Before:
@Override public String toString() { .. }
After:
@Override
public String toString() { .. }
llvm-svn: 220274
2014-10-21 08:24:18 +00:00
Daniel Jasper
18210d7d2f
clang-format: Add option to control call argument bin-packing separately
...
This is desirable for the Chromium style guide:
http://www.chromium.org/developers/coding-style
llvm-svn: 219400
2014-10-09 09:52:05 +00:00
Daniel Jasper
4281c5ae01
clang-format: Fix bug with comments between non-trival parameters.
...
Before:
SomeFunction(a, a,
// comment
b + x);
After:
SomeFunction(a, a,
// comment
b + x);
llvm-svn: 219209
2014-10-07 14:45:34 +00:00
Daniel Jasper
1779d438bc
clang-format: [JS] Improve formatting of function literals in chains
...
Before:
getSomeLongPromise(.....)
.then(
function(value) {
body();
body();
})
.thenCatch(function(error) {
body();
body();
});
After:
getSomeLongPromise(.....)
.then(function(value) {
body();
body();
})
.thenCatch(function(error) {
body();
body();
});
llvm-svn: 218595
2014-09-29 07:54:54 +00:00
Daniel Jasper
a41aa536dc
clang-format: Undo r216377.
...
It has proven to not be a food idea in many case.
llvm-svn: 218107
2014-09-19 08:01:25 +00:00
Daniel Jasper
d6f17d83a3
clang-format: Improve line breaks at function calls.
...
Before:
EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly(
Return(SomeValue));
After:
EXPECT_CALL(SomeObject, SomeFunction(Parameter))
.Times(2)
.WillRepeatedly(Return(SomeValue));
llvm-svn: 217687
2014-09-12 16:35:28 +00:00
Daniel Jasper
90ebc98e3d
clang-format: [JS] Format embedded function literals more efficently.
...
Before:
return {
a: a,
link:
function() {
f(); //
},
link:
function() {
f(); //
}
};
After:
return {
a: a,
link: function() {
f(); //
},
link: function() {
f(); //
}
};
llvm-svn: 217238
2014-09-05 09:27:38 +00:00
Daniel Jasper
7189fb2cf9
clang-format: Improve formatting of nested builder-type calls.
...
Before:
f(FirstToken->WhitespaceRange.getBegin().getLocWithOffset(
First->LastNewlineOffset));
After:
f(FirstToken->WhitespaceRange.getBegin()
.getLocWithOffset(First->LastNewlineOffset));
llvm-svn: 216377
2014-08-25 08:48:17 +00:00
Daniel Jasper
316ab38ed8
clang-format: Fix indentation in multi-line placement new.
...
Before:
auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
typename aaaaaaaaaaaaaaaaaaaaaaaa();
After:
auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
typename aaaaaaaaaaaaaaaaaaaaaaaa();
llvm-svn: 214964
2014-08-06 13:14:58 +00:00
Daniel Jasper
a382cbe4eb
clang-format: [proto] Improve formatting of text-proto options.
...
Initial patch and tests by Kaushik Sridharan, thank you!
llvm-svn: 214084
2014-07-28 14:08:09 +00:00
Daniel Jasper
fcfac10c8a
clang-format: Improve heuristic around avoiding bad line breaks.
...
Now, this can be properly formatted:
static_cast<A< //
B> *>( //
);
Before, clang-format could end up, not formatting the code at all.
llvm-svn: 213055
2014-07-15 09:00:34 +00:00
Daniel Jasper
c75e1effed
clang-format: Add new option to indent wrapped function declarations.
...
Though not completely identical, make former
IndentFunctionDeclarationAfterType change this flag for backwards
compatibility (it is somewhat close in meaning and better the err'ing on
an unknown config flag).
llvm-svn: 212597
2014-07-09 08:42:42 +00:00
Daniel Jasper
4355e7f0ef
clang-format: Revamp function declaration/definition indentation.
...
Key changes:
- Correctly (well ...) distinguish function declarations and variable
declarations with ()-initialization.
- Don't indent when breaking function declarations/definitions after the
return type.
- Indent variable declarations and typedefs when breaking after the
type.
This fixes llvm.org/PR17999.
llvm-svn: 212591
2014-07-09 07:50:33 +00:00
Daniel Jasper
17062ff550
clang-format: [JS] Treat dict literals similar to objc method exprs.
...
Before:
return {
link:
function() {
f(); //
}
};
return {
a: a,
link: function() {
f(); //
}
}
After:
return {
link: function() {
f(); //
}
};
return {
a: a,
link: function() {
f(); //
}
};
llvm-svn: 210537
2014-06-10 14:44:02 +00:00
Daniel Jasper
908180574e
clang-format: Fix enum formatting with specific comment.
...
Before:
enum Fruit { //
APPLE,
PEAR };
After:
enum Fruit { //
APPLE,
PEAR
};
llvm-svn: 210522
2014-06-10 10:42:26 +00:00
Daniel Jasper
3251fff0e3
clang-format: Handle multiline strings inside ternary expressions.
...
With AlwaysSplitBeforeMultilineStrings, clang-format would not find any
valid solution.
llvm-svn: 210513
2014-06-10 06:27:23 +00:00
Daniel Jasper
a69ca9be12
clang-format: Leave empty lines within UnwrappedLines.
...
These are commonly used to structure things like enums or long braced
lists. There doesn't seem to be a good reason to have the behavior in
such structures be different from the behavior between statements.
llvm-svn: 210183
2014-06-04 12:40:57 +00:00
Daniel Jasper
114a2bc9d2
clang-format: Refactor indentation behavior for multiple nested blocks.
...
This fixes a few oddities when formatting multiple nested JavaScript
blocks, e.g.:
Before:
promise.then(
function success() {
doFoo();
doBar();
},
[], function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
After:
promise.then(
function success() {
doFoo();
doBar();
},
[],
function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
llvm-svn: 210097
2014-06-03 12:02:45 +00:00
Daniel Jasper
335ff26631
clang-format: Format array and dict literals similar to blocks.
...
Especially, reduce the amount of indentation if it doesn't increase
readability.
Before:
NSMutableDictionary* dictionary = [NSMutableDictionary
dictionaryWithDictionary:@{
aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbb : bbbbb,
cccccccccccccccc : ccccccccccccccc
}];
After:
NSMutableDictionary* dictionary =
[NSMutableDictionary dictionaryWithDictionary:@{
aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbb : bbbbb,
cccccccccccccccc : ccccccccccccccc
}];
llvm-svn: 209720
2014-05-28 09:11:53 +00:00
Daniel Jasper
60553be5fd
clang-format: Split up moveStateToNextToken.
...
No functional changes intended.
llvm-svn: 209626
2014-05-26 13:10:39 +00:00
Daniel Jasper
2a958321c8
clang-format: Fix corner case working around one-per-line dict literals.
...
Before:
var object_literal_with_long_name = {
a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb'
};
After:
var object_literal_with_long_name = {
a: 'aaaaaaaaaaaaaaaaaa',
b: 'bbbbbbbbbbbbbbbbbb'
};
llvm-svn: 209296
2014-05-21 13:26:58 +00:00
Daniel Jasper
b16b969d7c
clang-format: [JS] Support different function literal style.
...
Before:
goog.array.forEach(array, function() {
doSomething();
doSomething();
},
this);
After:
goog.array.forEach(array, function() {
doSomething();
doSomething();
}, this);
llvm-svn: 209291
2014-05-21 12:51:23 +00:00
Daniel Jasper
7f0c517168
clang-format: Don't force line breaks in ObjC calls with ColumnLimit 0.
...
Before:
[self.x a:b c:d];
Got reformatted toi (with ColumnLimit set to 0):
[self.x a:b
c:d];
llvm-svn: 209114
2014-05-19 08:06:34 +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
05cd586863
clang-format: Cleanup redundant calculation of ParenLevel.
...
No functional changes intended.
llvm-svn: 208304
2014-05-08 12:21: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
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
0db806b7f9
Fix typo (first commit to test commit access).
...
llvm-svn: 207775
2014-05-01 17:19:34 +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