summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Improve nested block formatting.Daniel Jasper2015-04-071-1/+2
| | | | | | | | | | | | | | | | | | Before: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); After: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); llvm-svn: 234304
* clang-format: Indent relative to the ./-> and not the function name.Daniel Jasper2015-04-071-1/+1
| | | | | | | | | | | | | | | | | | Before: aaaaaaaaaaa // .aaaa( // bbbb) // This is different .. .aaaa( // cccc); // .. from this. After: aaaaaaaaaaa // .aaaa( // bbbb) // This is identical .. .aaaa( // cccc); // .. to this. llvm-svn: 234300
* clang-format: [JS] Understand object literals with only methods.Daniel Jasper2015-04-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Before: let theObject = {someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); }}; After: let theObject = { someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); } }; llvm-svn: 234091
* clang-format: [Proto] No alternate operator names.Daniel Jasper2015-04-031-2/+1
| | | | llvm-svn: 234055
* clang-format: [JS] Support getters, setters and methods in object literals.Daniel Jasper2015-03-311-0/+11
| | | | llvm-svn: 233698
* clang-format: [JS] Fix comment formatting in goog.scopes.Daniel Jasper2015-03-301-2/+3
| | | | | | | | | | | | | | | | | | Before: goog.scope(function() { // test var x = 0; // test }); After: goog.scope(function() { // test var x = 0; // test }); llvm-svn: 233530
* clang-format: Force line break in trailing calls after multline exprs.Daniel Jasper2015-03-263-6/+8
| | | | | | | | | | | | | Before: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb).a(); After: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb) .a(); llvm-svn: 233304
* 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
* Explicitly include raw_ostream.h instead of relying on transitive inclusion.Benjamin Kramer2015-03-231-0/+1
| | | | | | NFC. llvm-svn: 232975
* clang-format: Fix another bug in wrapping around "*".Daniel Jasper2015-03-191-3/+3
| | | | | | | | | | | | Before: void aaaaa( aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} // even violation the column limit After: void aaaaa(aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} llvm-svn: 232717
* clang-format: Fix bad wrapping after "*" introduced in r232044.Daniel Jasper2015-03-181-3/+1
| | | | | | | | | | | | Before: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {} After: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {} llvm-svn: 232635
* clang-format: [JS] support cast syntax and type arguments.Daniel Jasper2015-03-151-0/+7
| | | | | | | | | Casts in TS syntax (foo = <type>bar;) should not be followed by whitespace. Patch by Martin Probst. Thank you. llvm-svn: 232321
* clang-format: [JS] more precisely detect enums.Daniel Jasper2015-03-151-1/+7
| | | | | | | | | | | | The current enum detection is overly aggressive. As NestingLevel only applies per line (?) it classifies many if not most object literals as enum declarations and adds superfluous line breaks into them. This change narrows the heuristic by requiring an assignment just before the open brace and requiring the line to start with an identifier. Patch by Martin Probst. Thank you. llvm-svn: 232320
* clang-format: Don't corrupt macros with open braces.Daniel Jasper2015-03-131-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Formatting: #define A { { #define B } } Before: #define A \ { \ { #define B } \ } After: #define A \ { \ { #define B \ } \ } This fixes llvm.org/PR22884. llvm-svn: 232166
* clang-format: [OBJC] Don't indent 8 spaces in method declarations.Daniel Jasper2015-03-121-7/+3
| | | | | | | | | | | | Before: - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: (SoooooooooooooooooooooomeType *)bbbbbbbbbb; After: - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: (SoooooooooooooooooooooomeType *)bbbbbbbbbb; llvm-svn: 232112
* clang-format: When putting */& next to types, also wrap before them.Daniel Jasper2015-03-122-5/+12
| | | | | | | | | | | | Before: LoooooooooooongType * loooooooooooongVariable; After: LoooooooooooongType *loooooooooooongVariable; llvm-svn: 232044
* clang-format: [Java] Support anonymous classes after = and return.Daniel Jasper2015-03-122-0/+29
| | | | | | | | | | | | | | | | | | | Before: A a = new A(){public String toString(){return "NotReallyA"; } } ; After: A a = return new A() { public String toString() { return "NotReallyA"; } }; This fixes llvm.org/PR22878. llvm-svn: 232042
* clang-format: Recognize the .ts (TypeScript) extension as JavaScript.Daniel Jasper2015-03-111-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 231926
* clang-format: Fix incorrect && recognition.Daniel Jasper2015-03-111-0/+2
| | | | | | | | | | Before: if (a &&(b = c)) .. After: if (a && (b = c)) .. llvm-svn: 231920
* Make helper functions static. NFC.Benjamin Kramer2015-03-091-1/+1
| | | | | | Found by -Wmissing-prototypes. llvm-svn: 231668
* clang-format: Don't remove newline if macro ends in access specifier.Daniel Jasper2015-03-091-1/+2
| | | | | | | | | | | I.e.: #define A public: // The new line before this line would be removed. int a; llvm-svn: 231636
* Make constant static variables const so they can go into a read-only sectionBenjamin Kramer2015-03-082-7/+8
| | | | | | NFC. llvm-svn: 231597
* clang-format: Slightly change indentation rules in for loops.Daniel Jasper2015-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | There was already a TODO to double-check whether the extra indenation makes sense. A slightly different case reveals that it is actively harmful: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } Here (and it is probably not a totally infrequent case, it just works out that "i < " is four spaces and so the four space extra indentation makes the operator precedence confusing. So, this will now instead be formatted as: for (int i = 0; i < aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbb < ccccccccccccccc; ++i) { } llvm-svn: 231461
* Make sure we initialize all values in WhitespaceManager::Change.Manuel Klimek2015-03-031-2/+3
| | | | llvm-svn: 231067
* clang-format: Fix access to uninitialized memory.Daniel Jasper2015-03-031-0/+1
| | | | | | | | | With incomplete code, we aren't guaranteed to generated changes for every token. In that case, we need to assume that even the very first change can continue a preprocessor directive and initialize values accordingly. llvm-svn: 231066
* clang-format: Prefer wrapping a lambda's body over the lambda's return type.Daniel Jasper2015-03-021-0/+2
| | | | | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaa( [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaaaaaaa { return aaaaaaaaaaaaaaaaa; }); After: aaaaaaaaaaaaaaaaaaaaaa( [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaaaaaaa { return aaaaaaaaaaaaaaaaa; }); llvm-svn: 230942
* Add missing include.Benjamin Kramer2015-03-011-0/+1
| | | | llvm-svn: 230910
* clang-format: Always align */& in multi-var DeclStmts.Daniel Jasper2015-03-012-6/+15
| | | | | | | | Seems like the most consistent thing to do and in multi-var DeclStmts, it is especially important to point out that the */& bind to the identifier. llvm-svn: 230903
* clang-format: Make trailing commas in array inits force one per line.Daniel Jasper2015-02-271-2/+5
| | | | | | | | | | | | | Before: NSArray *array = @[ @"a", @"a", ]; After: NSArray *array = @[ @"a", @"a", ]; llvm-svn: 230741
* clang-format: Make braced list formatting more consistent.Daniel Jasper2015-02-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | Before: Aaaa aaaaaaaaaaa{ { a, // +1 indent weird. b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; After: Aaaa aaaaaaaaaaa{ { a, // better!? b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; Interesting that this apparently was entirely untested :-(. llvm-svn: 230627
* clang-format: Fix space of arrays of pointers to templated types.Daniel Jasper2015-02-261-1/+2
| | | | | | | | | | Before: vector<int>(*foo_)[6]; After: vector<int> (*foo_)[6]; llvm-svn: 230625
* clang-format: Allow breaking after "else if(" as a last resort.Daniel Jasper2015-02-261-2/+3
| | | | | | This isn't generally nice, but better than violating the column limit. llvm-svn: 230620
* clang-format: Fix spacing for function with ref-qualification ..Daniel Jasper2015-02-251-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | .. when using SpacesInCStyleCastParentheses != SpacesInParentheses. Before: FormatStyle Spaces = getLLVMStyle(); Deleted &operator=(const Deleted &)& = default; Spaces.SpacesInParentheses = true; Deleted(const Deleted &)& = default; Spaces.SpacesInCStyleCastParentheses = true; Spaces.SpacesInParentheses= false; Deleted( const Deleted & )& = default; After: FormatStyle Spaces = getLLVMStyle(); Deleted &operator=(const Deleted &)& = default;; Spaces.SpacesInParentheses= true; Deleted( const Deleted & )& = default; Spaces.SpacesInCStyleCastParentheses = true; Spaces.SpacesInParentheses= false; Deleted(const Deleted &)& = default; Patch by Jean-Philippe Dufraigne. Thank you! llvm-svn: 230473
* 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-202-1/+66
| | | | | | | | | 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: [js] Support ES6 module exports.Daniel Jasper2015-02-193-7/+24
| | | | | | Patch by Martin Probst, thank you! llvm-svn: 229865
* clang-format: [js] Support ES6 module imports.Daniel Jasper2015-02-194-8/+31
| | | | | | Patch by Martin Probst. llvm-svn: 229863
* clang-format: [js] Do not fall through for JS structural elements.Daniel Jasper2015-02-191-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 229862
* clang-format: Space and triple angle braces.Jacques Pienaar2015-02-182-35/+82
| | | | | | Committing patch http://reviews.llvm.org/D6800. llvm-svn: 229783
* clang-format: [JS] support AtScript style annotations for JS.Daniel Jasper2015-02-181-1/+7
| | | | | | | | Based on Java annotation support and style. Patch by Martin Probst. llvm-svn: 229703
* clang-format: [JS] Support classes.Daniel Jasper2015-02-182-4/+10
| | | | | | | | | | This adds support for JavaScript class definitions (again following TypeScript & AtScript style). This only required support for visibility modifiers in JS, everything else was already working. Patch by Martin Probst, thank you. llvm-svn: 229701
* clang-format: [JS] Support type annotations.Daniel Jasper2015-02-182-7/+16
| | | | | | | | | | This patch adds support for type annotations that follow TypeScript's, Flow's, and AtScript's syntax style. Patch by Martin Probst, thank you. Review: http://reviews.llvm.org/D7721 llvm-svn: 229700
* clang-format: Don't force a break after "endl" if everything fits on one line.Daniel Jasper2015-02-172-3/+4
| | | | llvm-svn: 229486
* clang-format: Fix crasher.Daniel Jasper2015-02-171-1/+1
| | | | llvm-svn: 229485
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-152-4/+4
| | | | | | requiring the macro. NFC; Clang edition. llvm-svn: 229339
* Format: Make FormatToken's isOneOf a variadic templateBenjamin Kramer2015-02-151-20/+3
| | | | llvm-svn: 229326
* clang-format: Correctly mark preprocessor lines in child blocks.Daniel Jasper2015-02-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | This prevents contracting: auto lambda = []() { int a = 2 #if A + 2 #endif ; }; into: auto lambda = []() { int a = 2 #if A + 2 #endif ; }; Which is obviously BAD. This fixes llvm.org/PR22496. llvm-svn: 228522
* clang-format: Format Objective-C try blocks like all the other try blocks.Nico Weber2015-02-072-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: @try { // ... } @finally { // ... } Now: @try { // ... } @finally { // ... } This is consistent with how we format C++ try blocks and SEH try blocks. clang-format not doing this before was an implementation oversight. This is dependent on BraceBreakingStyle. The snippet above is with the Attach style. Style Stroustrip for example still results in the "Before:" snippet, which makes sense since other blocks (try, else) break after '}' too. llvm-svn: 228483
* clang-format: Fix assert triggering on carriage returns.Daniel Jasper2015-02-051-0/+3
| | | | llvm-svn: 228288
OpenPOWER on IntegriCloud