summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-0/+1
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [clang-format] Walk backwards from end() instead of forwards from rend().Benjamin Kramer2016-04-111-1/+1
| | | | | | | | This should've been forwards from rbegin(), reverse iterators are just too confusing to be used by mere mortals. Fixes out-of-bounds walks over the list. llvm-svn: 265934
* clang-format: [JS] do not insert semicolons after wrapped annotations.Martin Probst2016-04-111-0/+7
| | | | | | | | | | 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-1/+3
| | | | | | | | | | | | | | | | 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/+3
| | | | | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | 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-11/+1
| | | | | | | | | | | | | | 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
* Added support for different VFSs in format::getStyle. Disable ↵Eric Liu2016-03-241-8/+17
| | | | | | 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-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: 264276
* Revert "removed redundant comment in format::getStyle."Eric Liu2016-03-241-7/+17
| | | | | | This reverts commit r264254. llvm-svn: 264275
OpenPOWER on IntegriCloud