summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] Support exporting abstract classes.Daniel Jasper2016-01-121-0/+1
| | | | | | | | | | | Before: export abstract class X {y: number;} (and all sorts of other havoc in more complicated cases). After: export abstract class X { y: number; } llvm-svn: 257451
* clang-format: [JS] Teach clang-format about "export interface".Daniel Jasper2016-01-111-0/+4
| | | | llvm-svn: 257406
* [clang-format] Fix comment aligning when there are changes within the commentBenjamin Kramer2016-01-111-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | As soon as a comment had whitespace changes inside of the token, we couldn't identify the whole comment as a trailing comment anymore and alignment stopped working. Add a new boolean to Change for this special case and fix trailing comment identification to use it. This also changes WhitespaceManager to sum the length of all Changes inside of a token into the first Change. Before this fix int xy; // a int z; //b became int xy; // a int z; // b with this patch we immediately get to: int xy; // a int z; // b Differential Revision: http://reviews.llvm.org/D16058 llvm-svn: 257341
* clang-format: Fix overloading "operator," definitions more thoroughly.Daniel Jasper2016-01-111-1/+1
| | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaa operator,(aaaaaaaaaaaaaaaaaaaaa & aaaaaaaaaaaaaaaaaaaaaaaaaa) const; After: aaaaaaaaaaaaaaaaaaaaaa operator,( aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const; llvm-svn: 257330
* clang-format: Slightly row back on r257257.Daniel Jasper2016-01-111-0/+13
| | | | | | | | | | | | | | | | | | | | | r257257 change the way clang-format enforces line breaks after a templated type has been line-wrapped. This was to fix an incorrect line break if BinPackParameters is set to false. However, it also leads to an unwanted line break in a different case. Thus, for now, only do this when BinPackParameters is false. This isn't ideal yet, but helps us until we have a better solution. With BinPackParameters: Before: void fffffffffff(aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaa> aaaaaaaaaa); After: void fffffffffff( aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaa> aaaaaaaaaa); llvm-svn: 257325
* clang-format: [JS] Improve line-flow when calling functions on array literals.Daniel Jasper2016-01-111-0/+6
| | | | | | | | | | | | | | | | | | | Before: return [ aaaaaaaaaaaaaaaaaaaaaa ].aaaaaaa(function() { // }) .bbbbbb(); After: return [aaaaaaaaaaaaaaaaaaaaaa] .aaaaaaa(function() { // }) .bbbbbb(); llvm-svn: 257324
* clang-format: Fix the counting of leading whitespace in tok::unknown tokensDaniel Jasper2016-01-091-0/+3
| | | | | | | | Previously, all whitespace characters would increase the starting column, which doesn't make sense. This fixes a problem, e.g. with the length calculation in JS template strings. llvm-svn: 257267
* clang-format: Improve selective comment formatting.Daniel Jasper2016-01-091-0/+7
| | | | | | | | | | | | | | | | | | | 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-0/+4
| | | | | | | | | | | | | 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-091-0/+3
| | | | | | | | | | Before: bool operator, (); After: bool operator,(); llvm-svn: 257256
* clang-format: [JS] Support semicolons in TypeScript's TypeMemberLists.Daniel Jasper2016-01-091-0/+8
| | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | | | | | 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/+10
| | | | | | Google configuration so that they aren't line-wrapped. llvm-svn: 257159
* clang-format: [JS] Support more ES6 classes.Daniel Jasper2016-01-081-0/+6
| | | | | | | | | | | | | | | Before: foo = class { constructor() {} } ; After: foo = class { constructor() {} }; llvm-svn: 257154
* clang-format: Fix corner case in one-per-line formatting.Daniel Jasper2016-01-072-0/+13
| | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | 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-0/+1
| | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | | 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-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+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-051-6/+11
| | | | | | | | | | | | | | | 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-0/+1
| | | | llvm-svn: 256759
* clang-format: [JS] Support ES6 exports of array literals.Daniel Jasper2016-01-041-0/+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-0/+2
| | | | | | | | | | | | | | | 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-0/+4
| | | | | | | | | | | | | | 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-0/+9
| | | | | | function calls. llvm-svn: 256740
* clang-format: Fix corner case for lambda assignments.Daniel Jasper2016-01-041-0/+2
| | | | | | | | | | | | 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-041-0/+5
| | | | | | | | | | | | | | | | | | 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-0/+6
| | | | llvm-svn: 256737
* clang-format: [Proto] Improve wrapping of message field attributes.Daniel Jasper2016-01-041-6/+22
| | | | | | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | 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-301-0/+8
| | | | | | | | | | | | | | | | 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-291-0/+1
| | | | | | | | | | | Before: enum: string []; After: enum: string[]; llvm-svn: 256546
* clang-format: Fix incorrect function type detection.Daniel Jasper2015-12-281-0/+1
| | | | | | | | | | Before: int x = f (&h)(); After: int x = f(&h)(); llvm-svn: 256488
* clang-format: [TableGen] Support ;-less include lines.Daniel Jasper2015-12-251-0/+6
| | | | llvm-svn: 256412
* clang-format: Lower penalty for breaking between array subscripts.Daniel Jasper2015-12-231-0/+2
| | | | | | | | | | | | 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-0/+1
| | | | | | | | | | Before: return * this += 1; After: return *this += 1; llvm-svn: 256342
* clang-format: [JS] Support arrays of object-type literals.Daniel Jasper2015-12-221-0/+5
| | | | | | | | | | | | | | | Before: interface I { o: {} []; } After: interface I { o: {}[]; } llvm-svn: 256247
* clang-format: [JS] Conservatively introduce column layout for JS arrayDaniel Jasper2015-12-221-0/+11
| | | | | | | | 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-222-0/+6
| | | | llvm-svn: 256245
* clang-format: Properly set the BlockKind for more blocks.Daniel Jasper2015-12-211-1/+7
| | | | | | | | | | | | | | | 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-0/+11
| | | | | | the main #include. llvm-svn: 256170
* clang-format: [JS] Change Google-style default for aligning operands.Daniel Jasper2015-12-211-8/+8
| | | | | | 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-0/+13
| | | | | | includes. llvm-svn: 256153
* clang-format: Extend detection of the "main" #include to use the filenameDaniel Jasper2015-12-211-5/+25
| | | | | | | | | | | 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
* Fix invalid enum comparison.Zachary Turner2015-12-181-1/+1
| | | | llvm-svn: 256055
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-181-7/+74
| | | | | | | | | | | 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-0/+8
| | | | | | | | | | 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: Add test for AlignAfterOpenBracket = AlwaysBreak in C++.Daniel Jasper2015-12-141-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revision 251405 added AlwaysBreak to support Google's JavaScript style. This changeset complete existing AlignsAfterOpenBracket tests to exercise AlwaysBreak for C++. I thought this would be worthwhile. With this option we can support request from http://lists.llvm.org/pipermail/cfe-dev/2015-May/042942.html, that had been requested a few times. This also partially solve related Bug 23422 and is probably sufficient for most people. AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; BinPackArguments = false; BinPackParameters = false; With these setting we obtain this formatting: void fooWithAVeryLongParamList( int firstParameter, int secondParameter int lastParameter) { object.alsoThisDoenstFitSoIBreakImmidiatly( firstParameter, secondParameter, lastParameter); } Patch by Jean-Philippe Dufraigne, thank you. llvm-svn: 255486
* clang-format: Extend Linux-brace-wrapping test.Daniel Jasper2015-12-141-0/+2
| | | | llvm-svn: 255485
OpenPOWER on IntegriCloud