Daniel Jasper
7a2d60e328
clang-format: Fix bad space before braced initializer.
...
Before:
new int {1};
After:
new int{1};
llvm-svn: 208168
2014-05-07 07:59:03 +00:00
Daniel Jasper
484033b188
clang-format: [JS] Keep space after closure style comments.
...
Before:
var x = /** @type {foo} */ (bar);
After:
var x = /** @type {foo} */(bar);
llvm-svn: 208093
2014-05-06 14:41:29 +00:00
Daniel Jasper
166c19bd37
clang-format: [JS] Keep space between 'return' and '['.
...
llvm-svn: 208090
2014-05-06 14:12:21 +00:00
Dinesh Dwivedi
2e92e66f66
Fixed one issue with casting
...
Before:
(void) SimplifyICmpOperands(Cond, LHS, RHS);
After:
(void)SimplifyICmpOperands(Cond, LHS, RHS);
Differential Revision: http://reviews.llvm.org/D3615
llvm-svn: 208080
2014-05-06 11:46:49 +00:00
Dinesh Dwivedi
13b9b7e0e8
Pulled out cast detection in TokenAnnotator into its own function
...
This is to remove FIXME added in r207964.
Differential Revision: http://reviews.llvm.org/D3619
llvm-svn: 208071
2014-05-06 09:08:34 +00:00
Daniel Jasper
f10a28d705
clang-format: Understand functions with decltype return type.
...
Before:
decltype(long_name_forcing_break)
f() {}
After:
decltype(long_name_forcing_break)
f() {}
llvm-svn: 207965
2014-05-05 13:48:09 +00:00
Dinesh Dwivedi
76f98f8047
Added some heuristics to identify c style casting
...
Before:
void f() { my_int a = (my_int) * b; }
void f() { return P ? (my_int) * P : (my_int)0; }
After:
void f() { my_int a = (my_int)*b; }
void f() { return P ? (my_int)*P : (my_int)0; }
Differential Revision: http://reviews.llvm.org/D3576
llvm-svn: 207964
2014-05-05 13:14:35 +00:00
Daniel Jasper
0e6c51c889
clang-format: Improve understanding of decltype.
...
Before:
SomeFunction([](decltype(x), A * a) {});
After:
SomeFunction([](decltype(x), A *a) {});
llvm-svn: 207961
2014-05-05 12:36:29 +00:00
Daniel Jasper
942d971c84
clang-format: Improve binary operator detection.
...
Before:
*(int *)(p &~3UL) = 0;
After:
*(int *)(p & ~3UL) = 0;
This fixes llvm.org/PR19464.
llvm-svn: 207405
2014-04-28 09:19:28 +00:00
Daniel Jasper
031e2409f9
clang-format: Fixes spaces in case statements.
...
This fixes llvm.org/PR19482.
Before:
switch (a) {
case(B) :
return;
}
After:
switch (a) {
case (B):
return;
}
llvm-svn: 207402
2014-04-28 07:48:36 +00:00
Daniel Jasper
437c3f5188
clang-format: Don't wrap after @interface.
...
This fixes llvm.org/PR19450.
Before:
@interface
BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate,
BookmarkFolderCollectionViewDelegate,
BookmarkMenuViewControllerDelegate,
BookmarkSearchViewControllerDelegate> {
}
After:
@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {
}
llvm-svn: 207400
2014-04-28 07:34:48 +00:00
Chandler Carruth
57f5fbe3b2
[Modules] Update Clang's two files that use DEBUG(...) without defining
...
DEBUG_TYPE to do so. LLVM's Debug.h requires this as of r206822.
llvm-svn: 206823
2014-04-21 22:55:36 +00:00
Daniel Jasper
0e61784ae5
clang-format: Add special case to reduce indentaiton in streams.
...
This is similar to how we treat assignments and seems to be generally
desirable.
Before:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 206384
2014-04-16 12:26:54 +00:00
Daniel Jasper
783bac6bba
clang-format: Understand proto text format without commas.
...
Also removed spaces before colons as they don't seem to be used
frequently.
Before:
optional int32 b = 2
[(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb :
"baz"}];
After:
optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123,
bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}];
llvm-svn: 206269
2014-04-15 09:54:30 +00:00
Daniel Jasper
866468ae4d
clang-format: Fix regression caused by r206165.
...
llvm-svn: 206173
2014-04-14 13:15:29 +00:00
Daniel Jasper
72ab43b28b
clang-format: Fix incorrect &&-detection in macros.
...
Before:
#define A(a, b) (a &&b)
After:
#define A(a, b) (a && b)
This fixes llvm.org/PR19343.
llvm-svn: 206165
2014-04-14 12:50:02 +00:00
Daniel Jasper
c0d606a584
clang-format: Don't allow hanging indentation for operators on new lines
...
Before:
if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
After:
if (aaaaaaaa
&& bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
The same rule has already be implemented for BreakBeforeBinaryOperators
set to false in r205527.
llvm-svn: 206159
2014-04-14 11:08:45 +00:00
Daniel Jasper
35ec2b244a
clang-format: Improve formatting of annotated variables.
...
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =
aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 206155
2014-04-14 08:15:20 +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
f9fc215f82
clang-format: Treat a trailing comment like a trailing comma in braced lists.
...
Before:
static StructInitInfo module = {MODULE_BUILTIN, /* type */
"streams" /* name */
};
After:
static StructInitInfo module = {
MODULE_BUILTIN, /* type */
"streams" /* name */
};
This fixes llvm.org/PR19378.
llvm-svn: 205851
2014-04-09 13:18:49 +00:00
Daniel Jasper
f9a0906b98
clang-format: Allow breaking between trailing annotations in more cases.
...
Before:
void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(
aaaaaaaaaaaaaaa);
After:
void aaaaaaaaaaaaaa(aaaaaaaa aaa) override
AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa);
llvm-svn: 205846
2014-04-09 10:29:11 +00:00
Daniel Jasper
b48d3afcd5
clang-format: Keep more trailing annotations on the same line.
...
More precisely keep all short annotations (<10 characters) on the same
line if possible. Previously, clang-format would only prefer to do so
for "const", "override" and "final". However, it seems to be generally
preferable, especially because some codebases have to wrap those in
macros for backwards compatibility.
Before:
void someLongFunction(int someLongParameter)
OVERRIDE {}
After:
void someLongFunction(
int someLongParameter) OVERRIDE {}
This fixes llvm.org/PR19363.
llvm-svn: 205845
2014-04-09 10:01:49 +00:00
Daniel Jasper
b175d57edc
clang-format: Recognize lists ending in trailing commas correctly.
...
Previously, this did not look through trailing comments leading to a few
formatting oddities.
llvm-svn: 205843
2014-04-09 09:53:23 +00:00
Daniel Jasper
b77105d2ce
clang-format: Fix incorrect multi-block-parameter computation.
...
llvm-svn: 205763
2014-04-08 14:04:31 +00:00
Daniel Jasper
139d4a3875
clang-format: Correctly understand arrays of pointers.
...
Before:
A<int * []> a;
After:
A<int *[]> a;
This fixes llvm.org/PR19360.
llvm-svn: 205761
2014-04-08 13:07:41 +00:00
Daniel Jasper
cc7bf7fda1
clang-format: Understand that "auto" is a type.
...
Before:
MACRO(auto * a);
After:
MACRO(auto *a);
llvm-svn: 205517
2014-04-03 09:00:49 +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
Manuel Klimek
9481556eb6
Get rid of the adapted isLiteral method.
...
We don't want to deviate from clang's standard terminology.
llvm-svn: 204997
2014-03-28 09:27:09 +00:00
Manuel Klimek
1f9d80ac66
Improve handling of bool expressions in template arguments.
...
Now correctly formats:
foo<true && false>();
llvm-svn: 204950
2014-03-27 19:00:52 +00:00
Manuel Klimek
f81e5c0e50
Fix bool expression special case.
...
Clang-format now correctly formats:
some_type<a * b> v;
template <bool a, bool b> typename enabled_if<a && b>::type f() {}
llvm-svn: 204913
2014-03-27 11:17:36 +00:00
Daniel Jasper
c13ee34378
clang-format: Correctly identify ObjC Block with return type.
...
llvm-svn: 204905
2014-03-27 09:43:54 +00:00
Daniel Jasper
a65e887587
clang-format: Fix incorrect &/* detection.
...
Before:
STATIC_ASSERT((a &b) == 0);
After:
STATIC_ASSERT((a & b) == 0);
llvm-svn: 204709
2014-03-25 10:52:45 +00:00
Daniel Jasper
a125d53a7b
clang-format: Let a trailing comma in braced lists enforce linebreaks.
...
Before:
vector<int> x{1, 2, 3, 4, };
After:
vector<int> x{
1, 2, 3, 4,
};
This fixes llvm.org/PR18519.
llvm-svn: 204458
2014-03-21 12:38:57 +00:00
Daniel Jasper
28df0a356e
clang-format: Fix for r204456.
...
llvm-svn: 204457
2014-03-21 12:15:40 +00:00
Daniel Jasper
14e58e5290
clang-format: Preserve meaning of trailing comments on parameters.
...
Formatting:
SomeFunction(a,
b, // comment
c);
Before:
SomeFunction(a, b, // comment
c);
After:
SomeFunction(a,
b, // comment
c);
llvm-svn: 204456
2014-03-21 11:58:45 +00:00
Manuel Klimek
819788da83
Fix crasher bug.
...
Due to not resetting the fake rparen data on the token when iterating
over annotated lines, we would pop the last element of the paren stack.
This patch fixes the underlying root cause, and makes the code more
robust against similar problems in the future:
- reset the first token when iterating on the same annotated lines due
to preprocessor branches
- never pop the last element from the paren stack, so we do not crash,
but rather incorrectly format
- add assert()s so we can figure out if our assumptions are violated
llvm-svn: 204140
2014-03-18 11:22:45 +00:00
Daniel Jasper
c580af96fa
clang-format: Detect weird macro lambda usage.
...
Before:
void f() {
MACRO((const AA & a) { return 1; });
}
After:
void f() {
MACRO((const AA &a) { return 1; });
}
llvm-svn: 203551
2014-03-11 09:29:46 +00:00
Daniel Jasper
84a12e18d3
clang-format: Add spaces between lambdas and comments.
...
Before:
void f() {
bar([]() {}// Does not respect SpacesBeforeTrailingComments
);
}
After:
void f() {
bar([]() {} // Does not respect SpacesBeforeTrailingComments
);
}
This fixes llvm.org/PR19017.
llvm-svn: 203466
2014-03-10 15:06:25 +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
Daniel Jasper
5550de684f
clang-format: Don't wrap "const" etc. of function declarations.
...
Generally people seem to prefer wrapping the first function parameter
over wrapping the trailing tokens "const", "override" and "final". This
does not extend to function-like annotations and probably not to other
non-standard annotations.
Before:
void someLongFunction(int SomeLongParameter)
const { ... }
After:
void someLongFunction(
int SomeLongParameter) const { ... }
llvm-svn: 201504
2014-02-17 07:57:46 +00:00
Daniel Jasper
3a122c029d
clang-format: Fix formatting of class template declaration.
...
Before:
template <class R, class C>
struct Aaaaaaaaaaaaaaaaa<R (C::*)(int)
const> : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};
After:
template <class R, class C>
struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>
: Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};
llvm-svn: 201424
2014-02-14 18:22:40 +00:00
Daniel Jasper
9cc3e97685
clang-format: Fix range-based for-loop formatting.
...
Before:
for (aaaaaaaaa aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaa.aaaaaaaaaaaa()
.aaaaaaaaa()
.a()) {
}
After:
for (aaaaaaaaa aaaaaaaaaaaaaaaaaaaaa :
aaaaaaaaaaaa.aaaaaaaaaaaa().aaaaaaaaa().a()) {
}
llvm-svn: 200968
2014-02-07 10:09:46 +00:00
Daniel Jasper
f24301d79c
clang-format: More custom option fixes for protocol buffer files.
...
Before:
repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {
aaaaaaaaaaaaaaaa : AAAAAAAAAA,
bbbbbbbbbbbbbbbb : BBBBBBBBBB
}];
After:
repeated double value = 1
[(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa : AAAAAAAAAA,
bbbbbbbbbbbbbbbb : BBBBBBBBBB}];
llvm-svn: 200406
2014-01-29 18:52:43 +00:00
Daniel Jasper
6e58feef76
clang-format: Fix formatting of custom proto options.
...
Before:
repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {
aaaaaaaaaaaaaaaaa : AAAAAAAA
}];
After:
repeated double value = 1
[(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}];
llvm-svn: 200405
2014-01-29 18:43:40 +00:00
Daniel Jasper
559b63cbb9
clang-format: Understand __attribute__s preceding parameter lists.
...
Before:
ReturnType __attribute__((unused))
function(int i);
After:
ReturnType __attribute__((unused))
function(int i);
This fixes llvm.org/PR18632.
llvm-svn: 200337
2014-01-28 20:13:43 +00:00
Daniel Jasper
a0e9be2bb2
clang-format: Fix option formatting in protocol buffer files.
...
Before:
optional int32 foo[ default = true, deprecated = true ];
After:
optional int32 foo[default = true, deprecated = true];
llvm-svn: 200327
2014-01-28 18:51:11 +00:00
Daniel Jasper
e9beea24ef
clang-format: Add support for a space after @property
...
Mozilla and WebKit seem to use a space after @property (verified by
grepping their codebases) so we turn this on there as well.
Change by Christian Legnitto. Thank you!
llvm-svn: 200320
2014-01-28 15:20:33 +00:00
Daniel Jasper
ff974ab88a
clang-format: Fix incorrect space removal.
...
Before:
Deleted &operator=(const Deleted &)&= default;
Deleted &operator=(const Deleted &)&&= delete;
After:
Deleted &operator=(const Deleted &)& = default;
Deleted &operator=(const Deleted &)&& = delete;
llvm-svn: 200073
2014-01-25 09:16:02 +00:00
Daniel Jasper
215d6c8c50
clang-format: Treat "." in protos like namespace separators.
...
Before:
optional really.really.long.and.qualified.type.aaaaaaa
.aaaaaaaa another_fiiiiiiiiiiiiiiiiiiiiield = 2;
After:
optional
really.really.long.and.qualified.type.aaaaaaa.aaaaaaaa
another_fiiiiiiiiiiiiiiiiiiiiield = 2;
llvm-svn: 199796
2014-01-22 08:04:52 +00:00
Daniel Jasper
7cfde414e1
clang-format: text following #if is likely an expression.
...
Before:
#if AAAA &&BBBB
After:
#if AAAA && BBBB
llvm-svn: 199713
2014-01-21 08:56:09 +00:00