summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] Test for parameter annotations.Martin Probst2016-04-111-0/+3
| | | | | | | | | | | | Summary: Just to ensure no regressions, this already works fine. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D18950 llvm-svn: 265922
* clang-format: [JS] do not insert semicolons after wrapped annotations.Martin Probst2016-04-111-0/+2
| | | | | | | | | | Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D18943 llvm-svn: 265916
* clang-format: Fix label-in-if statement in macros where it is actually used.Daniel Jasper2016-04-061-0/+6
| | | | | | | | | | | | | | | | Before: #define A \ if (a) \ label: \ f() After: #define A \ if (a) \ label: \ f() llvm-svn: 265557
* clang-format: Support labels in brace-less ifs.Daniel Jasper2016-04-061-0/+6
| | | | | | | | | | | | | | | | While I am not personally convinced about the usefulness of this construct, we should break it. Before: if (a) label: f(); After: if (a) label: f(); llvm-svn: 265545
* clang-format: Fix incorrect function annotation detection.Daniel Jasper2016-04-061-0/+6
| | | | | | | | | | | | | Before: MACRO( abc).function() // wrap << abc; After: MACRO(abc).function() // wrap << abc; llvm-svn: 265540
* clang-format: Fix cast detection on "this".Daniel Jasper2016-04-051-0/+1
| | | | | | | | | | | | Before: auto x = (X) this; After: auto x = (X)this; This fixes llvm.org/PR27198. llvm-svn: 265385
* Added formatAndApplyAllReplacements that works on multiple files in libTooling.Eric Liu2016-03-291-1/+2
| | | | | | | | | | | | | | Summary: formatAndApplyAllReplacements takes a set of Replacements, applies them on a Rewriter, and reformats the changed code. Reviewers: klimek, djasper Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17852 llvm-svn: 264745
* Dsiable FormatStyle::GetStyleOfFile test case for mingw.Eric Liu2016-03-241-1/+1
| | | | llvm-svn: 264289
* Added support for different VFSs in format::getStyle. Disable ↵Eric Liu2016-03-241-0/+34
| | | | | | platform-related test case for MS compilers to avoid breaking buildbot. llvm-svn: 264277
* Revert "Added support for different VFSs in format::getStyle."Eric Liu2016-03-241-28/+0
| | | | | | 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
* Added support for different VFSs in format::getStyle.Eric Liu2016-03-241-0/+28
| | | | | | | | | | | | | | | | 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
* clang-format: [JS] do not wrap ES6 imports/exports.Daniel Jasper2016-03-221-17/+15
| | | | | | | | | "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-211-0/+8
| | | | | | | | | 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-212-1/+22
| | | | | | | | | | 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-0/+12
| | | | | | change affected ranges. llvm-svn: 263713
* clang-format: [JS] Fix incorrect spacing around contextual keywords.Daniel Jasper2016-03-171-0/+4
| | | | | | | | | | Before: x.of (); After: x.of(); llvm-svn: 263710
* clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.Daniel Jasper2016-03-171-5/+24
| | | | | | | | | | | | | | | | | | 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-141-66/+121
| | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | 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/+18
| | | | | | | 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-3/+34
| | | | | | | | | | | | | | | | | | | | | 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-0/+3
| | | | | | Patch by Erik Kessler, thank you. llvm-svn: 262402
* FormatTests: Update libdeps corresponding to r262323.NAKAMURA Takumi2016-03-011-0/+1
| | | | llvm-svn: 262329
* Fix DLL build by adding required dependency.Manuel Klimek2016-03-011-0/+1
| | | | llvm-svn: 262324
* Add functions to apply replacements and reformat them.Manuel Klimek2016-03-012-1/+46
| | | | | | | | | | | | | | | | 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-0/+4
| | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | 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-0/+7
| | | | | | | | | | | | | | | | | 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-0/+17
| | | | | | | | | | | | | | | With this change: SomeFunction( [] { int i; return i; // Format this line. }, [] { return 2; // Don't "fix" this. }); llvm-svn: 262216
* clang-format: [JS] treat forwardDeclare as an import/export statement.Daniel Jasper2016-02-221-0/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 261528
* Remove use of builtin comma operator.Richard Trieu2016-02-181-1/+2
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* clang-format: [JS] Support for (.. of ..) loops.Daniel Jasper2016-02-111-0/+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-0/+7
| | | | | | | | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | Before: f({a}, () => { g(); // }); After: f({a}, () => { g(); // }); llvm-svn: 260060
* clang-format: Fix corner case in template detection.Daniel Jasper2016-02-051-0/+4
| | | | | | | | | | 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-0/+4
| | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | Before: enum?: string []; After: enum?: string[]; llvm-svn: 259628
* clang-format: Make AlignAfterOpenBracket also affect angle brackets.Daniel Jasper2016-02-021-0/+9
| | | | | | Patch by Matthew Whitehead, thank you. llvm-svn: 259487
* clang-format: Fix incorrect pointer detection in lambdas in constructorDaniel Jasper2016-02-011-0/+1
| | | | | | | | | | | | 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-011-0/+6
| | | | llvm-svn: 259352
* clang-format: Fix alignment of trailing multiline columns.Daniel Jasper2016-02-011-0/+8
| | | | llvm-svn: 259351
* clang-format: [JS] Treat "in" as a proper operator.Daniel Jasper2016-02-011-0/+11
| | | | llvm-svn: 259350
* clang-format: [Java] Remove unnecessary line break after complex annotationsDaniel Jasper2016-01-271-0/+3
| | | | | | | | | | | | | | | Before: @Annotation("Some" + " text") List<Integer> list; After: @Annotation("Some" + " text") List<Integer> list; llvm-svn: 258981
* Remove autoconf supportChris Bieneman2016-01-261-19/+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-0/+1
| | | | | | | | | | Before: a[ ::b::c]; After: a[::b::c]; llvm-svn: 258123
* clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.Daniel Jasper2016-01-141-0/+3
| | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | | | 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-132-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud