summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor the formatter of clang-format.Manuel Klimek2015-05-113-306/+347
| | | | | | | | | | | | 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: Improve wrapping of << operators.Daniel Jasper2015-05-102-9/+10
| | | | | | | | | | | | | | | | | Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; Also, cleanup and simplify the operator wrapping logic. llvm-svn: 236960
* clang-format: Preserve line break before } in __asm { ... }.Daniel Jasper2015-05-103-1/+7
| | | | | | | | Some compilers ignore everything after a semicolon in such inline asm blocks and thus, the closing brace must not be moved to the previous line. llvm-svn: 236946
* 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: Several improvements around formatting braced lists.Daniel Jasper2015-05-081-3/+4
| | | | | | | | | | | | | In particular: * If the difference between the longest and shortest element, we copped out of column format completely. Now, we instead allow to arrange these in a single column, essentially enforcing a one-per-line format. * Allow column layout even if there are braced lists. Especially, if there are many short lists, this can be beneficial. The bad case, where there is a long nested init list is usually caught as we now limit the length difference of the longest and shortest element. llvm-svn: 236851
* clang-format: [JS] Avoid bad line-warp around "function".Daniel Jasper2015-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | Before: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function( aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); After: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); llvm-svn: 236813
* clang-format: [JS] Fix regex literal detection.Daniel Jasper2015-05-081-1/+1
| | | | | | | | | | Before: var regex = /= / ; After: var regex = /=/; llvm-svn: 236811
* clang-format: Improve r236597, Properly indent method calls without inputs.Daniel Jasper2015-05-072-3/+7
| | | | | | | | | | | | Before: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; llvm-svn: 236730
* Implements a way to retrieve information about whether some lines were not ↵Manuel Klimek2015-05-073-12/+20
| | | | | | formatted due to syntax errors. llvm-svn: 236722
* clang-format: Don't indent 'signals' as access specifier if it isn't oneDaniel Jasper2015-05-061-1/+3
| | | | | | | | | | | | | | Before: { signals.set(0); } After: { signals.set(0); } llvm-svn: 236630
* clang-format: Merge labels and subsequent semicolons.Daniel Jasper2015-05-062-1/+3
| | | | | | | | | | | E.g.: default:; This can be used to get around restrictions as to what can follow a label. It fixes llvm.org/PR19648. llvm-svn: 236604
* clang-format: Allow ternary expressions inside template parameters ifDaniel Jasper2015-05-061-2/+7
| | | | | | | | the template parameters aren't inside an expression context. This fixes llvm.org/PR23270. llvm-svn: 236603
* clang-format: Consider operator precedence as penalty when breakingDaniel Jasper2015-05-061-0/+3
| | | | | | | | before operators. This fixes llvm.org/23382. llvm-svn: 236602
* clang-format: Accept slightly more record declarations.Daniel Jasper2015-05-061-28/+30
| | | | | | This fixes llvm.org/PR23397. llvm-svn: 236599
* clang-format: Fix bad wrapping of ObjC method exprs.Daniel Jasper2015-05-061-3/+3
| | | | | | | | | | | | | | | | | Before: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa: aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa:aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; Note that this might now violate the column limit and we probably need an alternative way of indenting these then. However, that is still strictly better than the messy formatting that clang-format did before. llvm-svn: 236598
* clang-format: Properly indent method calls without inputs.Daniel Jasper2015-05-061-2/+4
| | | | | | | | | | | | Before: [aaaaaaaaaaa aaaaaaa]; After: [aaaaaaaaaaa aaaaaaa]; llvm-svn: 236597
* 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-063-28/+10
| | | | | | 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: Prevent assertion discovered by fuzzer.Daniel Jasper2015-05-061-2/+10
| | | | llvm-svn: 236578
* clang-format: Prevent exponential runtime in token annotator.Daniel Jasper2015-05-061-1/+11
| | | | llvm-svn: 236577
* clang-format: Fix bug in multiline comment wrapping.Daniel Jasper2015-05-061-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Splitting: /** * multiline block comment * */ Before: /** * multiline block *comment * */ After: /** * multiline block * comment * */ The reason was that the empty line inside the comment (with just the "*") was confusing the comment breaking logic. llvm-svn: 236573
* clang-format: [JS] support optional methods.Daniel Jasper2015-05-052-22/+54
| | | | | | | | | | | | | | | Optional methods use ? tokens like this: interface X { y?(): z; } It seems easiest to detect and disambiguate these from ternary expressions by checking if the code is in a declaration context. Turns out that that didn't quite work properly for interfaces in Java and JS, and for JS file root contexts. Patch by Martin Probst, thank you. llvm-svn: 236488
* clang-format: [JS] Do not collapse short interfaces.Daniel Jasper2015-05-051-1/+2
| | | | | | Patch by Martin Probst. llvm-svn: 236485
* clang-format: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.Daniel Jasper2015-05-044-17/+12
| | | | llvm-svn: 236415
* clang-format: NFC: Use default member initializers and other cleanups.Daniel Jasper2015-05-041-71/+65
| | | | llvm-svn: 236413
* clang-format: Force aligning different brackets relative to each other.Daniel Jasper2015-05-043-5/+25
| | | | | | | | | | | | Before: void SomeFunction(vector< // break int> v); After: void SomeFunction(vector< // break int> v); llvm-svn: 236412
* 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: [JS] Fix templated parameter default values.Daniel Jasper2015-05-021-1/+1
| | | | | | | | | | Parameters can have templated types and default values (= ...), which is another location in which a template closer should be followed by whitespace. Patch by Martin Probst, thank you. llvm-svn: 236382
* clang-format: Don't merge short else blocks.Daniel Jasper2015-04-301-1/+6
| | | | | | | | | | | | | | | | | | | | | Before (with the appropriate flags settings): if (a) { f(); } else { g(); } Before (with other appropriate flags settings): if (a) { f(); } else { g(); } After: if (a) { f(); } else { g(); } llvm-svn: 236217
* clang-format: Add ability to align assignment operators.Daniel Jasper2015-04-293-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Fix selective indentaiton in nested blocks.Daniel Jasper2015-04-291-1/+3
| | | | | | | | | | | | Buggy case: someFunction( [] { // comment int i; // invoke formatting here. }, // force line break aaa); llvm-svn: 236091
* clang-format: Don't wrap after short first segments of builder calls.Daniel Jasper2015-04-241-1/+2
| | | | | | | | | | | | | | | Before: a() .aaaaa() .aaaaa() .aaaaa(); After: a().aaaaa() .aaaaa() .aaaaa(); llvm-svn: 235707
* clang-format: More selectively detect QT's "signals".Daniel Jasper2015-04-241-1/+5
| | | | llvm-svn: 235702
* clang-format: Properly detect variable declarations with ObjC.Daniel Jasper2015-04-231-1/+2
| | | | | | | | | | | | Before: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); After: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); llvm-svn: 235599
* clang-format: Allow splitting "= default" and "= delete".Daniel Jasper2015-04-231-1/+2
| | | | | | Otherwise, this can violate the column limit. llvm-svn: 235592
* clang-format: Don't add unwanted space when creating new arrays.Daniel Jasper2015-04-231-1/+2
| | | | | | | | | | Before: char** newargv = new char* [argc]; After: char** newargv = new char*[argc]; llvm-svn: 235583
* clang-format: [Proto] Don't linewrap top-level options.Daniel Jasper2015-04-231-2/+10
| | | | | | They are very similar to import statements. llvm-svn: 235582
* clang-format: Support nested block formatting with ColumnLimit=0.Daniel Jasper2015-04-233-31/+50
| | | | llvm-svn: 235580
* clang-format: Fix for #pragma option formatting.Daniel Jasper2015-04-222-2/+10
| | | | | | Adapted patch from Sergey Razmetov. Thank you. llvm-svn: 235492
* clang-format: Fix incorrect multi-var declstmt detection.Daniel Jasper2015-04-201-3/+3
| | | | | | | | | | | | This is now obvious as the pointer alignment behavior was changed. Before (even with pointer alignment "Left"): MACRO Constructor(const int &i) : a(a), b(b) {} After: MACRO Constructor(const int& i) : a(a), b(b) {} llvm-svn: 235301
* 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: Undo r214508. It was essentially always removing theDaniel Jasper2015-04-161-1/+1
| | | | | | | space where we already had the flag ObjCSpaceBeforeProtocolList to control it. I don't know what I was thinking. llvm-svn: 235076
* clang-format: Determine "in" as a keyword in ObjC for loops more preciselyDaniel Jasper2015-04-151-23/+21
| | | | | | | | | | | | Before: for (int i = 0; i < in [a]; ++i) .. After: for (int i = 0; i < in[a]; ++i) .. Also do some related cleanups. llvm-svn: 234980
* clang-format: [JS] Support index signature types.Daniel Jasper2015-04-131-1/+2
| | | | | | Patch by Martin Probst. llvm-svn: 234754
* clang-format: [JS] support optionality markers in JS types.Daniel Jasper2015-04-132-10/+23
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234753
* clang-format: [JS] Allow periods and commata in class declarations.Daniel Jasper2015-04-131-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234752
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* clang-format: Fix regression formatting QT's "signals:" from r234318.Daniel Jasper2015-04-073-3/+16
| | | | llvm-svn: 234320
* clang-format: Don't allow labels when expecting declarations.Daniel Jasper2015-04-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | This fixes formatting unnamed bitfields (llvm.org/PR21999). Before: struct MyStruct { uchar data; uchar: 8; uchar: 8; uchar other; }; After: struct MyStruct { uchar data; uchar : 8; uchar : 8; uchar other; }; llvm-svn: 234318
OpenPOWER on IntegriCloud