summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Added support for different VFSs in format::getStyle."Eric Liu2016-03-241-17/+7
| | | | | | This reverts commit r264253. It is breaking the buildbot http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2203 llvm-svn: 264257
* Revert "removed redundant comment in format::getStyle."Eric Liu2016-03-241-1/+2
| | | | | | This reverts commit r264254. llvm-svn: 264256
* removed redundant comment in format::getStyle.Eric Liu2016-03-241-2/+1
| | | | llvm-svn: 264254
* Added support for different VFSs in format::getStyle.Eric Liu2016-03-241-7/+17
| | | | | | | | | | | | | | | | Summary: Previously, format::getStyle assumes that the given file resides in the real file system, which prevents the use of virtual file system in testing etc. This patch adds a parameter in format::getStyle interface so that users can specify the right file system. By default, the file system is the real file system. Reviewers: djasper, klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D18399 llvm-svn: 264253
* Test commit access to clang repo.Eric Liu2016-03-241-0/+1
| | | | | | | | | | | | Summary: Test commit access to clang repo. Reviewers: cfe-commits Subscribers: klimek Differential Revision: http://reviews.llvm.org/D18432 llvm-svn: 264252
* clang-format: [JS] do not wrap ES6 imports/exports.Daniel Jasper2016-03-222-5/+23
| | | | | | | | | "import ... from '...';" and "export ... from '...';" should be treated the same as goog.require/provide/module/forwardDeclare calls. Patch by Martin Probst. llvm-svn: 264055
* clang-format: [JS] no space in union and intersection types.Daniel Jasper2016-03-212-0/+14
| | | | | | | | | The operators | and & in types, as opposed to the bitwise operators, should not have whitespace around them (e.g. `Foo<Bar|Baz>`). Patch by Martin Probst. Thank you. llvm-svn: 263961
* clang-format: Make include sorting's main include detection configurable.Daniel Jasper2016-03-211-2/+9
| | | | | | | | | | This patch adds a regular expression to configure suffixes of an included file to check whether it is the "main" include of the current file. Previously, clang-format has allowed arbitrary suffixes on the formatted file, which is still the case when no IncludeMainRegex is specified. llvm-svn: 263943
* clang-format: [JS] Make requoting of JavaScript string literals onlyDaniel Jasper2016-03-171-78/+88
| | | | | | change affected ranges. llvm-svn: 263713
* clang-format: [JS] Fix incorrect spacing around contextual keywords.Daniel Jasper2016-03-171-2/+5
| | | | | | | | | | Before: x.of (); After: x.of(); llvm-svn: 263710
* clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.Daniel Jasper2016-03-171-1/+11
| | | | | | | | | | | | | | | | | | If a call takes a single argument, using AlwaysBreak can lead to lots of wasted lines and additional indentation without improving the readability in a significant way. Before: caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); After: caaaaaaaaaaaall(caaaaaaaaaaaall(caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); llvm-svn: 263709
* clang-format: [JS] Handle certain cases of ASI.Daniel Jasper2016-03-142-1/+72
| | | | | | | | | | | | | | Automatic Semicolon Insertion can only be properly handled by parsing source code. However conservatively catching just a few, common situations prevents breaking code during development, which greatly improves usability. JS code should still use semicolons, and ASI code should be flagged by a compiler or linter. Patch by Martin Probst. Thank you. llvm-svn: 263470
* clang-format: [JS] Support destructuring assignments in for loops.Daniel Jasper2016-03-051-0/+2
| | | | | | | | | | | | Before: for (let { a, b } of x) { } After: for (let {a, b} of x) { } llvm-svn: 262776
* clang-format: Use stable_sort when sorting #includes.Daniel Jasper2016-03-031-4/+5
| | | | | | | Otherwise, clang-format can output useless replacements in the presence of identical #includes llvm-svn: 262630
* clang-format: [JS] Optionally re-quote string literals.Daniel Jasper2016-03-022-8/+96
| | | | | | | | | | | | | | | | | | | | | Turns "foo" into 'foo' (or vice versa, depending on configuration). This makes it more convenient to follow the Google JavaScript style guide: https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings This functionality is behind the option "JavaScriptQuotes", which can be: * "leave" (no re-quoting) * "single" (change to single quotes) * "double" (change to double quotes) This also changes single quoted JavaScript string literals to be treated as tok::string_literal, not tok::char_literal, which fixes two unrelated tests. Patch by Martin Probst. Thank you. llvm-svn: 262534
* [clang-format] Detect constructor initializers preceded by `noexcept`.Daniel Jasper2016-03-011-1/+1
| | | | | | Patch by Erik Kessler, thank you. llvm-svn: 262402
* Add functions to apply replacements and reformat them.Manuel Klimek2016-03-011-0/+28
| | | | | | | | | | | | | | | | This is a commonly useful feature to have, and we have implemented it multiple times with different kinds of bugs. This implementation centralizes the idea in a set of functions that we can then use from the various tools. Reverts r262234, which is a revert of r262232, and puts the functions into FOrmat.h, as they are closely coupled to clang-format, and we otherwise introduce a cyclic dependency between libFormat and libTooling. Patch by Eric Liu. llvm-svn: 262323
* clang-format: Correctly apply wrap before multi-line RHS rule toDaniel Jasper2016-03-011-1/+1
| | | | | | | | | | | | | | | ternary expressions. Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; llvm-svn: 262293
* clang-format: Increase the penalty for breaking between array subscripts.Daniel Jasper2016-03-011-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa] [a].aaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa][a] .aaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 262292
* clang-format: [JS] Support quoted object literal keys.Daniel Jasper2016-03-011-1/+2
| | | | | | | | | | | | | | | | | Before: var x = { a: a, b: b, 'c': c, }; After: var x = { a: a, b: b, 'c': c, }; llvm-svn: 262291
* clang-format: Don't format unrelated nested blocks.Daniel Jasper2016-02-291-1/+3
| | | | | | | | | | | | | | | With this change: SomeFunction( [] { int i; return i; // Format this line. }, [] { return 2; // Don't "fix" this. }); llvm-svn: 262216
* clang-format: [JS] Add @return to the supported JSDoc pragmas in GoogleDaniel Jasper2016-02-221-1/+1
| | | | | | style. llvm-svn: 261563
* clang-format: [JS] treat forwardDeclare as an import/export statement.Daniel Jasper2016-02-221-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 261528
* clang-format: [JS] Support for (.. of ..) loops.Daniel Jasper2016-02-112-1/+3
| | | | | | | | | | Before: for (var i of[2, 3]) {} After: for (var i of [2, 3]) {} llvm-svn: 260518
* clang-format: Make indentation after "<<" more consistent.Daniel Jasper2016-02-111-3/+9
| | | | | | | | | | | | | | | | | | | | | | Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; llvm-svn: 260517
* clang-format: Make it more expensive to break template parameters.Daniel Jasper2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | In particular, make it more expensive than breaking after the return type of a function definition/declaration. Before: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa< T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); After: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); llvm-svn: 260497
* clang-format: Fix weird alignment when not aligning after brackets.Daniel Jasper2016-02-081-1/+2
| | | | | | | | | | | | | | | | Before: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); After: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); This fixes llvm.org/PR24905. llvm-svn: 260080
* clang-format: [JS] Don't count shortened object literals as blocks.Daniel Jasper2016-02-071-1/+1
| | | | | | | | | | | | | | | Before: f({a}, () => { g(); // }); After: f({a}, () => { g(); // }); llvm-svn: 260060
* clang-format: [JS] Support @see annotations in JSDoc comments in GoogleDaniel Jasper2016-02-071-1/+1
| | | | | | style. llvm-svn: 260057
* clang-format: Fix corner case in template detection.Daniel Jasper2016-02-052-7/+16
| | | | | | | | | | Before: f(a.operator() < A > ()); After: f(a.operator()<A>()); llvm-svn: 259884
* clang-format: Fix formatting of ternary expressions with comments.Daniel Jasper2016-02-031-4/+8
| | | | | | | | | | | | | | Before: int i = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? /*bbbbbbbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb : ccccccccccccccccccccccccccc; After: int i = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? /*bbbbbbbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb : ccccccccccccccccccccccccccc; llvm-svn: 259670
* clang-format: [JS/TypeScript] Support "enum" as an optional property name, too.Daniel Jasper2016-02-031-1/+2
| | | | | | | | | | | Before: enum?: string []; After: enum?: string[]; llvm-svn: 259628
* clang-format: Make AlignAfterOpenBracket also affect angle brackets.Daniel Jasper2016-02-021-1/+2
| | | | | | Patch by Matthew Whitehead, thank you. llvm-svn: 259487
* clang-format: Fix incorrect pointer detection in lambdas in constructorDaniel Jasper2016-02-011-2/+2
| | | | | | | | | | | | initializers. Before: Constructor() : member([](A *a, B * b) {}) {} After: Constructor() : member([](A *a, B *b) {}) {} llvm-svn: 259353
* clang-format: Add option to disable string literal formatting.Daniel Jasper2016-02-012-2/+7
| | | | llvm-svn: 259352
* clang-format: Fix alignment of trailing multiline columns.Daniel Jasper2016-02-011-10/+14
| | | | llvm-svn: 259351
* clang-format: [JS] Treat "in" as a proper operator.Daniel Jasper2016-02-011-0/+10
| | | | llvm-svn: 259350
* clang-format: [Java] Remove unnecessary line break after complex annotationsDaniel Jasper2016-01-271-0/+1
| | | | | | | | | | | | | | | Before: @Annotation("Some" + " text") List<Integer> list; After: @Annotation("Some" + " text") List<Integer> list; llvm-svn: 258981
* Remove autoconf supportChris Bieneman2016-01-261-13/+0
| | | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "This is the way [autoconf] ends Not with a bang but a whimper." -T.S. Eliot Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D16472 llvm-svn: 258862
* Fix formatting of fully qualified names in array subscripts.Manuel Klimek2016-01-191-1/+2
| | | | | | | | | | Before: a[ ::b::c]; After: a[::b::c]; llvm-svn: 258123
* clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.Daniel Jasper2016-01-141-1/+1
| | | | | | | | | | | Before: aaaa[bbbb] .cccc(); After: aaaa[bbbb].cccc(); llvm-svn: 257763
* clang-format: [JS] Fix incorrect line break leading to semicolon insertion.Daniel Jasper2016-01-141-0/+2
| | | | | | | | | | | | | | | | clang-format only works for JavaScript code, if all the semicolons are present anyway, so this linebreak can never be desired. Before (with appropriate statement lengths or column limit): return [ aaa ]; After: return [ aaaa ]; llvm-svn: 257741
* clang-format: [ObjC+JS] Allow bin-packing of array literals.Daniel Jasper2016-01-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After reading the style guides again, they don't actually say how to pack or not pack array literals. Based on some user reports, array initializers can unnecessarily get quite long if they contain many small elements. Array literals with trailing commas are still formatted one per line so that users have a way to opt out of the packing. Before: var array = [ aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa ]; After: var array = [ aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa ]; llvm-svn: 257615
* clang-format: [JS] Support exporting abstract classes.Daniel Jasper2016-01-121-0/+4
| | | | | | | | | | | 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-1/+2
| | | | llvm-svn: 257406
* [clang-format] Fix comment aligning when there are changes within the commentBenjamin Kramer2016-01-112-15/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | | 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-1/+5
| | | | | | | | | | | | | | | | | | | | | 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-4/+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/+2
| | | | | | | | 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
OpenPOWER on IntegriCloud