summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Format: support inline namespacesSaleem Abdulrasool2015-10-301-1/+1
| | | | | | | | Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. llvm-svn: 251690
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* clang-format: Fix false ObjC block detection.Daniel Jasper2015-10-071-0/+5
| | | | | | | | | | | Before: inline A operator^(const A &lhs, const A &rhs) {} int i; After: inline A operator^(const A &lhs, const A &rhs) {} int i; llvm-svn: 249517
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-41/+22
| | | | | | | | | | | | | | | control the individual braces. The existing choices for brace wrapping are now merely presets for the different flags that get expanded upon calling the reformat function. All presets have been chose to keep the existing formatting, so there shouldn't be any difference in formatting behavior. Also change the dump_format_style.py to properly document the nested structs that are used to keep these flags discoverable among all the configuration flags. llvm-svn: 248802
* clang-format: [JS] Support pseudo-keywordsDaniel Jasper2015-09-281-0/+5
| | | | | | | | | JavaScript allows keywords to appear in IdenfierName positions, e.g. fields, or object literal members, but not as plain identifiers. Patch by Martin Probst. Thank you! llvm-svn: 248714
* clang-format: [JS] handle let (ES6)Daniel Jasper2015-09-281-1/+1
| | | | | | Patch by Martin Probst. Thank you! llvm-svn: 248713
* clang-format: Properly handle braced lists in macros.Daniel Jasper2015-08-241-0/+2
| | | | | | | | | | | | Before: #define A \ { a, a } \ , After: #define A {a, a}, llvm-svn: 245837
* clang-format: Fix incorrect lambda-detection.Daniel Jasper2015-08-131-0/+1
| | | | | | | | | | Before: [ a, a ]() -> a<1>{}; After: [a, a]() -> a<1> {}; llvm-svn: 244890
* clang-format: [Proto] Handle enum bodies differently.Daniel Jasper2015-07-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | In proto, enum constants can contain complex options and should be handled more like individual declarations. Before: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; After: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; llvm-svn: 242404
* clang-format: Add Mozilla brace breaking styleBirunthan Mohanathas2015-07-121-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D10883 llvm-svn: 241986
* clang-format: [JS] Properly reset parse state after parsing interface.Daniel Jasper2015-07-061-1/+1
| | | | llvm-svn: 241446
* clang-format: Add MacroBlock{Begin,End} optionsBirunthan Mohanathas2015-07-031-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MacroBlockBegin and MacroBlockEnd options make matching macro identifiers behave like '{' and '}', respectively, in terms of indentation. Mozilla code, for example, uses several macros that begin and end a scope. Previously, Clang-Format removed the indentation resulting in: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Now, using the options MacroBlockBegin: "^[A-Z_]+_BEGIN$" MacroBlockEnd: "^[A-Z_]+_END$" will yield the expected result: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Differential Revision: http://reviews.llvm.org/D10840 llvm-svn: 241363
* clang-format: Properly parse parenthesis in braced lists.Daniel Jasper2015-06-301-3/+2
| | | | | | | | | | | Among other things, this makes clang-format understand arbitrary blocks embedded in them, such as: SomeFunction({MACRO({ return output; }), b}); where MACRO could e.g. expand to a lambda. llvm-svn: 241059
* clang-format: Support @autoreleasepool.Nico Weber2015-06-281-0/+10
| | | | | | | | | | Format @autoreleasepool properly for the Attach brace style by recognizing @autoreleasepool as a block introducer. Patch from Strager Neds! http://reviews.llvm.org/D10372 llvm-svn: 240896
* clang-format: Better fix to detect elaborated enum return types.Daniel Jasper2015-06-191-3/+8
| | | | | | | The previous one (r240021) regressed: enum E Type::f() { .. } llvm-svn: 240127
* clang-format: Better support functions with elaborated enum return types.Daniel Jasper2015-06-181-0/+2
| | | | | | | | | Before, this wasn't formatted properly: enum ::C f() { return a; } llvm-svn: 240021
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-6/+3
| | | | llvm-svn: 239903
* clang-format: [JS] Fix typescript enum formatting.Daniel Jasper2015-06-171-5/+13
| | | | | | | | | | | | | | | | | | | Patch by Martin Probst. Before: enum { A, B } var x = 1; After: enum { A, B } var x = 1; llvm-svn: 239893
* clang-format: [JS] Support "export enum" declarations.Daniel Jasper2015-06-121-1/+2
| | | | llvm-svn: 239595
* 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
OpenPOWER on IntegriCloud