summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Don't merge const and &, e.g. in function ref qualifiers.Daniel Jasper2016-06-131-1/+1
| | | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | | | 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-5/+7
| | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | 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] pass Style by reference instead of value.Eric Liu2016-06-111-1/+1
| | | | llvm-svn: 272465
* clang-format: [JS] recognized named functions in AnnotatingParser.Martin Probst2016-06-091-1/+4
| | | | | | | | | | | | | | | 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 a FIXME.Martin Probst2016-06-081-1/+1
| | | | llvm-svn: 272143
* clang-format: [JS] fix an assertion failure caused by shrinking sources.Martin Probst2016-06-081-2/+15
| | | | | | | | | | | | | | | | | | 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-3/+6
| | | | | | This could lead to column limit violations. llvm-svn: 272125
* clang-format: Fix bug in function ref qualifier identification.Daniel Jasper2016-06-081-4/+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-23/+51
| | | | | | | | | | | | 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-8/+23
| | | | | | | | | | | | | | | | | 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-012-6/+6
| | | | | | | | | | | | 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-012-24/+60
| | | | | | | | | | | | 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
* Avoid unused variable warning in release builds.Benjamin Kramer2016-05-311-0/+1
| | | | llvm-svn: 271280
* [clang-format] insert new #includes into correct blocks when cleaning up ↵Eric Liu2016-05-311-34/+177
| | | | | | | | | | | | | | | | | 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-1/+2
| | | | llvm-svn: 271191
* clang-format: [JS] Support shebang lines on the very first line.Martin Probst2016-05-292-1/+15
| | | | | | | | | | | | | | | 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-4/+9
| | | | | | | | | | | | | | 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: [JS] FormatToken.startsSequence/endsSequence.Martin Probst2016-05-292-40/+44
| | | | | | | | | Refactors AnnotatedLine.startsWith/endsWith by extracting the core functionality into FormatToken.startsSequence/endsSequence. This allows checking tokens within the pointered linked list structure with a lookahead, automatically ignoring comments, which is useful in many places (e.g. see subsequent commit). llvm-svn: 271183
* clang-format: Allow splitting the line after /**/-comments.Daniel Jasper2016-05-271-1/+3
| | | | | | | 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: [JS] sort ES6 imports.Martin Probst2016-05-209-781/+1390
| | | | | | | | | | | | | | | | | | 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/+3
| | | | | | | | 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-1/+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/+2
| | | | | | | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | Before: case a... b: break; After: case a ... b: break; llvm-svn: 270027
* [clang-format] Make formatReplacements() also sort #includes.Eric Liu2016-05-181-1/+11
| | | | | | | | | | | | 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
* [clang-format] Make FormatTokenLess::operator() const.Eric Liu2016-05-181-1/+1
| | | | llvm-svn: 269889
* Make clang-format cleaner remove redundant commas in list and redundant ↵Eric Liu2016-05-182-4/+52
| | | | | | | | | | | | | | 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] simplify logic by parsing forward.Martin Probst2016-05-171-65/+36
| | | | | | | This also reduces complexity to O(n) from O(n^2) by avoiding backtracking re-parses, and fixes length calculation. llvm-svn: 269748
* clang-format: [JS] fix template string width counting.Martin Probst2016-05-171-45/+23
| | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20200 llvm-svn: 269282
* Enable support for __float128 in Clang and enable it on pertinent platformsNemanja Ivanovic2016-05-091-0/+1
| | | | | | | | | | | | | | | | | | This patch corresponds to reviews: http://reviews.llvm.org/D15120 http://reviews.llvm.org/D19125 It adds support for the __float128 keyword, literals and target feature to enable it. Based on the latter of the two aforementioned reviews, this feature is enabled on Linux on i386/X86 as well as SystemZ. This is also the second attempt in commiting this feature. The first attempt did not enable it on required platforms which caused failures when compiling type_traits with -std=gnu++11. If you see failures with compiling this header on your platform after this commit, it is likely that your platform needs to have this feature enabled. llvm-svn: 268898
* 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/+7
| | | | | | | | | | | | | Before: template <enum E> class A { public : E *f(); }; After: template <enum E> class A { public: E *f(); }; llvm-svn: 268878
* removed redundant '#'Eric Liu2016-04-281-1/+0
| | | | llvm-svn: 267860
* Addressed reviewer's post-submission comments from ↵Eric Liu2016-04-285-70/+61
| | | | | | | | | | | | | | http://reviews.llvm.org/D18551. Summary: Make SourceManager in Environment, WhitespaceManager, and FormatTokenAnalyzer etc constant members. Reviewers: djasper, klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19587 llvm-svn: 267859
* Addressed review's comments.Eric Liu2016-04-282-2/+4
| | | | llvm-svn: 267858
* Added Fixer implementation and fix() interface in clang-format for removing ↵Eric Liu2016-04-255-258/+665
| | | | | | | | | | | | | | | | | 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-244-11/+35
| | | | | | | | | | | | | | | 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
* Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.Eric Liu2016-04-191-4/+13
| | | | | | | | | | | | Summary: When there are comments in the line, one token may be checked multiple times. Reviewers: mprobst, djasper Subscribers: ioeric, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19106 llvm-svn: 266803
* reuse mustBeJSIdent for interface detectionMartin Probst2016-04-191-7/+8
| | | | llvm-svn: 266790
* clang-format: [JS] support `interface` as a free standing identifier.Martin Probst2016-04-191-0/+15
| | | | | | | | | | | | | | | 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
* clang-format: [JS] simplify import/export.Martin Probst2016-04-191-9/+9
| | | | | | | | | | | | | | | | | | | 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-4/+14
| | | | | | | Specifically understand ellipses in parameter lists and treat trailing reference qualifiers and the "{" as signals. llvm-svn: 266599
* Add missing include for StringRef (NFC)Mehdi Amini2016-04-181-0/+1
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266594
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-151-1/+0
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* clang-format: Last line in incomplete block is indented incorrectlyMarianne Mailhot-Sarrasin2016-04-141-0/+3
| | | | | | | | | | 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-142-0/+10
| | | | | | | | | | 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
* clang-format: Allow include of clangFormat.h in managed contextMarianne Mailhot-Sarrasin2016-04-141-0/+1
| | | | | | | | | | | Including VirtualFileSystem.h in the clangFormat.h indirectly includes <atomic>. This header is blocked when compiling with /clr. Patch by Maxime Beaulieu Differential Revision: http://reviews.llvm.org/D19064 llvm-svn: 266319
OpenPOWER on IntegriCloud