summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* clang-format: Add support for SEH __try / __except / __finally blocks.Nico Weber2015-02-046-12/+30
| | | | | | | | | | | | | | | | | | | | | | | | 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: Fix incorrect handling of leading whitespace.Daniel Jasper2015-01-311-6/+12
| | | | | | | Added an assertion that triggered in an existing test case (without observable differences) and fixed the code. llvm-svn: 227677
* 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: Fix crasher caused by not properly setting dry-run.Daniel Jasper2015-01-292-2/+7
| | | | llvm-svn: 227427
* clang-format: Fix another crasher caused by incomplete macro code.Daniel Jasper2015-01-231-5/+11
| | | | | | | | We did't properly mark all of an AnnotatedLine's children as finalized and thus would reformat the same tokens in different branches of #if/#else sequences leading to invalid replacements. llvm-svn: 226930
* clang-format: Fix incorrect classification of "*".Daniel Jasper2015-01-231-13/+14
| | | | | | | | | | Before: *a = b *c; After: *a = b * c; llvm-svn: 226923
* clang-format: Fix crasher when splitting incomplete escape sequences.Daniel Jasper2015-01-211-1/+1
| | | | llvm-svn: 226698
* clang-format: Fix crasher caused by incorrect resetting of token info.Daniel Jasper2015-01-211-0/+1
| | | | llvm-svn: 226685
* clang-format: Fix bad memory access.Daniel Jasper2015-01-211-0/+1
| | | | llvm-svn: 226680
* clang-format: Fix use-heap-after-free bug.Daniel Jasper2015-01-211-5/+7
| | | | | | Discovered by the awesome test case and ASAN. llvm-svn: 226678
* clang-format: Fix AlwaysBreakBeforeMultilineStrings with ColumnLimit=0Daniel Jasper2015-01-201-2/+3
| | | | | | | | | | | | | | Before: const char *x = "hello llvm"; After: const char *x = "hello llvm"; This fixes llvm.org/PR22245. Patch by Bill Meltsner, thank you! llvm-svn: 226564
* clang-format: Fix crasher on weird comments.Daniel Jasper2015-01-191-4/+2
| | | | | | | | Crashing input: /\ / comment llvm-svn: 226454
* clang-format: Fix crasher on incomplete condition compilation.Daniel Jasper2015-01-191-1/+1
| | | | | | | | | | | Previously crashing input: void f( #if A ); #else #endif llvm-svn: 226451
* clang-format: Fix crash on invalid code.Daniel Jasper2015-01-191-1/+2
| | | | | | Input "a<," made clang-format crash. llvm-svn: 226450
* clang-format: Fix clang-format crash on invalid code.Daniel Jasper2015-01-191-1/+1
| | | | llvm-svn: 226449
* clang-format: Fix assertion when trying to build a nullptr StringRef.Daniel Jasper2015-01-191-0/+1
| | | | llvm-svn: 226448
* clang-format: Fix endless loop on incomplete try-catch-block.Daniel Jasper2015-01-191-1/+1
| | | | llvm-svn: 226447
* clang-format: Remove assert that isn't helpful.Daniel Jasper2015-01-191-1/+0
| | | | | | | This assert would trigger on: #d , = } llvm-svn: 226446
* 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
OpenPOWER on IntegriCloud