summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* clang-format: Tweak -style=Chromium for Java files.Nico Weber2014-11-261-6/+11
| | | | | | | | | | | For Java, don't do any of the deviations from Google Style that Chromium style does for C++. Chromium's Java follows Android Java style [1], which is roughly Google Java style with an indent of 4 and a continuation indent of 8. 1: https://source.android.com/source/code-style.html llvm-svn: 222839
* clang-format: Add SFS_Empty to only empty functions on a single line.Daniel Jasper2014-11-261-2/+6
| | | | | | | | Activated for and tested by Google's Java style. This fixes llvm.org/PR21667. llvm-svn: 222819
* clang-format: Refactoring.Daniel Jasper2014-11-251-12/+10
| | | | | | Re-apply r222638 and r222641 without variadic templates. llvm-svn: 222747
* Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 ↵Aaron Ballman2014-11-241-10/+12
| | | | | | does not support variadic templates. Also reverting r222641 because it was relying on 222638. llvm-svn: 222656
* clang-format: Make short case labels work with #ifsDaniel Jasper2014-11-231-0/+3
| | | | | | | | | | | | | | | | | | | Before: switch (a) { #if FOO case 0: return 0; #endif } After: switch (a) { #if FOO case 0: return 0; #endif } This fixed llvm.org/PR21544. llvm-svn: 222642
* clang-format: Refactoring.Daniel Jasper2014-11-231-12/+10
| | | | | | | Provide more overloads to simplify testing the type of a token. No functional changes intended. llvm-svn: 222638
* clang-format: [JS] Support Closure's module statements.Daniel Jasper2014-11-231-1/+2
| | | | | | | These are like import statements and should not be line-wrapped. Minor restructuring of the handling of other import statements. llvm-svn: 222637
* clang-format: Use nested block special case for all languages.Daniel Jasper2014-11-211-1/+1
| | | | | | | | | | | | | | | | | | | Previously this was only used for JavaScript. Before: functionCall({ int i; int j; }, aaaa, bbbb, cccc); After: functionCall({ int i; int j; }, aaaa, bbbb, cccc); llvm-svn: 222531
* clang-format: Handle comments in short case labels.Daniel Jasper2014-11-211-1/+1
| | | | | | | | | | | | | | | With AllowShortCaseLabelsOnASingleLine set to true: This gets now left unchanged: case 1: // comment return; Whereas before it was changed into: case 1: // comment return; This fixes llvm.org/PR21630. llvm-svn: 222529
* clang-format: [Java] Ignore C++-specific keywordsDaniel Jasper2014-11-191-0/+5
| | | | | | | | | | | | | | | | | | Before: public void union (Object o); public void struct (Object o); public void delete (Object o); After: public void union(Object o); public void struct(Object o); public void delete(Object o); Patch by Harry Terkelsen, thank you! llvm-svn: 222357
* clang-format: Add option to disable alignment after opening bracketsDaniel Jasper2014-11-181-0/+4
| | | | | | | | | | | | | | Before: SomeFunction(parameter, parameter); After: SomeFunction(parameter, parameter); Patch by Harry Terkelsen, thank you! llvm-svn: 222284
* clang-format: [Java] No altnerative operator names in Java.Daniel Jasper2014-11-141-2/+3
| | | | | | | | | | Before: someObject.and (); After: someObject.and(); llvm-svn: 221978
* clang-format: [Java] Improve formatting of generics.Daniel Jasper2014-11-141-0/+1
| | | | | | | | | | Before: Function < F, ? extends T > function; After: Function<F, ? extends T> function; llvm-svn: 221976
* clang-format: Format extern "C" blocks like namespace blocks.Nico Weber2014-11-131-2/+11
| | | | | | | | | | | | | | | | | | | | | namespace blocks act as if KeepEmptyLinesAtTheStartOfBlocks is always true, and aren't collapsed to a single line even if they would fit. Do the same for extern "C" blocks. Before, extern "C" { void ExternCFunction(); } was collapsed into `extern "C" { void ExternCFunction(); }`. Now it stays like it was. Fixes http://crbug.com/432640 and part of PR21419. llvm-svn: 221897
* Revert "clang-format: [js] Updates to Google's JavaScript style."Daniel Jasper2014-11-051-1/+1
| | | | | | | | This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b. Apparently, this change was a bit premature. llvm-svn: 221365
* clang-format: Use identifier table for keywords in other languages.Daniel Jasper2014-11-041-8/+11
| | | | | | | | | Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
OpenPOWER on IntegriCloud