summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Improve function declaration detection.Daniel Jasper2014-10-281-2/+1
| | | | | | | | | | | | | | | | | Before: ReturnType MACRO FunctionName() {} After: ReturnType MACRO FunctionName() {} This fixes llvm.org/PR21404. I wonder what the motivation for that if-condition was. But as no test breaks, ... llvm-svn: 220801
* clang-format: [ObjC] Add separate flag to control indentation in blocksDaniel Jasper2014-10-282-4/+7
| | | | | | | | | | 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
* clang-format: Don't put functions on a single line in Google's JavaDaniel Jasper2014-10-281-0/+1
| | | | | | style. llvm-svn: 220778
* clang-format: Don't break after very short return types.Daniel Jasper2014-10-271-0/+6
| | | | | | | | | | | | | | Before: void SomeFunction(int parameter); After: void SomeFunction( int parameter); (Unless AlwaysBreakAfterDefinitionReturnType after type is set). llvm-svn: 220686
* clang-format: Fix bad merging of lines in nested blocks.Daniel Jasper2014-10-272-5/+10
| | | | | | | | | | | | | | | Before: SomeFunction([]() { #define A a return 43; }); After: SomeFunction([]() { #define A a return 43; }); llvm-svn: 220684
* clang-format: [Proto] Change formatting text-formatted options.Daniel Jasper2014-10-272-3/+2
| | | | | | | | | | | | | | 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
* clang-format: Fix incorrect space after "<".Daniel Jasper2014-10-231-3/+4
| | | | | | | | | | Before: bool a = 2 <::SomeFunction(); After: bool a = 2 < ::SomeFunction(); llvm-svn: 220505
* clang-format: Use AllowShortBlocksOnASingleLine for ObjC blocks, too.Daniel Jasper2014-10-221-0/+3
| | | | llvm-svn: 220375
* clang-format: Fix incorrect trailing return arrow detection.Daniel Jasper2014-10-221-1/+1
| | | | | | | | | | Before: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {} After: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {} llvm-svn: 220373
* clang-format: [Java] Understand string literal concatenation.Daniel Jasper2014-10-211-0/+3
| | | | | | | | | | | Before: String someString = "abc" + "cde"; After: String someString = "abc" + "cde"; llvm-svn: 220287
* clang-format: [Java] Fix formatting of multiple annotations.Daniel Jasper2014-10-211-1/+2
| | | | | | | | | | | | | | | Before: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } After: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } llvm-svn: 220286
* clang-format: [Java] Fix space in generic method calls.Daniel Jasper2014-10-211-0/+5
| | | | | | | | | | Before: A.<B>doSomething(); After: A.<B>doSomething(); llvm-svn: 220285
* clang-format: [Java] Improve annotation handling.Daniel Jasper2014-10-211-0/+2
| | | | | | | | | | | | Before: @SuppressWarnings( value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") public static int iiiiiiiiiiiiiiiiiiiiiiii; After: @SuppressWarnings(value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") public static int iiiiiiiiiiiiiiiiiiiiiiii; llvm-svn: 220284
* clang-format: [Java] Make annotation formatting more consistent.Daniel Jasper2014-10-211-1/+1
| | | | | | | | | | | | | | | | | Before: DoSomething(new A() { @Override public String toString() { } }); After: DoSomething(new A() { @Override public String toString() { } }); llvm-svn: 220282
* clang-format: [Java] Improve generic support.Daniel Jasper2014-10-211-8/+11
| | | | | | | | | | | | Before: Iterable< ? > a; Iterable< ? extends SomeObject > a; After: Iterable<?> a; Iterable<? extends SomeObject> a; llvm-svn: 220281
* clang-format: [Java] Support extending inner classes.Daniel Jasper2014-10-211-3/+4
| | | | | | | | | | | Before: class A extends B .C {} After: class A extends B.C {} llvm-svn: 220280
* clang-format: [Java] Support annotations with parameters.Daniel Jasper2014-10-211-1/+4
| | | | | | | | | | | | Before: @SuppressWarnings (value = "unchecked") public void doSomething() { .. } After: @SuppressWarnings(value = "unchecked") public void doSomething() { .. } llvm-svn: 220279
* clang-format: [Java] Wrap after each function annotation.Daniel Jasper2014-10-213-1/+10
| | | | | | | | | | | Before: @Override public String toString() { .. } After: @Override public String toString() { .. } llvm-svn: 220274
* clang-format: [ObjC] Fix spacing in block variable parameters.Daniel Jasper2014-10-211-0/+3
| | | | | | | | | | Before: { void (^block)(Object * x); } After: { void (^block)(Object *x); } llvm-svn: 220270
* clang-format: Fix space in direct destructor calls.Daniel Jasper2014-10-211-56/+52
| | | | | | | | | | | | Before: void F(int& i) { i. ~int(); } After: void F(int& i) { i.~int(); } Also, some cleanups. llvm-svn: 220269
* clang-format: Fix overloaded operator edge case.Daniel Jasper2014-10-201-0/+4
| | | | | | | | | | | | | | | | Before: template <class F> void Call(F f) { f.template operator() <int>(); } After: template <class F> void Call(F f) { f.template operator()<int>(); } llvm-svn: 220202
* clang-format: [ObjC] Fix using selector names as macro arguments.Daniel Jasper2014-10-201-0/+5
| | | | | | | | | | Before: [self aaaaa:MACRO(a, b :, c :)]; After: [self aaaaa:MACRO(a, b:, c:)]; llvm-svn: 220197
* clang-format: Fix indentation of struct definitions with array init.Daniel Jasper2014-10-201-6/+2
| | | | | | | | | | | | | | | | | | | | Before: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; After: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; llvm-svn: 220195
* clang-format: Prefer breaking before trailing return arrows.Daniel Jasper2014-10-172-2/+3
| | | | | | | | | | | | Before: auto SomeFunction( A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} After: auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} llvm-svn: 220043
* clang-format: [Java] Don't break immediately after "throws".Daniel Jasper2014-10-171-0/+6
| | | | | | | | | | | | Before: public void doSooooooooooooooooooooooooooomething() throws LooooooooooooooooooooooooooooongException {} After: public void doSooooooooooooooooooooooooooomething() throws LooooooooooooooooooooooooooooongException {} llvm-svn: 220041
* clang-format: Fix behavior with comments before conditional expressionsDaniel Jasper2014-10-161-0/+3
| | | | | | | | | | | | | | | Before: SomeFunction(aaaaaaaaaaaaaaaaa, // comment. ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa : bbbbbbbbbbbbbbbbbbbb); After: SomeFunction(aaaaaaaaaaaaaaaaa, // comment. ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa : bbbbbbbbbbbbbbbbbbbb); llvm-svn: 219921
* clang-format: [ObjC] Fix method expression detection.Daniel Jasper2014-10-161-1/+9
| | | | | | | | | | Before: return (a)[foo bar : baz]; After: return (a)[foo bar:baz]; llvm-svn: 219919
* clang-format: [ObjC] Wrap ObjC method declarations before annotations.Daniel Jasper2014-10-111-0/+5
| | | | | | | | | | | | | Before: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>) y NS_DESIGNATED_INITIALIZER; After: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>)y NS_DESIGNATED_INITIALIZER; llvm-svn: 219564
* clang-format: Add option to control call argument bin-packing separatelyDaniel Jasper2014-10-092-5/+9
| | | | | | | This is desirable for the Chromium style guide: http://www.chromium.org/developers/coding-style llvm-svn: 219400
* clang-format: Fix bug with comments between non-trival parameters.Daniel Jasper2014-10-071-3/+4
| | | | | | | | | | | | | | Before: SomeFunction(a, a, // comment b + x); After: SomeFunction(a, a, // comment b + x); llvm-svn: 219209
* clang-format: If in doubt, assume '+' is a binary operator.Daniel Jasper2014-10-061-2/+3
| | | | | | | | | | Before: #define LENGTH(x, y) (x) - (y)+1 After: #define LENGTH(x, y) (x) - (y) + 1 llvm-svn: 219119
* Format: ArrayRefize some implicit copies away.Benjamin Kramer2014-10-031-8/+8
| | | | | | NFC. llvm-svn: 219000
* clang-format: [JS] Support AllowShortFunctionsOnASingleLine.Daniel Jasper2014-09-302-0/+8
| | | | | | | | | Specifically, this also counts for stuff like (with style "inline"): var x = function() { return 1; }; llvm-svn: 218689
* clang-format: [JS] Improve formatting of function literals in chainsDaniel Jasper2014-09-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* clang-format: Don't let -style=Chromium imply c++03 template formatting.Nico Weber2014-09-241-1/+0
| | | | | | | Chromium's now using some c++11 language features, so it's now fine that clang-format produces vector<vector<int>>. llvm-svn: 218392
* clang-format: [JS] add space before operator 'in'.Daniel Jasper2014-09-191-0/+3
| | | | | | | | | | Before: return ('aaa')in bbbb; After: return ('aaa') in bbbb; llvm-svn: 218119
* clang-format: Prevent column layout if elements aren't uniform enough.Daniel Jasper2014-09-191-2/+10
| | | | | | | | | | | | | | | | | | | | | | | This patch only considers the difference between the length of the shortest and longest element, but we might want to look at other features (token count, etc.) in future. Before: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a}; After: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a}; llvm-svn: 218111
* clang-format: Undo r216377.Daniel Jasper2014-09-191-4/+3
| | | | | | It has proven to not be a food idea in many case. llvm-svn: 218107
* clang-format: Allow unbroken ::: in inline assembly.Daniel Jasper2014-09-161-0/+2
| | | | | | | | | | | | Before: asm volatile("nop" :: : "memory"); After: asm volatile("nop" ::: "memory"); Patch by Eugene Toder. Thank you. llvm-svn: 217883
* clang-format: Basic support for Java.Daniel Jasper2014-09-152-3/+20
| | | | llvm-svn: 217759
* clang-format: Add option to break before non-assignment operators.Daniel Jasper2014-09-152-8/+23
| | | | | | | | | This will allow: int aaaaaaaaaaaaaa = bbbbbbbbbbbbbb + ccccccccccccccc; llvm-svn: 217757
* clang-format: Improve line breaks at function calls.Daniel Jasper2014-09-121-0/+12
| | | | | | | | | | | | | 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
* Fix bug 20892 - clang-format does not handle C-style commentsRoman Kashitsyn2014-09-111-2/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: http://llvm.org/bugs/show_bug.cgi?id=20892 Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported: // clang-format on /* clang-format on */ The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, curdeius, klimek Differential Revision: http://reviews.llvm.org/D5309 llvm-svn: 217588
* clang-format: Add option to allow short case labels on a single line.Daniel Jasper2014-09-101-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | On a single line: switch (a) { case 1: x = 1; return; case 2: x = 2; return; default: break; } Not on a single line: switch (a) { case 1: x = 1; return; case 2: x = 2; return; default: break; } This partly addresses llvm.org/PR16535. In the long run, we probably want to lay these out in columns. llvm-svn: 217501
* clang-format: [JS] Support regex literals with trailing escaped slash.Daniel Jasper2014-09-091-26/+58
| | | | | | | | | | | | | | | | | | Before: var regex = / a\//; int i; After: var regex = /a\//; int i; This required pushing the Lexer into its wrapper class and generating a new one in this specific case. Otherwise, the sequence get lexed as a //-comment. This is hacky, but I don't know a better way (short of supporting regex literals in the Lexer). Pushing the Lexer down seems to make all the call sites simpler. llvm-svn: 217444
* clang-format: [JS] Format embedded function literals more efficently.Daniel Jasper2014-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; After: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; llvm-svn: 217238
* clang-format: [JS] JavaScript does not have the */&/&& madness.Daniel Jasper2014-09-051-0/+3
| | | | | | | | | | | | | Before: e&& e.SomeFunction(); After: e && e.SomeFunction(); Yeah, this might be useful for C++, too, but it is not such a frequent pattern there (plus the fix is much harder). llvm-svn: 217237
* clang-format: [JS] Better support for empty function literals.Daniel Jasper2014-09-051-0/+7
| | | | | | | | | | Before: SomeFunction(function(){}); After: SomeFunction(function() {}); llvm-svn: 217236
* clang-format: [JS] Fix indentation in dict literals.Daniel Jasper2014-09-051-2/+6
| | | | | | | | | | | | | | | | | | Before: return { 'finish': // a }; After: return { 'finish': // a }; llvm-svn: 217235
* clang-format: [JS] Support alternative operator names as identifiers.Daniel Jasper2014-09-041-7/+8
| | | | | | | | | | Before: not. and . or . not_eq = 1; After: not.and.or.not_eq = 1; llvm-svn: 217179
OpenPOWER on IntegriCloud