summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatToken.h
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Keep string-literal-label + value pairs on a line.Daniel Jasper2016-12-131-0/+15
| | | | | | | | | | | | | | | | | | | | | We have previously done that for <<-operators. This patch also adds this logic for "," and "+". Before: string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa; string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa); After: string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa; string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa); llvm-svn: 289531
* clang-format: [JS] do not break after declare namespace.Martin Probst2016-11-101-0/+4
| | | | | | | See TypeScript grammar for tokens following 'declare': https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10 llvm-svn: 286467
* clang-format: [JS] recognize more type locations.Martin Probst2016-06-231-0/+2
| | | | | | | | | | | | Summary: Includes parenthesized type expressions and type aliases. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21597 llvm-svn: 273603
* clang-format: [JS] Support shebang lines on the very first line.Martin Probst2016-05-291-1/+1
| | | | | | | | | | | | | | | Summary: Shebang lines (`#!/bin/blah`) can be used in JavaScript scripts to indicate they should be run using e.g. node. This change treats # lines on the first line as line comments. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20632 llvm-svn: 271185
* clang-format: [JS] FormatToken.startsSequence/endsSequence.Martin Probst2016-05-291-0/+42
| | | | | | | | | Refactors AnnotatedLine.startsWith/endsWith by extracting the core functionality into FormatToken.startsSequence/endsSequence. This allows checking tokens within the pointered linked list structure with a lookahead, automatically ignoring comments, which is useful in many places (e.g. see subsequent commit). llvm-svn: 271183
* clang-format: [JS] sort ES6 imports.Martin Probst2016-05-201-0/+2
| | | | | | | | | | | | | | | | | | Summary: This change automatically sorts ES6 imports and exports into four groups: absolute imports, parent imports, relative imports, and then exports. Exports are sorted in the same order, but not grouped further. To keep JS import sorting out of Format.cpp, this required extracting the TokenAnalyzer infrastructure to separate header and implementation files. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20198 llvm-svn: 270203
* clang-format: [JS] generator and async functions.Martin Probst2016-04-241-2/+8
| | | | | | | | | | | | | | | For generators, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators async functions are not quite in the spec yet, but stage 3 and already widely used: http://tc39.github.io/ecmascript-asyncawait/ Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D19204 llvm-svn: 267368
* clang-format: [JS] do not wrap ES6 imports/exports.Daniel Jasper2016-03-221-0/+2
| | | | | | | | | "import ... from '...';" and "export ... from '...';" should be treated the same as goog.require/provide/module/forwardDeclare calls. Patch by Martin Probst. llvm-svn: 264055
* clang-format: [JS] no space in union and intersection types.Daniel Jasper2016-03-211-0/+1
| | | | | | | | | The operators | and & in types, as opposed to the bitwise operators, should not have whitespace around them (e.g. `Foo<Bar|Baz>`). Patch by Martin Probst. Thank you. llvm-svn: 263961
* clang-format: [JS] Support for (.. of ..) loops.Daniel Jasper2016-02-111-0/+2
| | | | | | | | | | Before: for (var i of[2, 3]) {} After: for (var i of [2, 3]) {} llvm-svn: 260518
* clang-format: Improve line wrapping behavior in call sequences.Daniel Jasper2016-01-051-3/+3
| | | | | | | | | | | | | | | r256750 has been leading to an undesired behavior: aaaaaaaaaa .aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); This change increases penalty for wrapping before member accesses that aren't calls. Thus, this is again formatted as (as it has been before r256750): aaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 256830
* clang-format: [JS] Support TypeScript 1.6 user defined type guards.Daniel Jasper2015-12-301-0/+2
| | | | | | | | | | | | | | | | Before: function foo(check: Object): check is{foo: string, bar: string, baz: string, foobar: string} { return 'bar' in check; } After: function foo(check: Object): check is {foo: string, bar: string, baz: string, foobar: string} { return 'bar' in check; } llvm-svn: 256631
* clang-format: treat Q_SIGNALS as an access modifierDaniel Jasper2015-12-011-0/+2
| | | | | | Patch by Alexander Richardson, thank you! llvm-svn: 254407
* clang-format: [Proto] Support extending message.Daniel Jasper2015-11-201-0/+2
| | | | | | | | | | | | Before: extend.foo.Bar { } After: extend .foo.Bar { } llvm-svn: 253667
* clang-format: Undo unwanted format change done in r251405.Daniel Jasper2015-10-271-4/+4
| | | | | | | | Specifically, don't wrap between the {} of an empty constructor if the "}" falls on column 81 and ConstructorInitializerAllOnOneLineOrOnePerLine is set. llvm-svn: 251406
* clang-format: [JS] handle let (ES6)Daniel Jasper2015-09-281-0/+2
| | | | | | Patch by Martin Probst. Thank you! llvm-svn: 248713
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-151-0/+2
| | | | | | Before: assert a&& b; Now: assert a && b; llvm-svn: 247750
* clang-format: Make formatting of member function reference qualifiersDaniel Jasper2015-08-241-2/+4
| | | | | | | | | | | | | | more consistent. Before: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &) && { ... } After: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &)&& { ... } llvm-svn: 245843
* clang-format: Don't remove space between #elif and parentheses.Daniel Jasper2015-08-141-0/+4
| | | | | | | | | | Before: #elif(AAAA && BBBB) After: #elif (AAAA && BBBB) llvm-svn: 245043
* clang-format: Print token type name instead of number in -debug outputBirunthan Mohanathas2015-07-131-59/+68
| | | | | | Differential Revision: http://reviews.llvm.org/D11125 llvm-svn: 242039
* clang-format: Add MacroBlock{Begin,End} optionsBirunthan Mohanathas2015-07-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: clang-format (NFC)Daniel Jasper2015-06-171-15/+3
| | | | llvm-svn: 239903
* clang-format: [JS] Support ES6 computed property names.Daniel Jasper2015-05-291-0/+1
| | | | | | | | | | | | | | | | Before: var x = { [a]: 1, b: 2 }; After: var x = { [a]: 1, b: 2 }; llvm-svn: 238544
* clang-format: [JS] Better support for fat arrows.Manuel Klimek2015-05-211-0/+1
| | | | | | | | | | | | 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: Improve detection of macros annotating functions.Daniel Jasper2015-05-181-1/+1
| | | | | | | | | | | | | | | | Before: ASSERT("aaaaaaaaaaaaaaa") << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; After: ASSERT("aaaaaaaaaaaaaaa") << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; Also cleanup implementation a bit and only mark closing parenthesis of these annotations. llvm-svn: 237567
* clang-format: Support function annotations in macros.Daniel Jasper2015-05-181-0/+1
| | | | | | | | | | | | Before: DEPRECATED("Use NewClass::NewFunction instead.") string OldFunction(const string &parameter) {} After: DEPRECATED("Use NewClass::NewFunction instead.") string OldFunction(const string &parameter) {} llvm-svn: 237562
* clang-format: Support aligning ObjC string literals.Daniel Jasper2015-05-111-0/+1
| | | | | | | | | | | | Before: NSString s = @"aaaa" @"bbbb"; After: NSString s = @"aaaa" @"bbbb"; llvm-svn: 237000
* clang-format: Improve wrapping of << operators.Daniel Jasper2015-05-101-1/+1
| | | | | | | | | | | | | | | | | 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-101-0/+1
| | | | | | | | 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: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.Daniel Jasper2015-05-041-4/+1
| | | | 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-041-1/+5
| | | | | | | | | | | | Before: void SomeFunction(vector< // break int> v); After: void SomeFunction(vector< // break int> v); llvm-svn: 236412
* clang-format: Fix for #pragma option formatting.Daniel Jasper2015-04-221-0/+5
| | | | | | Adapted patch from Sergey Razmetov. Thank you. llvm-svn: 235492
* clang-format: [JS] support optionality markers in JS types.Daniel Jasper2015-04-131-0/+1
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234753
* clang-format: Fix regression formatting QT's "signals:" from r234318.Daniel Jasper2015-04-071-0/+9
| | | | llvm-svn: 234320
* clang-format: Force line break in trailing calls after multline exprs.Daniel Jasper2015-03-261-1/+2
| | | | | | | | | | | | | Before: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb).a(); After: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb) .a(); llvm-svn: 233304
* clang-format: [js] Support template strings.Daniel Jasper2015-02-201-0/+1
| | | | | | | | | 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 imports.Daniel Jasper2015-02-191-0/+2
| | | | | | Patch by Martin Probst. llvm-svn: 229863
* clang-format: [JS] Support type annotations.Daniel Jasper2015-02-181-0/+1
| | | | | | | | | | 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
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-2/+2
| | | | | | 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: Add support for SEH __try / __except / __finally blocks.Nico Weber2015-02-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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: [Java] Detect `native` keyword.Nico Weber2015-01-131-0/+2
| | | | | | | | | | Before: public native<X> Foo foo(); After: public native <X> Foo foo(); llvm-svn: 225839
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | This fixed llvm.org/PR21804 and hopefully a few other strange cases. Before: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } After: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } llvm-svn: 224112
* clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.Daniel Jasper2014-12-051-0/+6
| | | | | | This fixes llvm.org/PR21756. llvm-svn: 223458
* clang-format: [Java] Don't line-wrap package declarations.Daniel Jasper2014-11-261-0/+2
| | | | | | This fixes llvm.org/PR21677. llvm-svn: 222843
* clang-format: Refactoring.Daniel Jasper2014-11-251-27/+24
| | | | | | Re-apply r222638 and r222641 without variadic templates. llvm-svn: 222747
* Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 ↵Aaron Ballman2014-11-241-19/+35
| | | | | | does not support variadic templates. Also reverting r222641 because it was relying on 222638. llvm-svn: 222656
* clang-format: [Java] Treat 'instanceof' like other binary operators.Daniel Jasper2014-11-231-0/+2
| | | | | | This fixes llvm.org/PR21436. llvm-svn: 222641
* clang-format: Refactoring.Daniel Jasper2014-11-231-35/+17
| | | | | | | Provide more overloads to simplify testing the type of a token. No functional changes intended. llvm-svn: 222638
OpenPOWER on IntegriCloud