summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* [VFS] Transition clang-format to use an in-memory FS.Benjamin Kramer2015-10-061-8/+7
| | | | | | | | | | | Apart from being cleaner this also means that clang-format no longer has access to the host file system. This isn't necessary because clang-format never reads includes :) Includes minor tweaks and bugfixes found in the VFS implementation while running clang-format tests. llvm-svn: 249385
* Add -f[no-]declspec to control recognition of __declspec as a keywordSaleem Abdulrasool2015-10-041-0/+1
| | | | | | | | | | | | | | | In versions of clang prior to r238238, __declspec was recognized as a keyword in all modes. It was then changed to only be enabled when Microsoft or Borland extensions were enabled (and for CUDA, as a temporary measure). There is a desire to support __declspec in Playstation code, and possibly other environments. This commit adds a command-line switch to allow explicit enabling/disabling of the recognition of __declspec as a keyword. Recognition is enabled by default in Microsoft, Borland, CUDA, and PS4 environments, and disabled in all other environments. Patch by Warren Ristow! llvm-svn: 249279
* [clang-format] Add support of consecutive declarations alignmentDaniel Jasper2015-10-011-0/+3
| | | | | | | | | | | | | | | | | | | This allows clang-format to align identifiers in consecutive declarations. This is useful for increasing the readability of the code in the same way the alignment of assignations is. The code is a slightly modified version of the consecutive assignment alignment code. Currently only the identifiers are aligned, and there is no support of alignment of the pointer star or reference symbol. The patch also solve the issue of alignments not being possible due to the ColumnLimit for both the existing AlignConsecutiveAligments and the new AlignConsecutiveDeclarations. Patch by Beren Minor, thank you. Review: http://reviews.llvm.org/D12362 llvm-svn: 248999
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-5/+73
| | | | | | | | | | | | | | | control the individual braces. The existing choices for brace wrapping are now merely presets for the different flags that get expanded upon calling the reformat function. All presets have been chose to keep the existing formatting, so there shouldn't be any difference in formatting behavior. Also change the dump_format_style.py to properly document the nested structs that are used to keep these flags discoverable among all the configuration flags. llvm-svn: 248802
* clang-format: Extend #include sorting functionalityDaniel Jasper2015-09-291-10/+42
| | | | | | | | | Recognize the main module header as well as different #include categories. This should now mimic the behavior of llvm/utils/sort_includes.py as well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very closely. llvm-svn: 248782
* clang-format: Add initial #include sorting capabilities.Daniel Jasper2015-09-231-2/+102
| | | | | | | | | To implement this nicely, add a function that merges two sets of replacements that are meant to be done in sequence. This functionality will also be useful for other applications, e.g. formatting the result of clang-tidy fixes. llvm-svn: 248367
* clang-format: Remove ChromiumStyle.MacroBlockBegin.Nico Weber2015-09-211-2/+0
| | | | | | | | We prefer setting these in our .clang-format file as the macros change over time. (Also, the code was setting MacroBlockBegin twice and didn't set MacroBlockEnd, so it wasn't doing what it tried to do anyways.) llvm-svn: 248205
* Add WebKit brace style configuration option.Roman Kashitsyn2015-08-101-1/+2
| | | | | | | | | | | | | | | | | | Summary: Add brace style `BS_WebKit` as described on https://www.webkit.org/coding/coding-style.html: * Function definitions: place each brace on its own line. * Other braces: place the open brace on the line preceding the code block; place the close brace on its own line. Set brace style used in `getWebKitStyle()` to the newly added `BS_WebKit`. Reviewers: djasper, klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D11837 llvm-svn: 244446
* clang-format: Take nested lines into account when detection C++03Daniel Jasper2015-07-181-32/+46
| | | | | | compatibility and variable alignment. llvm-svn: 242611
* clang-format: Add Mozilla brace breaking styleBirunthan Mohanathas2015-07-121-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D10883 llvm-svn: 241986
* clang-format: Add MacroBlock{Begin,End} optionsBirunthan Mohanathas2015-07-031-7/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MacroBlockBegin and MacroBlockEnd options make matching macro identifiers behave like '{' and '}', respectively, in terms of indentation. Mozilla code, for example, uses several macros that begin and end a scope. Previously, Clang-Format removed the indentation resulting in: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Now, using the options MacroBlockBegin: "^[A-Z_]+_BEGIN$" MacroBlockEnd: "^[A-Z_]+_END$" will yield the expected result: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Differential Revision: http://reviews.llvm.org/D10840 llvm-svn: 241363
* clang-format: [JS] Treat regex literals like string literals.Daniel Jasper2015-07-021-0/+2
| | | | | | | Using the token type "unknown" can interfere badly with WhitespaceManager's way of handling multiline comments. llvm-svn: 241273
* clang-format: [JS] Skip comments when applying the regex-literal heuristicDaniel Jasper2015-07-021-5/+9
| | | | llvm-svn: 241264
* clang-format: [JS] Fix bug in regex literal parsing.Daniel Jasper2015-07-021-0/+1
| | | | | | The lexer wasn't properly reset leading to unexpected deletions. llvm-svn: 241262
* clang-format: [JS] Support regex literals at the start of a file.Daniel Jasper2015-07-021-5/+6
| | | | llvm-svn: 241259
* clang-format: [JS] Fix character counting in template strings.Daniel Jasper2015-07-021-5/+6
| | | | | | | Some counts were off, we don't need to take the leading newlines of the first ` into account and some tests were just wrong. llvm-svn: 241257
* clang-format: Add option to break after definition return type for top-level ↵Birunthan Mohanathas2015-06-291-2/+16
| | | | | | | | functions only Differential Revision: http://reviews.llvm.org/D10774 llvm-svn: 240959
* clang-format: Adjust Mozilla style defaultsBirunthan Mohanathas2015-06-291-3/+5
| | | | | | | | Summary: This makes the Mozilla style defaults more compliant with the Mozilla style guide. A few options were removed in order to use the LLVM style defaults. Differential Revision: http://reviews.llvm.org/D10771 llvm-svn: 240957
* clang-format: Stop old options from overriding new optionsBirunthan Mohanathas2015-06-281-10/+10
| | | | | | | | | | | | | | Summary: Depends on D10785. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D10786 llvm-svn: 240909
* clang-format: Alphabetize FormatStyle membersBirunthan Mohanathas2015-06-281-33/+33
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D10784 llvm-svn: 240907
* clang-format: [JS] Support regex literals containing quotes (' and ").Daniel Jasper2015-06-241-3/+23
| | | | llvm-svn: 240548
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
OpenPOWER on IntegriCloud