summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] Fix regression caused by r239592.Daniel Jasper2015-06-121-0/+1
| | | | | | | | | | Without it, it would do: interface I { x: string; } var y; llvm-svn: 239593
* clang-format: [JS] fix incorrectly collapsed lines after exportDaniel Jasper2015-06-121-6/+8
| | | | | | | | | | | | | statement. When an exported function would follow a class declaration, it would not be recognized as a stand-alone function. That would then collapse the following line with the current one, e.g. class C {} export function f() {} var x; llvm-svn: 239592
* clang-format: More eagerly wrap trailing return types.Daniel Jasper2015-06-051-1/+1
| | | | | | | | | | | | | | | | | Before: template <typename T> auto aaaaaaaaaaaaaaaaaaaaaa(T t) -> decltype(eaaaaaaaaaaaaaaa<T>(t.a) .aaaaaaaa()); After: template <typename T> auto aaaaaaaaaaaaaaaaaaaaaa(T t) -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa()); Also add a test case for a difficult template parsing case I stumbled accross. Needs fixing. llvm-svn: 239149
* clang-format: Don't try to detect C++ lambdas in other languages.Daniel Jasper2015-06-021-0/+4
| | | | llvm-svn: 238845
* [Format] Move UnwrappedLines instead of copying.Benjamin Kramer2015-05-311-7/+4
| | | | | | No functional change intended. llvm-svn: 238673
* clang-format: NFC. Cleanup after r237895.Daniel Jasper2015-05-311-26/+8
| | | | | | | | | | | Specifically adhere to LLVM Coding Standards (no 'else' after return/break/continue) and remove yet another implementation of paren counting. We already have enough of those in the UnwrappedLineParser. No functional changes intended. llvm-svn: 238672
* clang-format: [JS] Better support for fat arrows.Manuel Klimek2015-05-211-11/+57
| | | | | | | | | | | | 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
* clang-format: Fix another regression caused by r237565.Daniel Jasper2015-05-181-5/+8
| | | | | | | | | | | | | | | | | | | | Before: class C : test { class D : test{void f(){int i{2}; } } ; } ; After: class C : test { class D : test { void f() { int i{2}; } }; }; llvm-svn: 237569
* clang-format: Fix regression introduced by r237565.Daniel Jasper2015-05-181-1/+2
| | | | | | | | | | | | | | Before: class C : public D { SomeClass SC { 2 }; }; After: class C : public D { SomeClass SC{2}; }; llvm-svn: 237568
* clang-format: Allow braced initializers in template arguments of classDaniel Jasper2015-05-181-10/+12
| | | | | | | | | | | | | | specializations. Before: template <class T> struct S < std::is_arithmetic<T> { } > {}; After: template <class T> struct S<std::is_arithmetic<T>{}> {}; llvm-svn: 237565
* clang-format: Fix semicolon less macro-detection.Daniel Jasper2015-05-131-5/+9
| | | | | | | | | | | | | | It was fooled by the comment. Before: SOME_UNRELATED_MACRO /*static*/ int i; After: SOME_UNRELATED_MACRO /*static*/ int i; llvm-svn: 237246
* clang-format: Don't merge subsequent lines into _asm blocks.Daniel Jasper2015-05-111-0/+1
| | | | | | | | | | | | | Before: _asm { } int i; After: _asm { } int i; llvm-svn: 236985
* clang-format: [JS] Clean up export declaration parsing.Daniel Jasper2015-05-111-7/+4
| | | | | | NFC intended. llvm-svn: 236982
* clang-format: [JS] Parse exported functions as free-standing.Daniel Jasper2015-05-111-2/+10
| | | | | | | | | | | | | Before: export function foo() {} export function bar() {} After: export function foo() { } export function bar() { } llvm-svn: 236978
* clang-format: Preserve line break before } in __asm { ... }.Daniel Jasper2015-05-101-0/+2
| | | | | | | | 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: Merge labels and subsequent semicolons.Daniel Jasper2015-05-061-0/+2
| | | | | | | | | | | 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: Accept slightly more record declarations.Daniel Jasper2015-05-061-28/+30
| | | | | | This fixes llvm.org/PR23397. llvm-svn: 236599
* Remove all computation of structural errors in clang-format's line parser.Manuel Klimek2015-05-061-18/+6
| | | | | | We were already ignoring those already. llvm-svn: 236591
* clang-format: [JS] support optional methods.Daniel Jasper2015-05-051-7/+17
| | | | | | | | | | | | | | | 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: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.Daniel Jasper2015-05-041-3/+2
| | | | llvm-svn: 236415
* clang-format: More selectively detect QT's "signals".Daniel Jasper2015-04-241-1/+5
| | | | llvm-svn: 235702
* 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-071-2/+5
| | | | 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
* 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
* Explicitly include raw_ostream.h instead of relying on transitive inclusion.Benjamin Kramer2015-03-231-0/+1
| | | | | | NFC. llvm-svn: 232975
* clang-format: [Java] Support anonymous classes after = and return.Daniel Jasper2015-03-121-0/+28
| | | | | | | | | | | | | | | | | | | 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
* Make helper functions static. NFC.Benjamin Kramer2015-03-091-1/+1
| | | | | | Found by -Wmissing-prototypes. llvm-svn: 231668
* Add missing include.Benjamin Kramer2015-03-011-0/+1
| | | | llvm-svn: 230910
* clang-format: [js] Support ES6 module exports.Daniel Jasper2015-02-191-5/+22
| | | | | | Patch by Martin Probst, thank you! llvm-svn: 229865
* clang-format: [js] Support ES6 module imports.Daniel Jasper2015-02-191-0/+18
| | | | | | 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: [JS] Support classes.Daniel Jasper2015-02-181-3/+8
| | | | | | | | | | 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: 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-071-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add support for SEH __try / __except / __finally blocks.Nico Weber2015-02-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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 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: [Java] Support try blocks with resources.Daniel Jasper2015-01-141-0/+4
| | | | | | | | | | | | | | | Before: try (SomeResource rs = someFunction()) { Something(); } After: try (SomeResource rs = someFunction()) { Something(); } llvm-svn: 225973
* clang-format: Fix formatting of inline asm.Daniel Jasper2015-01-121-2/+2
| | | | | | | | | Specifically, adjust the leading "__asm {" and trailing "}" while still leaving the assembly inside it alone. This fixes llvm.org/PR22190. llvm-svn: 225623
* clang-format: [Java] Fix incorrect recognition of annonymous classes.Daniel Jasper2015-01-041-2/+3
| | | | | | | | | | | | | | | | Before: someFunction(new Runnable() { public void run() { System.out.println(42); } }); After: someFunction(new Runnable() { public void run() { System.out.println(42); } }); llvm-svn: 225142
* clang-format: Support commas in lambda return types.Daniel Jasper2014-12-081-0/+1
| | | | | | | | | | Before: auto next_pair = [](A * a) -> pair<A*, A*>{}; After: auto next_pair = [](A* a) -> pair<A*, A*>{}; llvm-svn: 223652
* clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.Daniel Jasper2014-12-051-1/+2
| | | | | | This fixes llvm.org/PR21756. llvm-svn: 223458
* clang-format: [Java] Support Foo.class;Daniel Jasper2014-11-261-0/+7
| | | | | | | | | | | | | Before: SomeClass. class.getName(); After: SomeClass.class.getName(); This fixes llvm.org/PR21665. llvm-svn: 222813
* clang-format: [JS] Support Closure's module statements.Daniel Jasper2014-11-231-0/+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: Understand more lambda return types.Daniel Jasper2014-11-211-0/+3
| | | | | | | | | | Before: auto a = [&b, c ](D * d) -> D * {} After: auto a = [&b, c](D* d) -> D* {} llvm-svn: 222534
* clang-format: [Java] Accept generic types in enum declarationDaniel Jasper2014-11-191-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Before: enum Foo implements Bar<X, Y> { ABC { ... } , CDE { ... }; } After: enum Foo implements Bar<X, Y> { ABC { ... }, CDE { ... }; } Patch by Harry Terkelsen. llvm-svn: 222394
* clang-format: [Java] Support Java enums.Daniel Jasper2014-11-131-18/+85
| | | | | | | In Java, enums can contain a class body and enum constants can have arguments as well as class bodies. Support most of that. llvm-svn: 221895
OpenPOWER on IntegriCloud