summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] handle conditionals in fields, default params.Martin Probst2016-06-231-1/+9
| | | | | | | | | | | | Summary: Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21658 llvm-svn: 273619
* clang-format: [JS] recognize more type locations.Martin Probst2016-06-231-0/+6
| | | | | | | | | | | | Summary: Includes parenthesized type expressions and type aliases. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21597 llvm-svn: 273603
* clang-format: [Proto] Use more compact format for text-formatted optionsDaniel Jasper2016-06-231-5/+5
| | | | | | | | | | | | | | | | | Before: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; After: enum Type { UNKNOWN = 0 [(some_options) = {a: aa, b: bb}]; }; llvm-svn: 273553
* clang-format: [JS] Do not break before 'as'.Martin Probst2016-06-221-2/+5
| | | | | | | | | | | | | | Summary: 'as' is a pseudo operator, so automatic semicolon insertion kicks in and the code fails to part. Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D21576 llvm-svn: 273422
* clang-format: [Proto] Fix "import public" after r273179.Daniel Jasper2016-06-201-0/+6
| | | | llvm-svn: 273196
* clang-format: [Proto] Don't do bad things if imports are missing ;.Daniel Jasper2016-06-201-0/+15
| | | | llvm-svn: 273179
* [clang-format] do not add existing includes.Eric Liu2016-06-141-0/+23
| | | | | | | | | | | | Summary: do not add existing includes. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21323 llvm-svn: 272669
* clang-format: [JS] Fix failing format with TypeScript casts.Daniel Jasper2016-06-141-0/+4
| | | | | | | | | | | | Before, this could be formatted at all (with BracketAlignmentStyle AlwaysBreak): foo = <Bar[]>[ 1, /* */ 2 ]; llvm-svn: 272668
* clang-format: [JS] Support annotated classes.Daniel Jasper2016-06-141-0/+5
| | | | llvm-svn: 272654
* clang-format: [JS] Indent namespaces in JavaScript/TS by default.Martin Probst2016-06-131-0/+9
| | | | | | | | | | | | Summary: There's no convention of avoiding the nested indentation. Reviewers: djasper Subscribers: klimek, alexeagle, cfe-commits Differential Revision: http://reviews.llvm.org/D21275 llvm-svn: 272559
* clang-format: [JS] Introduce JavaScriptWrapImports option.Martin Probst2016-06-132-7/+28
| | | | | | | | | | | | | | Summary: When turned on, clang-format wraps JavaScript imports (and importing exports), instead of forcing the entire import statement onto one line. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21273 llvm-svn: 272558
* clang-format: Restrict r272537 to function ref qualifiers.Daniel Jasper2016-06-131-0/+1
| | | | | | | | | | | | Seems this isn't generally desirable. Before: int const * a; After: int const* a; llvm-svn: 272548
* clang-format: Fix incorrect function type detection.Daniel Jasper2016-06-131-0/+1
| | | | | | | | | | Before: returnsFunction (&param1, &param2)(param); After: returnsFunction(&param1, &param2)(param); llvm-svn: 272538
* clang-format: Don't merge const and &, e.g. in function ref qualifiers.Daniel Jasper2016-06-131-0/+2
| | | | | | | | | | | | | | | | | Before (when aligning & to the right): SomeType MemberFunction(const Deleted &) const&; After: SomeType MemberFunction(const Deleted &) const &; This also applies to variable declarations, e.g.: int const * a; However, this form is very uncommon (most people would write "const int* a" instead) and contracting to "const*" might actually send the wrong signal of what the const binds to. llvm-svn: 272537
* clang-format: Fix incorrect cast detection.Daniel Jasper2016-06-131-0/+1
| | | | | | | | | | Before: auto s = sizeof...(Ts)-1; After: auto s = sizeof...(Ts) - 1; llvm-svn: 272536
* clang-format: Don't indent lambda body relative to its return type.Daniel Jasper2016-06-131-0/+4
| | | | | | | | | | | | | | | | Before: []() // -> int { return 1; // }; After: []() // -> int { return 1; // }; llvm-svn: 272535
* clang-format: [JS] post-fix non-null assertion operator.Martin Probst2016-06-131-0/+9
| | | | | | | | | | | | | | Summary: Do not insert whitespace preceding the "!" postfix operator. This is an incomplete fix, but should cover common usage. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D21204 llvm-svn: 272524
* clang-format: [JS] recognized named functions in AnnotatingParser.Martin Probst2016-06-091-0/+2
| | | | | | | | | | | | | | | Summary: This also fixes union type formatting in function parameter types. Before: function x(path: number| string) {} After: function x(path: number|string) {} Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21206 llvm-svn: 272330
* clang-format: [JS] fix an assertion failure caused by shrinking sources.Martin Probst2016-06-081-0/+13
| | | | | | | | | | | | | | | | | | Summary: The JavaScript import sorter has a corner condition that can cause the overall source text length to shrink. This change circumvents the issue by appending trailing space in the line after the import blocks to match at least the previous source code length. This needs a better long term fix, but this fixes the immediate issue. Reviewers: alexeagle, djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D21108 llvm-svn: 272142
* clang-format: Fix incorrect calculation of "length" of /**/ comments.Daniel Jasper2016-06-081-0/+8
| | | | | | This could lead to column limit violations. llvm-svn: 272125
* clang-format: Fix bug in function ref qualifier identification.Daniel Jasper2016-06-081-0/+1
| | | | | | | | | | | | | | .. and simplify it. Before: void A::f()&& {} void f() && {} After: void A::f() && {} void f() && {} llvm-svn: 272124
* [clang-format] make header guard identification stricter (with Lexer).Eric Liu2016-06-061-0/+80
| | | | | | | | | | | | Summary: make header guard identification stricter with Lexer. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20959 llvm-svn: 271883
* [clang-format] skip empty lines and comments in the top of the code when ↵Eric Liu2016-06-031-7/+78
| | | | | | | | | | | | | | | | | inserting new headers. Summary: [clang-format] skip empty lines and comments in the top of the code when inserting new headers. Pair-programmed with @hokein Reviewers: djasper Subscribers: ioeric, cfe-commits, hokein, klimek Differential Revision: http://reviews.llvm.org/D20898 llvm-svn: 271664
* clang-format: [JS] no ASI on `import {x as\n y}`.Martin Probst2016-06-011-0/+3
| | | | | | | | | | | | Summary: ASI did not handle the ES6 `as` operator correctly. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20817 llvm-svn: 271401
* clang-format: [JS] Sort imported symbols.Martin Probst2016-06-011-0/+27
| | | | | | | | | | | | Summary: E.g. sort `import {b, a} from 'x';` into `import {a, b} from 'x';`. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20798 llvm-svn: 271400
* [clang-format] insert new #includes into correct blocks when cleaning up ↵Eric Liu2016-05-311-16/+272
| | | | | | | | | | | | | | | | | Replacement with cleanupAroundReplacements(). Summary: When a replacement's offset is set to UINT_MAX or -1U, it is treated as a header insertion replacement by cleanupAroundReplacements(). The new #include directive is then inserted into the correct block. Reviewers: klimek, djasper Subscribers: klimek, cfe-commits, bkramer Differential Revision: http://reviews.llvm.org/D20734 llvm-svn: 271276
* clang-format: Fix segfault introduced by allowing wraps after comments.Daniel Jasper2016-05-291-0/+5
| | | | llvm-svn: 271191
* clang-format: [JS] Support shebang lines on the very first line.Martin Probst2016-05-291-0/+7
| | | | | | | | | | | | | | | Summary: Shebang lines (`#!/bin/blah`) can be used in JavaScript scripts to indicate they should be run using e.g. node. This change treats # lines on the first line as line comments. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20632 llvm-svn: 271185
* clang-format: [JS] fix async parsing.Martin Probst2016-05-291-0/+4
| | | | | | | | | | | | | | Summary: Only treat the sequence `async function` as the start of a function expression, as opposed to every occurrence of the token `async` (whoops). Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20737 llvm-svn: 271184
* clang-format: Allow splitting the line after /**/-comments.Daniel Jasper2016-05-271-0/+2
| | | | | | | While it might change the meaning of the comment in rare circumstances, it is better than violating the column limit. llvm-svn: 270975
* [clang-format] moved unit tests related to replacements cleaner from ↵Eric Liu2016-05-272-29/+41
| | | | | | FormatTest.cpp to CleanUpTest.cpp. llvm-svn: 270971
* clang-format: [JS] sort ES6 imports.Martin Probst2016-05-202-0/+202
| | | | | | | | | | | | | | | | | | Summary: This change automatically sorts ES6 imports and exports into four groups: absolute imports, parent imports, relative imports, and then exports. Exports are sorted in the same order, but not grouped further. To keep JS import sorting out of Format.cpp, this required extracting the TokenAnalyzer infrastructure to separate header and implementation files. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20198 llvm-svn: 270203
* clang-format: [JS] Treat "for" as a reserved word after a ".".Daniel Jasper2016-05-201-0/+1
| | | | | | | | Otherwise, clang-format can get confused with statements like: x.for = 1; llvm-svn: 270188
* clang-format: [JS] Fix spacing in destructuring assignments.Daniel Jasper2016-05-191-0/+1
| | | | | | | | | | Before: const[a, b, c] = [1, 2, 3]; After: const [a, b, c] = [1, 2, 3]; llvm-svn: 270029
* clang-format: Fix incorrect indentation in last line of macro definitionDaniel Jasper2016-05-191-0/+6
| | | | | | | | | | | | | | | | | | Before: #define MACRO(a) \ if (a) { \ f(); \ } else \ g() After: #define MACRO(a) \ if (a) { \ f(); \ } else \ g() llvm-svn: 270028
* clang-format: Fix enumerator case ranges.Daniel Jasper2016-05-191-0/+1
| | | | | | | | | | Before: case a... b: break; After: case a ... b: break; llvm-svn: 270027
* [clang-format] Make formatReplacements() also sort #includes.Eric Liu2016-05-181-0/+25
| | | | | | | | | | | | Summary: [clang-format] Make formatReplacements() also sort #includes. Reviewers: bkramer, djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20362 llvm-svn: 269924
* Make clang-format cleaner remove redundant commas in list and redundant ↵Eric Liu2016-05-181-0/+127
| | | | | | | | | | | | | | colon in constructor initializer. Summary: Make clang-format cleaner remove redundant commas/colons in constructor initializer list. Reviewers: klimek, djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19804 llvm-svn: 269888
* clang-format: [JS] fix template string width counting.Martin Probst2016-05-171-0/+9
| | | | | | | | | | | | | | | Summary: Simply looking at the final text greatly simplifies the algorithm and also fixes a reported issue. This requires duplicating the "actual encoding width" logic, but that seems cleaner than the column acrobatics before. Reviewers: djasper, bkramer Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20208 llvm-svn: 269747
* clang-format: [JS] respect clang-format off when requoting strings.Martin Probst2016-05-121-0/+8
| | | | | | | | | | Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20200 llvm-svn: 269282
* clang-format: Fix space after argument comments.Daniel Jasper2016-05-081-1/+1
| | | | | | | | | | Before: f(/*a=*/a, /*b=*/ ::b); After: f(/*a=*/a, /*b=*/::b); llvm-svn: 268879
* clang-format: Support enum type template arguments.Daniel Jasper2016-05-081-0/+4
| | | | | | | | | | | | | Before: template <enum E> class A { public : E *f(); }; After: template <enum E> class A { public: E *f(); }; llvm-svn: 268878
* Added Fixer implementation and fix() interface in clang-format for removing ↵Eric Liu2016-04-253-0/+148
| | | | | | | | | | | | | | | | | redundant code. Summary: After applying replacements, redundant code like extra commas or empty namespaces might be introduced. Fixer can detect and remove any redundant code introduced by replacements. The current implementation only handles redundant commas. Reviewers: djasper, klimek Subscribers: ioeric, mprobst, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D18551 llvm-svn: 267416
* clang-format: [JS] generator and async functions.Martin Probst2016-04-241-0/+34
| | | | | | | | | | | | | | | For generators, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators async functions are not quite in the spec yet, but stage 3 and already widely used: http://tc39.github.io/ecmascript-asyncawait/ Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D19204 llvm-svn: 267368
* clang-format: [JS] support `interface` as a free standing identifier.Martin Probst2016-04-191-0/+3
| | | | | | | | | | | | | | | Summary: `interface` can be used as a fee standing identifier in JavaScript/TypeScript. This change uses the heuristic of whether it's followed by another identifier as an indication. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D19240 llvm-svn: 266789
* Summary:Martin Probst2016-04-191-1/+14
| | | | | | | | | | | | | | | | | | | clang-format: [JS] unit tests for type aliases. Also adds a test for "foo as bar" casts. Spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.10 These are already handled correctly. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19206 llvm-svn: 266744
* clang-format: [JS] simplify import/export.Martin Probst2016-04-191-0/+4
| | | | | | | | | | | | | | | | | | | Summary: Change `import` and `export` parsing to special case the renaming syntax (`import x, {y as bar} ...`, `export {x}`) and otherwise just parse a regular structural element. This simplifies the code a bit and should be more correct - it's easier to recognise the specific import syntax than to recognise arbitrary expressions and declarations. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19242 llvm-svn: 266743
* clang-format: Improve heuristics to detect function declarations/definitions.Daniel Jasper2016-04-181-0/+8
| | | | | | | Specifically understand ellipses in parameter lists and treat trailing reference qualifiers and the "{" as signals. llvm-svn: 266599
* clang-format: Last line in incomplete block is indented incorrectlyMarianne Mailhot-Sarrasin2016-04-141-3/+2
| | | | | | | | | | Indentation of the last line was reset to the initial indentation of the block when reaching EOF. Patch by Maxime Beaulieu Differential Revision: http://reviews.llvm.org/D19065 llvm-svn: 266321
* clang-format: Implemented tab usage for continuation and indentationMarianne Mailhot-Sarrasin2016-04-141-0/+226
| | | | | | | | | | Use tabs to fill whitespace at the start of a line. Patch by Maxime Beaulieu Differential Revision: http://reviews.llvm.org/D19028 llvm-svn: 266320
OpenPOWER on IntegriCloud