summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatToken.h
Commit message (Collapse)AuthorAgeFilesLines
* 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
* clang-format: [Java] Support more Java keywords.Daniel Jasper2014-11-211-0/+4
| | | | | | | | | | | | | | | | | | Before: public final<X> Foo foo() { } public abstract<X> Foo foo(); After: public final <X> Foo foo() { } public abstract <X> Foo foo(); Patch by Harry Terkelsen. Thank you. llvm-svn: 222527
* clang-format: [Java] Basic lambda support.Daniel Jasper2014-11-211-0/+3
| | | | llvm-svn: 222524
* clang-format: [Java] Never treat @interface as annotation.Nico Weber2014-11-101-0/+3
| | | | | | | | | '@' followed by any keyword can't be an annotation, but @interface is currently the only combination of '@' and a keyword that's allowed, so limit it to this case. `@interface Foo` without a leading `public` was misformatted prior to this patch. llvm-svn: 221607
* clang-format: Use identifier table for keywords in other languages.Daniel Jasper2014-11-041-12/+66
| | | | | | | | | Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
* clang-format: [Java] Improve line breaks around annotations.Daniel Jasper2014-10-311-0/+1
| | | | | | | | | | | | | | | | | Before: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} After: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} llvm-svn: 220984
* clang-format: [Java] Wrap after each function annotation.Daniel Jasper2014-10-211-0/+1
| | | | | | | | | | | Before: @Override public String toString() { .. } After: @Override public String toString() { .. } llvm-svn: 220274
* clang-format: Prefer breaking before trailing return arrows.Daniel Jasper2014-10-171-1/+2
| | | | | | | | | | | | Before: auto SomeFunction( A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} After: auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {} llvm-svn: 220043
* clang-format: Improve handling of block comments in braced lists.Daniel Jasper2014-08-261-1/+2
| | | | | | | | | | | | Before: std::vector<int> v = { 1, 0 /* comment */ }; After: std::vector<int> v = {1, 0 /* comment */}; llvm-svn: 216445
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-3/+3
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* clang-format: Correct SBPO_Always-behavior after function-like keywordsDaniel Jasper2014-08-061-0/+20
| | | | | | | | | | | | | | | | | Before: auto f (int x) -> decltype(x) { return sizeof(x); } int g () noexcept(someCall ()); static_assert(sizeof(char) == 1, "Your compiler is broken"); After: auto f (int x) -> decltype (x) { return sizeof (x); } int g () noexcept (someCall ()); static_assert (sizeof (char) == 1, "Your compiler is broken"); This fixes llvm.org/PR20559. Patch by Roman Kashitsyn, thank you! llvm-svn: 214969
* clang-format: Fix behavior around pointer-to-member invocations.Daniel Jasper2014-07-091-1/+1
| | | | | | | | | | | | Before: (aaaaaaaaaa->* bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); After: (aaaaaaaaaa->*bbbbbbb)( aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); llvm-svn: 212617
* clang-format: Revamp function declaration/definition indentation.Daniel Jasper2014-07-091-0/+1
| | | | | | | | | | | | | | Key changes: - Correctly (well ...) distinguish function declarations and variable declarations with ()-initialization. - Don't indent when breaking function declarations/definitions after the return type. - Indent variable declarations and typedefs when breaking after the type. This fixes llvm.org/PR17999. llvm-svn: 212591
* clang-format: [JS] Treat dict literals similar to objc method exprs.Daniel Jasper2014-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } } After: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } }; llvm-svn: 210537
* clang-format: Refactor indentation behavior for multiple nested blocks.Daniel Jasper2014-06-031-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a few oddities when formatting multiple nested JavaScript blocks, e.g.: Before: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); After: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); llvm-svn: 210097
* clang-format: Fix bug introduced by r208392.Daniel Jasper2014-05-091-1/+3
| | | | | | Also run clang-format over clang-format's files. llvm-svn: 208409
* [C++11] Use 'nullptr'.Craig Topper2014-05-091-3/+3
| | | | llvm-svn: 208392
* clang-format: [JS] Initial support for regex literals.Daniel Jasper2014-05-081-0/+1
| | | | llvm-svn: 208281
* clang-format: Add special case to reduce indentaiton in streams.Daniel Jasper2014-04-161-4/+10
| | | | | | | | | | | | | | | | This is similar to how we treat assignments and seems to be generally desirable. Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 206384
* Format code around VCS conflict markers.Manuel Klimek2014-04-141-4/+7
| | | | | | | | | | | | | | | | | | | | | Now correctly formats: { int a; void f() { callme(some(parameter1, <<<<<<< text by the vcs parameter2), ||||||| text by the vcs parameter2), parameter3, ======= text by the vcs parameter2, parameter3), >>>>>>> text by the vcs otherparameter); } } llvm-svn: 206157
OpenPOWER on IntegriCloud