summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Make clang::format::reformat work with non 0-terminated strings.Daniel Jasper2016-01-091-2/+3
| | | | llvm-svn: 257259
* clang-format: Improve selective comment formatting.Daniel Jasper2016-01-091-7/+14
| | | | | | | | | | | | | | | | | | | Starting here: int x; // Format this line only. int xx; // int xxxxx; // Before: int x; // Format this line only. int xx; // int xxxxx; // After: int x; // Format this line only. int xx; // int xxxxx; // llvm-svn: 257258
* clang-format: Fix incorrect line break in certain configurations.Daniel Jasper2016-01-091-1/+2
| | | | | | | | | | | | | Before: void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, vector<int> bbbbbbbbbbbbbbb); After: void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, vector<int> bbbbbbbbbbbbbbb); llvm-svn: 257257
* clang-format: Support definitions/declarations of operator,.Daniel Jasper2016-01-092-4/+6
| | | | | | | | | | Before: bool operator, (); After: bool operator,(); llvm-svn: 257256
* clang-format: [JS] Support semicolons in TypeScript's TypeMemberLists.Daniel Jasper2016-01-092-44/+68
| | | | | | | | | | | | | | Before: var x: { a: string; b: number; } = {}; After: var x: {a: string; b: number;} = {}; llvm-svn: 257255
* clang-format: [JS] Prefer wrapping before the TypeScript return typeDaniel Jasper2016-01-081-1/+1
| | | | | | | | | | | | | | over wrapping before parameters. Before: function someFunc( args: string[]): {longReturnValue: string[]} {} After: function someFunc(args: string[]): {longReturnValue: string[]} {} llvm-svn: 257162
* clang-format: [JS] Add some Closure Compiler JSDoc tags to the defaultDaniel Jasper2016-01-081-0/+1
| | | | | | Google configuration so that they aren't line-wrapped. llvm-svn: 257159
* clang-format: [JS] Support more ES6 classes.Daniel Jasper2016-01-081-0/+2
| | | | | | | | | | | | | | | Before: foo = class { constructor() {} } ; After: foo = class { constructor() {} }; llvm-svn: 257154
* clang-format: Fix corner case in one-per-line formatting.Daniel Jasper2016-01-071-1/+1
| | | | | | | | | | | | | | | | | | | Before (example is JS, but also applies to C++): return [ aaaa() .bbbbbbbb('A'), aaaa().bbbbbbbb('B'), aaaa().bbbbbbbb('C'), ]; After: return [ aaaa().bbbbbbbb('A'), aaaa().bbbbbbbb('B'), aaaa().bbbbbbbb('C'), ]; llvm-svn: 257079
* clang-format: Support weird lambda macros.Daniel Jasper2016-01-071-0/+12
| | | | | | | | | | Before: MACRO((AA & a) { return 1; }); After: MACRO((AA &a) { return 1; }); llvm-svn: 257062
* clang-format: [JS] Support more ES6 imports.Daniel Jasper2016-01-071-8/+7
| | | | | | | | | | | Before: import a, {X, Y} from 'some/module.js'; After: import a, {X, Y} from 'some/module.js'; llvm-svn: 257038
* clang-format: Fix corner case in "if it saves columns"-calculation.Daniel Jasper2016-01-051-1/+1
| | | | | | | | | | | | | | | Before: aaaa .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256841
* clang-format: Handle \n the same way as std::endl with stream operator.Daniel Jasper2016-01-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang-format breaks multi-line streams after std::endl. It now also break for '\n', the suggested replacement for std::endl: http://llvm.org/docs/CodingStandards.html#avoid-std-endl Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb << '\n'; llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb << "bbbbbbbbbbbbbbbbbb\n"; After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb << '\n'; llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb << "bbbbbbbbbbbbbbbbbb\n"; This changeset ensure that multiline streams have a line break after: - std::endl - '\n' - "\n" - "Some Text\n" Patch by Jean-Philippe Dufraigne, thank you. llvm-svn: 256832
* clang-format: Avoid creating hanging indents in call sequences.Daniel Jasper2016-01-051-0/+10
| | | | | | | | | | | | | | Before: aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaa) .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaaaaaaaaaaaa .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa) .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256831
* clang-format: Improve line wrapping behavior in call sequences.Daniel Jasper2016-01-053-8/+18
| | | | | | | | | | | | | | | r256750 has been leading to an undesired behavior: aaaaaaaaaa .aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); This change increases penalty for wrapping before member accesses that aren't calls. Thus, this is again formatted as (as it has been before r256750): aaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256830
* clang-format: [JS] Support more ES6 default exports.Daniel Jasper2016-01-041-2/+3
| | | | llvm-svn: 256759
* clang-format: [JS] Support ES6 exports of array literals.Daniel Jasper2016-01-041-1/+5
| | | | | | | | | | | | | | | | Before: export default[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]; export default[]; After: export default [ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ]; export default []; llvm-svn: 256758
* clang-format: [JS] Improve empty array literal detection.Daniel Jasper2016-01-041-3/+3
| | | | | | | | | | | | | | | Previously, the [] in the following example were recognized as an array subscript leading to weird indentation. Before: var aaaa = aaaaa || // wrap []; After: var aaaa = aaaaa || // wrap []; llvm-svn: 256753
* clang-format: Fix corner case in builder-type call formatting.Daniel Jasper2016-01-041-1/+1
| | | | | | | | | | | | | | Before: return aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa) .aaaa(aaaaaaaaaaaaaa); After: return aaaaaaaaaaaaaaaa .aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa) .aaaa(aaaaaaaaaaaaaa); llvm-svn: 256750
* clang-format: Align long braced init lists even if they are nested inDaniel Jasper2016-01-041-4/+6
| | | | | | function calls. llvm-svn: 256740
* clang-format: Fix corner case for lambda assignments.Daniel Jasper2016-01-041-1/+1
| | | | | | | | | | | | Before: std::function<std::string(const std::string &)> my_lambda = []( const string &s) { return s; }; After: std::function<std::string(const std::string &)> my_lambda = [](const string &s) { return s; }; llvm-svn: 256739
* clang-format: Fix corner-case in ObjC method declaration formattingDaniel Jasper2016-01-042-9/+8
| | | | | | | | | | | | | | | | | | Before: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } After: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } llvm-svn: 256738
* clang-format: [Proto] Basic support for options with <> for repeated fields.Daniel Jasper2016-01-041-3/+4
| | | | llvm-svn: 256737
* clang-format: [Proto] Improve wrapping of message field attributes.Daniel Jasper2016-01-042-6/+8
| | | | | | | | | | | | | | | | | | | | | | | Before: optional AAA aaa = 1 [foo = { key: "a" // }, bar = { key: "a" // }]; After: optional AAA aaa = 1 [ foo = { key: "a" // }, bar = { key: "a" // } ]; llvm-svn: 256736
* clang-format: Slightly row back on r256343 by increasing penalty forDaniel Jasper2015-12-301-1/+3
| | | | | | | | | | | | | breaking between array subscripts. Before: if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa] [aaaaaaaaaaaaa]) After: if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa]) llvm-svn: 256640
* clang-format: [JS] Support TypeScript 1.6 user defined type guards.Daniel Jasper2015-12-302-0/+6
| | | | | | | | | | | | | | | | Before: function foo(check: Object): check is{foo: string, bar: string, baz: string, foobar: string} { return 'bar' in check; } After: function foo(check: Object): check is {foo: string, bar: string, baz: string, foobar: string} { return 'bar' in check; } llvm-svn: 256631
* clang-format: [JS/TypeScript] Support "enum" as property name.Daniel Jasper2015-12-292-8/+17
| | | | | | | | | | | Before: enum: string []; After: enum: string[]; llvm-svn: 256546
* clang-format: Fix incorrect function type detection.Daniel Jasper2015-12-281-15/+8
| | | | | | | | | | Before: int x = f (&h)(); After: int x = f(&h)(); llvm-svn: 256488
* clang-format: [TableGen] Support ;-less include lines.Daniel Jasper2015-12-252-8/+17
| | | | llvm-svn: 256412
* clang-format: Lower penalty for breaking between array subscripts.Daniel Jasper2015-12-231-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)][bbbbbbbbbbb( bbbbbbbbbbbb)] After: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)] [bbbbbbbbbbb(bbbbbbbbbbbb)] llvm-svn: 256343
* clang-format: Fix incorrect pointer detection.Daniel Jasper2015-12-231-1/+1
| | | | | | | | | | Before: return * this += 1; After: return *this += 1; llvm-svn: 256342
* Disable include sorting by default for Chromium style.Nico Weber2015-12-221-0/+1
| | | | | | | | | | | Include sorting generally can break .cc files, especially on Windows. Make this opt-in for Chromium style to give us some more time to roll this out. (Given that the Google style guide is used by many companies, some of them probably writing code on Windows, one could argue this should be opt-in in general...) llvm-svn: 256288
* clang-format: [JS] Support arrays of object-type literals.Daniel Jasper2015-12-221-1/+1
| | | | | | | | | | | | | | | Before: interface I { o: {} []; } After: interface I { o: {}[]; } llvm-svn: 256247
* clang-format: [JS] Conservatively introduce column layout for JS arrayDaniel Jasper2015-12-221-4/+12
| | | | | | | | initializers. For now, only use it for 20 items or more. Otherwise, clang-format formats these one-per-line and thus increases the vertical code size a lot. llvm-svn: 256246
* clang-format: [JS] "operator" is not a keyword in Java/JavaScript.Daniel Jasper2015-12-221-2/+4
| | | | llvm-svn: 256245
* clang-format: Properly set the BlockKind for more blocks.Daniel Jasper2015-12-211-1/+3
| | | | | | | | | | | | | | | Before: void f() { struct Dummy { }; f(); } After: void f() { struct Dummy {}; f(); } llvm-svn: 256175
* clang-format: Only consider the first #include that looks right to beDaniel Jasper2015-12-211-3/+6
| | | | | | the main #include. llvm-svn: 256170
* clang-format: [JS] Change Google-style default for aligning operands.Daniel Jasper2015-12-211-0/+1
| | | | | | The style guide allows both, but apparently, this is the more dominant use. llvm-svn: 256154
* clang-format: Only try to find the "main" include in the first block ofDaniel Jasper2015-12-211-1/+4
| | | | | | includes. llvm-svn: 256153
* clang-format: Extend detection of the "main" #include to use the filenameDaniel Jasper2015-12-211-18/+16
| | | | | | | | | | | Before, the first (non-system) header in a file was considered to be the main include. This is conservative as it makes clang-format change the #include order less often. Instead implement some basic usage of the filename itself. With this patch, clang-format considers every header to be a main include if the header file's basename is a prefix to the filename the #include is in. llvm-svn: 256148
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-184-13/+72
| | | | | | | | | | | This changes the behavior of AlwaysBreakAfterDeclarationReturnType so that it supports breaking after declarations, definitions, or both. Differential Revision: http://reviews.llvm.org/D10370 Reviewed By: Daniel Jasper llvm-svn: 256046
* clang-format: Extend header sort category implementation.Daniel Jasper2015-12-161-3/+3
| | | | | | | | | | Specifically, it is sometimes necessary to keep certain #includes as the first #include, even before the main #include for a .cc file. Switching the category to be signed instead of unsigned isn't ideal, but it seems as good of an option as any and is fully backwards compatible. llvm-svn: 255757
* clang-format: Fix style default for WebKit and Linux styles.Daniel Jasper2015-12-141-2/+0
| | | | | | | | Brought up in codereviews: http://reviews.llvm.org/D15445 http://reviews.llvm.org/D15485 llvm-svn: 255484
* clang-format: Make wrapping after "./->" cheaper, even if the elementDaniel Jasper2015-12-071-4/+14
| | | | | | | | | | | | | | | | | | | before it is not a closing parenthesis. Otherwise, this frequently leads to "hanging" indents that users perceive as "weird". Before: return !soooooooooooooome_map.insert( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; After: return !soooooooooooooome_map .insert(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; llvm-svn: 254933
* clang-format: Make it possible to turn off comment reflowing.Daniel Jasper2015-12-012-3/+7
| | | | llvm-svn: 254414
* clang-format: treat Q_SIGNALS as an access modifierDaniel Jasper2015-12-013-3/+6
| | | | | | Patch by Alexander Richardson, thank you! llvm-svn: 254407
* This fixes https://llvm.org/bugs/show_bug.cgi?id=25329, as well asDaniel Jasper2015-12-012-202/+133
| | | | | | | | | | | misalignments like the following: int a, b = 2; int c = 3; Patch by Beren Minor, thanks! llvm-svn: 254406
* clang-format: Re-add code path deleted in r253873 and add missing test.Daniel Jasper2015-11-231-0/+9
| | | | llvm-svn: 253900
* clang-format: Signficantly refactor the cast detection.Daniel Jasper2015-11-231-49/+60
| | | | | | No functional changes intended. llvm-svn: 253873
* clang-format: Fix incorrect cast detection.Daniel Jasper2015-11-231-17/+15
| | | | | | | | | | Before: bool b = f(g<int>)&&c; After: bool b = f(g<int>) && c; llvm-svn: 253872
OpenPOWER on IntegriCloud