summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: [JS] generator and async functions.Martin Probst2016-04-241-0/+3
| | | | | | | | | | | | | | | 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: Improve heuristics to detect function declarations/definitions.Daniel Jasper2016-04-181-4/+14
| | | | | | | Specifically understand ellipses in parameter lists and treat trailing reference qualifiers and the "{" as signals. llvm-svn: 266599
* clang-format: Fix incorrect function annotation detection.Daniel Jasper2016-04-061-1/+2
| | | | | | | | | | | | | Before: MACRO( abc).function() // wrap << abc; After: MACRO(abc).function() // wrap << abc; llvm-svn: 265540
* clang-format: Fix cast detection on "this".Daniel Jasper2016-04-051-3/+3
| | | | | | | | | | | | Before: auto x = (X) this; After: auto x = (X)this; This fixes llvm.org/PR27198. llvm-svn: 265385
* clang-format: [JS] do not wrap ES6 imports/exports.Daniel Jasper2016-03-221-5/+21
| | | | | | | | | "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/+13
| | | | | | | | | 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] Fix incorrect spacing around contextual keywords.Daniel Jasper2016-03-171-2/+5
| | | | | | | | | | Before: x.of (); After: x.of(); llvm-svn: 263710
* clang-format: [JS] Optionally re-quote string literals.Daniel Jasper2016-03-021-3/+3
| | | | | | | | | | | | | | | | | | | | | Turns "foo" into 'foo' (or vice versa, depending on configuration). This makes it more convenient to follow the Google JavaScript style guide: https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings This functionality is behind the option "JavaScriptQuotes", which can be: * "leave" (no re-quoting) * "single" (change to single quotes) * "double" (change to double quotes) This also changes single quoted JavaScript string literals to be treated as tok::string_literal, not tok::char_literal, which fixes two unrelated tests. Patch by Martin Probst. Thank you. llvm-svn: 262534
* [clang-format] Detect constructor initializers preceded by `noexcept`.Daniel Jasper2016-03-011-1/+1
| | | | | | Patch by Erik Kessler, thank you. llvm-svn: 262402
* clang-format: Increase the penalty for breaking between array subscripts.Daniel Jasper2016-03-011-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa] [a].aaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa][a] .aaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 262292
* clang-format: [JS] Support quoted object literal keys.Daniel Jasper2016-03-011-1/+2
| | | | | | | | | | | | | | | | | Before: var x = { a: a, b: b, 'c': c, }; After: var x = { a: a, b: b, 'c': c, }; llvm-svn: 262291
* clang-format: [JS] treat forwardDeclare as an import/export statement.Daniel Jasper2016-02-221-1/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 261528
* clang-format: [JS] Support for (.. of ..) loops.Daniel Jasper2016-02-111-1/+1
| | | | | | | | | | Before: for (var i of[2, 3]) {} After: for (var i of [2, 3]) {} llvm-svn: 260518
* clang-format: Make it more expensive to break template parameters.Daniel Jasper2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | In particular, make it more expensive than breaking after the return type of a function definition/declaration. Before: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa< T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); After: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); llvm-svn: 260497
* clang-format: [JS] Don't count shortened object literals as blocks.Daniel Jasper2016-02-071-1/+1
| | | | | | | | | | | | | | | Before: f({a}, () => { g(); // }); After: f({a}, () => { g(); // }); llvm-svn: 260060
* clang-format: Fix corner case in template detection.Daniel Jasper2016-02-051-6/+15
| | | | | | | | | | Before: f(a.operator() < A > ()); After: f(a.operator()<A>()); llvm-svn: 259884
* clang-format: Fix incorrect pointer detection in lambdas in constructorDaniel Jasper2016-02-011-2/+2
| | | | | | | | | | | | initializers. Before: Constructor() : member([](A *a, B * b) {}) {} After: Constructor() : member([](A *a, B *b) {}) {} llvm-svn: 259353
* clang-format: [JS] Treat "in" as a proper operator.Daniel Jasper2016-02-011-0/+10
| | | | llvm-svn: 259350
* Fix formatting of fully qualified names in array subscripts.Manuel Klimek2016-01-191-1/+2
| | | | | | | | | | Before: a[ ::b::c]; After: a[::b::c]; llvm-svn: 258123
* clang-format: [JS] Fix incorrect line break leading to semicolon insertion.Daniel Jasper2016-01-141-0/+2
| | | | | | | | | | | | | | | | clang-format only works for JavaScript code, if all the semicolons are present anyway, so this linebreak can never be desired. Before (with appropriate statement lengths or column limit): return [ aaa ]; After: return [ aaaa ]; llvm-svn: 257741
* clang-format: Fix overloading "operator," definitions more thoroughly.Daniel Jasper2016-01-111-4/+4
| | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaa operator,(aaaaaaaaaaaaaaaaaaaaa & aaaaaaaaaaaaaaaaaaaaaaaaaa) const; After: aaaaaaaaaaaaaaaaaaaaaa operator,( aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const; llvm-svn: 257330
* clang-format: Support definitions/declarations of operator,.Daniel Jasper2016-01-091-3/+4
| | | | | | | | | | Before: bool operator, (); After: bool operator,(); llvm-svn: 257256
* clang-format: [JS] Prefer wrapping before the TypeScript return typeDaniel Jasper2016-01-081-1/+1
| | | | | | | | | | | | | | over wrapping before parameters. Before: function someFunc( args: string[]): {longReturnValue: string[]} {} After: function someFunc(args: string[]): {longReturnValue: string[]} {} llvm-svn: 257162
* clang-format: Support weird lambda macros.Daniel Jasper2016-01-071-0/+12
| | | | | | | | | | Before: MACRO((AA & a) { return 1; }); After: MACRO((AA &a) { return 1; }); llvm-svn: 257062
* clang-format: Improve line wrapping behavior in call sequences.Daniel Jasper2016-01-051-3/+13
| | | | | | | | | | | | | | | 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 more ES6 default exports.Daniel Jasper2016-01-041-2/+3
| | | | llvm-svn: 256759
* clang-format: [JS] Support ES6 exports of array literals.Daniel Jasper2016-01-041-1/+5
| | | | | | | | | | | | | | | | Before: export default[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]; export default[]; After: export default [ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ]; export default []; llvm-svn: 256758
* clang-format: [JS] Improve empty array literal detection.Daniel Jasper2016-01-041-3/+3
| | | | | | | | | | | | | | | Previously, the [] in the following example were recognized as an array subscript leading to weird indentation. Before: var aaaa = aaaaa || // wrap []; After: var aaaa = aaaaa || // wrap []; llvm-svn: 256753
* clang-format: Fix corner case in builder-type call formatting.Daniel Jasper2016-01-041-1/+1
| | | | | | | | | | | | | | Before: return aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa) .aaaa(aaaaaaaaaaaaaa); After: return aaaaaaaaaaaaaaaa .aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa) .aaaa(aaaaaaaaaaaaaa); llvm-svn: 256750
* clang-format: Fix corner case for lambda assignments.Daniel Jasper2016-01-041-1/+1
| | | | | | | | | | | | Before: std::function<std::string(const std::string &)> my_lambda = []( const string &s) { return s; }; After: std::function<std::string(const std::string &)> my_lambda = [](const string &s) { return s; }; llvm-svn: 256739
* clang-format: Fix corner-case in ObjC method declaration formattingDaniel Jasper2016-01-041-2/+1
| | | | | | | | | | | | | | | | | | Before: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } After: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } llvm-svn: 256738
* clang-format: [Proto] Basic support for options with <> for repeated fields.Daniel Jasper2016-01-041-3/+4
| | | | llvm-svn: 256737
* clang-format: [Proto] Improve wrapping of message field attributes.Daniel Jasper2016-01-041-4/+5
| | | | | | | | | | | | | | | | | | | | | | | Before: optional AAA aaa = 1 [foo = { key: "a" // }, bar = { key: "a" // }]; After: optional AAA aaa = 1 [ foo = { key: "a" // }, bar = { key: "a" // } ]; llvm-svn: 256736
* clang-format: Slightly row back on r256343 by increasing penalty forDaniel Jasper2015-12-301-1/+3
| | | | | | | | | | | | | breaking between array subscripts. Before: if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa] [aaaaaaaaaaaaa]) After: if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa]) llvm-svn: 256640
* clang-format: [JS] Support TypeScript 1.6 user defined type guards.Daniel Jasper2015-12-301-0/+4
| | | | | | | | | | | | | | | | 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: Fix incorrect function type detection.Daniel Jasper2015-12-281-15/+8
| | | | | | | | | | Before: int x = f (&h)(); After: int x = f(&h)(); llvm-svn: 256488
* clang-format: Lower penalty for breaking between array subscripts.Daniel Jasper2015-12-231-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)][bbbbbbbbbbb( bbbbbbbbbbbb)] After: aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)] [bbbbbbbbbbb(bbbbbbbbbbbb)] llvm-svn: 256343
* clang-format: Fix incorrect pointer detection.Daniel Jasper2015-12-231-1/+1
| | | | | | | | | | Before: return * this += 1; After: return *this += 1; llvm-svn: 256342
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-181-9/+26
| | | | | | | | | | | This changes the behavior of AlwaysBreakAfterDeclarationReturnType so that it supports breaking after declarations, definitions, or both. Differential Revision: http://reviews.llvm.org/D10370 Reviewed By: Daniel Jasper llvm-svn: 256046
* clang-format: Make wrapping after "./->" cheaper, even if the elementDaniel Jasper2015-12-071-4/+14
| | | | | | | | | | | | | | | | | | | before it is not a closing parenthesis. Otherwise, this frequently leads to "hanging" indents that users perceive as "weird". Before: return !soooooooooooooome_map.insert( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; After: return !soooooooooooooome_map .insert(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; llvm-svn: 254933
* clang-format: Re-add code path deleted in r253873 and add missing test.Daniel Jasper2015-11-231-0/+9
| | | | llvm-svn: 253900
* clang-format: Signficantly refactor the cast detection.Daniel Jasper2015-11-231-49/+60
| | | | | | No functional changes intended. llvm-svn: 253873
* clang-format: Fix incorrect cast detection.Daniel Jasper2015-11-231-17/+15
| | | | | | | | | | Before: bool b = f(g<int>)&&c; After: bool b = f(g<int>) && c; llvm-svn: 253872
* clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"Daniel Jasper2015-11-201-0/+1
| | | | | | work properly. llvm-svn: 253674
* clang-format: [JS] Properly add a space after "in" in for loops.Daniel Jasper2015-11-201-1/+2
| | | | llvm-svn: 253672
* clang-format: Don't use incorrect space in macro calls with operators.Daniel Jasper2015-11-201-1/+2
| | | | | | | | | | | | Before: MACRO(> ); After: MACRO(>); Not overly important, but easy and good for symmetry reasons :-). llvm-svn: 253669
* clang-format: [Proto] Support extending message.Daniel Jasper2015-11-201-1/+1
| | | | | | | | | | | | Before: extend.foo.Bar { } After: extend .foo.Bar { } llvm-svn: 253667
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* clang-format: [JS] Add goog.setTestOnly to the list of stuff thatDaniel Jasper2015-10-291-3/+4
| | | | | | is import-statement-like and shouldn't be wrapped. llvm-svn: 251643
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-271-7/+4
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
OpenPOWER on IntegriCloud