summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-4/+5
| | | | llvm-svn: 239903
* clang-format: [JS] Fix corner case in template string parsing.Daniel Jasper2015-06-141-1/+2
| | | | | | | | | | Before, these would not properly detected because of the char/string literal found when re-lexing after the first `: var x = `'`; // comment with matching quote ' var x = `"`; // comment with matching quote " llvm-svn: 239693
* clang-format: Don't add spaces in foreach macro definition.Daniel Jasper2015-06-111-1/+4
| | | | | | | | | | | | Before clang-format would e.g. add a space into #define Q_FOREACH(x, y) which turns this into a non-function-like macro. Patch by Strager Neds, thank you! llvm-svn: 239513
* Remove error message when using the fallback style.Manuel Klimek2015-06-021-2/+0
| | | | llvm-svn: 238822
* clang-format: [JS] Better support for fat arrows.Manuel Klimek2015-05-211-7/+7
| | | | | | | | | | | | Assigns a token type (TT_JsFatArrow) to => tokens, and uses that to more easily recognize and format fat arrow functions. Improves function parsing to better recognize formal parameter lists and return type declarations. Recognizes arrow functions and parse function bodies as child blocks. Patch by Martin Probst. llvm-svn: 237895
* Refactor the formatter of clang-format.Manuel Klimek2015-05-111-3/+3
| | | | | | | | | | | | Pull various parts of the UnwrappedLineFormatter into their own abstractions. NFC. There are two things left for subsequent changes (to keep this reasonably small) - the UnwrappedLineFormatter now has a bad name - the UnwrappedLineFormatter::format function is still too large llvm-svn: 236974
* clang-format: Fix bug in escaped newline calculation.Daniel Jasper2015-05-101-1/+1
| | | | | | | This prevents clang-format from inadvertently joining stuff into macro definitions as reported in llvm.org/PR23466. llvm-svn: 236944
* clang-format: [JS] Fix regex literal detection.Daniel Jasper2015-05-081-1/+1
| | | | | | | | | | Before: var regex = /= / ; After: var regex = /=/; llvm-svn: 236811
* Implements a way to retrieve information about whether some lines were not ↵Manuel Klimek2015-05-071-8/+11
| | | | | | formatted due to syntax errors. llvm-svn: 236722
* Remove deprecated version of reformat.Manuel Klimek2015-05-061-9/+0
| | | | llvm-svn: 236594
* Remove all computation of structural errors in clang-format's line parser.Manuel Klimek2015-05-061-4/+3
| | | | | | We were already ignoring those already. llvm-svn: 236591
* clang-format: Fix another assertion discovered by the fuzzer.Daniel Jasper2015-05-061-10/+17
| | | | | | | | | In the process, fix an old todo that I don't really know how to write tests for. The problem is that Clang's lexer creates very strange token sequences for these. However, the new approach seems generally better and easier to read so I am submitting it nonetheless. llvm-svn: 236589
* clang-format: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.Daniel Jasper2015-05-041-3/+3
| | | | llvm-svn: 236415
* clang-format: [JS] Fix calculation of template string width.Daniel Jasper2015-05-021-4/+14
| | | | | | | | | | OriginalColumn might not be set, so fall back to Location and SourceMgr in case it is missing. Also initialize end column in case the token is multi line, but it's the ` token itself that starts the multi line. Patch by Martin Probst, thank you! llvm-svn: 236383
* clang-format: Add ability to align assignment operators.Daniel Jasper2015-04-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | In Objective-C some style guides use a style where assignment operators are aligned, in an effort to increase code readability. This patch adds an option to the format library which allows this functionality. It is disabled by default for all the included styles, so it must be explicitly enabled. The option will change code such as: - (void)method { NSNumber *one = @1; NSNumber *twentyFive = @25; } to: - (void)method { NSNumber *one = @1; NSNumber *twentyFive = @25; } Patch by Matt Oakes. Thank you! Accidentally reformatted all the tests... llvm-svn: 236100
* clang-format: [JS] handle comments in template strings.Daniel Jasper2015-04-161-2/+17
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 235078
* clang-format: [Proto] No alternate operator names.Daniel Jasper2015-04-031-2/+1
| | | | llvm-svn: 234055
* clang-format: Fix merging of _T macros.Daniel Jasper2015-03-261-0/+2
| | | | | | | NewlinesBefore and HasUnescapedNewline were not properly propagated leading to llvm.org/PR23032. llvm-svn: 233276
* clang-format: Recognize the .ts (TypeScript) extension as JavaScript.Daniel Jasper2015-03-111-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 231926
* Make constant static variables const so they can go into a read-only sectionBenjamin Kramer2015-03-081-5/+6
| | | | | | NFC. llvm-svn: 231597
* clang-format: Change location of stashed tokenJacques Pienaar2015-02-241-2/+4
| | | | | | Commit of patch in http://reviews.llvm.org/D7871 llvm-svn: 230395
* Fix merging of << at end of input.Jacques Pienaar2015-02-201-20/+13
| | | | | | Commit of review http://reviews.llvm.org/D7766 llvm-svn: 230061
* clang-format: [js] Support template strings.Daniel Jasper2015-02-201-1/+65
| | | | | | | | | Merge template strings (marked by backticks ``). Do not format any contents of template strings. Patch by Martin Probst. Thank you. llvm-svn: 230011
* clang-format: Space and triple angle braces.Jacques Pienaar2015-02-181-32/+79
| | | | | | Committing patch http://reviews.llvm.org/D6800. llvm-svn: 229783
* clang-format: Fix assert triggering on carriage returns.Daniel Jasper2015-02-051-0/+3
| | | | llvm-svn: 228288
* clang-format: Add support for SEH __try / __except / __finally blocks.Nico Weber2015-02-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | This lets clang-format format __try { } __except(0) { } and __try { } __finally { } correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set, so this turns this on. This also enables a few other keywords, but it shouldn't overly perturb regular clang-format operation. __except is a context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to a few more places. Fixes PR22321. llvm-svn: 228148
* clang-format: FIXME that led to access of uninitialized memory.Daniel Jasper2015-01-291-1/+2
| | | | | | | | | | I have so far not succeeded in finding a nicely reduced test case or an observable difference which could help me create a test failure without msan. Committing without test to unblock kcc's further fuzzing progress. llvm-svn: 227433
* clang-format: Disable flag for Google's Java and Javascript styles.Daniel Jasper2015-01-141-0/+2
| | | | | | | Disable AlwaysBreakBeforeMultilineString, as the style guides don't really say to do so. llvm-svn: 225982
* clang-format: Let Chromium use the Google default for AlignTrailingComments.Nico Weber2015-01-071-1/+0
| | | | | | | | | | | r225141 changed the defaults of AllowShortIfStatementsOnASingleLine and AlignTrailingComments for Google style and added explicit overrides for Chromium style to undo these changes. For AllowShortIfStatementsOnASingleLine that's good as the Android style guide (which Chromium uses for Java) explicitly permits single-line ifs. But it's silent on trailing comments, to it makes sense for Chromium style to just follow Google style. llvm-svn: 225363
* clang-format: [Java] Change a few flags for Google's Java style.Daniel Jasper2015-01-041-0/+4
| | | | | | No tests added as all of these are already tested separately. llvm-svn: 225141
* clang-format: Fix incorrect calculation of token lenghts.Daniel Jasper2014-12-171-1/+0
| | | | | | This led, e.g. to break JavaScript regex literals too early. llvm-svn: 224419
* clang-format: Factor out UnwrappedLineFormatter into a separate file.Daniel Jasper2014-12-101-773/+1
| | | | | | No functional changes intended. llvm-svn: 223936
* clang-format: Don't merge lines with comments.Daniel Jasper2014-12-071-0/+3
| | | | | | | | | | | | | | Before: int f() { // comment return 42; } After: int f() { // comment return 42; } This fixes llvm.org/PR21769. llvm-svn: 223609
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-021-0/+4
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
OpenPOWER on IntegriCloud