summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Addressed reviewer's post-submission comments from ↵Eric Liu2016-04-281-63/+53
| | | | | | | | | | | | | | 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-281-1/+1
| | | | llvm-svn: 267858
* Added Fixer implementation and fix() interface in clang-format for removing ↵Eric Liu2016-04-251-258/+423
| | | | | | | | | | | | | | | | | 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: Implemented tab usage for continuation and indentationMarianne Mailhot-Sarrasin2016-04-141-0/+2
| | | | | | | | | | 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
* 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
* 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: 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: 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-021-5/+93
| | | | | | | | | | | | | | | | | | | | | 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
* 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: [JS] Add @return to the supported JSDoc pragmas in GoogleDaniel Jasper2016-02-221-1/+1
| | | | | | style. llvm-svn: 261563
* clang-format: [JS] Support @see annotations in JSDoc comments in GoogleDaniel Jasper2016-02-071-1/+1
| | | | | | style. llvm-svn: 260057
* clang-format: Add option to disable string literal formatting.Daniel Jasper2016-02-011-1/+5
| | | | llvm-svn: 259352
* 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
* Make clang::format::reformat work with non 0-terminated strings.Daniel Jasper2016-01-091-2/+3
| | | | llvm-svn: 257259
* clang-format: [JS] Add some Closure Compiler JSDoc tags to the defaultDaniel Jasper2016-01-081-0/+1
| | | | | | Google configuration so that they aren't line-wrapped. llvm-svn: 257159
* clang-format: [TableGen] Support ;-less include lines.Daniel Jasper2015-12-251-7/+8
| | | | llvm-svn: 256412
* Disable include sorting by default for Chromium style.Nico Weber2015-12-221-0/+1
| | | | | | | | | | | Include sorting generally can break .cc files, especially on Windows. Make this opt-in for Chromium style to give us some more time to roll this out. (Given that the Google style guide is used by many companies, some of them probably writing code on Windows, one could argue this should be opt-in in general...) llvm-svn: 256288
* clang-format: [JS] "operator" is not a keyword in Java/JavaScript.Daniel Jasper2015-12-221-2/+4
| | | | llvm-svn: 256245
* clang-format: Only consider the first #include that looks right to beDaniel Jasper2015-12-211-3/+6
| | | | | | the main #include. llvm-svn: 256170
* clang-format: [JS] Change Google-style default for aligning operands.Daniel Jasper2015-12-211-0/+1
| | | | | | The style guide allows both, but apparently, this is the more dominant use. llvm-svn: 256154
* clang-format: Only try to find the "main" include in the first block ofDaniel Jasper2015-12-211-1/+4
| | | | | | includes. llvm-svn: 256153
* clang-format: Extend detection of the "main" #include to use the filenameDaniel Jasper2015-12-211-18/+16
| | | | | | | | | | | Before, the first (non-system) header in a file was considered to be the main include. This is conservative as it makes clang-format change the #include order less often. Instead implement some basic usage of the filename itself. With this patch, clang-format considers every header to be a main include if the header file's basename is a prefix to the filename the #include is in. llvm-svn: 256148
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-181-0/+31
| | | | | | | | | | | This changes the behavior of AlwaysBreakAfterDeclarationReturnType so that it supports breaking after declarations, definitions, or both. Differential Revision: http://reviews.llvm.org/D10370 Reviewed By: Daniel Jasper llvm-svn: 256046
* clang-format: Extend header sort category implementation.Daniel Jasper2015-12-161-3/+3
| | | | | | | | | | Specifically, it is sometimes necessary to keep certain #includes as the first #include, even before the main #include for a .cc file. Switching the category to be signed instead of unsigned isn't ideal, but it seems as good of an option as any and is fully backwards compatible. llvm-svn: 255757
* clang-format: Fix style default for WebKit and Linux styles.Daniel Jasper2015-12-141-2/+0
| | | | | | | | Brought up in codereviews: http://reviews.llvm.org/D15445 http://reviews.llvm.org/D15485 llvm-svn: 255484
* clang-format: Make it possible to turn off comment reflowing.Daniel Jasper2015-12-011-1/+3
| | | | llvm-svn: 254414
* clang-format: Make moving of the Cursor work properly when sorting #includes.Daniel Jasper2015-11-231-8/+20
| | | | llvm-svn: 253860
* clang-format: Make sorting includes respect // clang-format offDaniel Jasper2015-11-211-1/+10
| | | | llvm-svn: 253772
* clang-format: [JS] struct and union aren't keywords / reserved words.Daniel Jasper2015-11-201-0/+4
| | | | llvm-svn: 253671
* clang-format: Enable #include sorting by default.Daniel Jasper2015-11-161-0/+6
| | | | | | | | | This has seen quite some usage and I am not aware of any issues. Also add a style option to enable/disable include sorting. The existing command line flag can from now on be used to override whatever is set in the style. llvm-svn: 253202
* clang-format: Turn on wrapping before "else" for WebKit style.Daniel Jasper2015-11-041-0/+1
| | | | llvm-svn: 252089
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-271-5/+18
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
* clang-format: Teach --sort-includes to interleave #include and #import.Nico Weber2015-10-211-4/+5
| | | | | | | | | | clang accepts both #include and #import for includes (the latter having an implicit header guard). Let clang-format interleave both types if --sort-includes is passed. #import is used frequently in Objective-C code. http://reviews.llvm.org/D13853 llvm-svn: 250909
* clang-format: Extend main header include sorting heuristic to Objective-C files.Nico Weber2015-10-191-1/+3
| | | | llvm-svn: 250675
* clang-format: [JS] Handle string literals spanning character classes.Daniel Jasper2015-10-181-92/+80
| | | | | | | | | | | | | | | If a RegExp contains a character group with a quote (/["]/), the trailing end of it is first tokenized as a string literal, which leads to the merging code seeing an unbalanced bracket. This change parses regex literals from the left hand side. That simplifies the parsing code and also allows correctly handling escapes and character classes, hopefully correctly parsing all regex literals. Patch by Martin Probst, thank you. Review: http://reviews.llvm.org/D13765 llvm-svn: 250648
* clang-format/java: Break after annotations on fields in Chromium style.Nico Weber2015-10-151-1/+3
| | | | | | | | | | | Chromium follows the Android style guide for Java code, and that doesn't make the distinction between fields and non-fields that the Google Java style guide makes: https://source.android.com/source/code-style.html#use-standard-java-annotations https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations llvm-svn: 250422
* clang-format: [JS] handle character classes in regexes.Daniel Jasper2015-10-121-1/+12
| | | | | | | | | Slashes in regular expressions do not need to be escaped and do not terminate the regular expression even without a preceding backslash. Patch by Martin Probst. Thank you. llvm-svn: 250009
* Make clang-format actually respect custom brace wrapping flags.Daniel Jasper2015-10-071-0/+4
| | | | | | This fixes llvm.org/PR25073. llvm-svn: 249519
* clang-format: Make IncludeCategories configurable in .clang-format file.Daniel Jasper2015-10-061-3/+12
| | | | | | | | | This was made much easier by introducing an IncludeCategory struct to replace the previously used std::pair. Also, cleaned up documentation and added examples. llvm-svn: 249392
OpenPOWER on IntegriCloud