summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-4/+3
| | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | 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-3/+4
| | | | | | Patch by Martin Probst. Thank you! llvm-svn: 248713
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-151-1/+1
| | | | | | Before: assert a&& b; Now: assert a && b; llvm-svn: 247750
* clang-format: Add space before member function reference qualifiers.Daniel Jasper2015-08-251-6/+6
| | | | | | | | | | | | Before: SomeType MemberFunction(const Deleted &)&; After: SomeType MemberFunction(const Deleted &) &; Seems to be much more common. llvm-svn: 245934
* clang-format: Always allow break after leading annotations.Daniel Jasper2015-08-241-1/+1
| | | | | | | | | | | Before: DEPRECATED("Use NewClass::NewFunction instead.") int OldFunction( const string &parameter) {} Could not be formatted at all, as clang-format would both require and disallow the break before "int". llvm-svn: 245846
* clang-format: Make formatting of member function reference qualifiersDaniel Jasper2015-08-241-3/+7
| | | | | | | | | | | | | | 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: Be more conservative about specially indenting blocks in C++.Daniel Jasper2015-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is a bit of a step back of what we did in r222531, as there are some corner cases in C++, where this kind of formatting is really bad. Example: Before: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); After: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); The block formatting logic in JavaScript will probably go some other changes, too, and we'll potentially be able to make the rules more consistent again. For now, this seems to be the best approach for C++. llvm-svn: 245694
* clang-format: Don't remove space between #elif and parentheses.Daniel Jasper2015-08-141-1/+1
| | | | | | | | | | Before: #elif(AAAA && BBBB) After: #elif (AAAA && BBBB) llvm-svn: 245043
* clang-format: Inside decltype(), there is an expression.Daniel Jasper2015-08-131-2/+3
| | | | | | | | | | Before: decltype(a* b) F(); After: decltype(a * b) F(); llvm-svn: 244891
* clang-format: Make SpaceBeforeParens work with overloaded operators.Daniel Jasper2015-08-111-1/+1
| | | | | | Patch by Jon Chesterfield, thank you! llvm-svn: 244660
* Do not force linebreaks when MaxEmptyLinesToKeep is 0.Manuel Klimek2015-07-281-1/+1
| | | | | | | | | | | | | | | | Previously we would format call( p); as call( p); with MaxEmptyLinesToKeep == 0. Now we format it as: call(p); llvm-svn: 243429
* clang-format: Fix unary operator detection in for loops.Daniel Jasper2015-07-211-1/+2
| | | | | | | | | | Before: for (;; * a = b) {} After: for (;; *a = b) {} llvm-svn: 242849
* clang-format: Fix return type breaking with overloaded operator functionsBirunthan Mohanathas2015-07-151-14/+58
| | | | | | Differential Revision: http://reviews.llvm.org/D11177 llvm-svn: 242316
* clang-format: Print token type name instead of number in -debug outputBirunthan Mohanathas2015-07-131-1/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D11125 llvm-svn: 242039
* clang-format: Add Mozilla brace breaking styleBirunthan Mohanathas2015-07-121-1/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D10883 llvm-svn: 241986
* clang-format: [JS] Assign proper penalties when breaking a type annotationDaniel Jasper2015-07-101-0/+2
| | | | | | | | | | | | | | | | Before: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } After: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } llvm-svn: 241908
* clang-format: Break after "for (" less eagerly.Daniel Jasper2015-07-071-1/+2
| | | | | | | | | | | | | | | | Before: for ( auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { After: for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { llvm-svn: 241601
* clang-format: Don't wrap before the ] of a lambda introducer.Daniel Jasper2015-07-071-0/+3
| | | | | | | | | | | | | | | | Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([= ](int iiiiiiiiiiii) { return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa; }); After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([=]( int iiiiiiiiiiii) { return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa; }); llvm-svn: 241583
* clang-format: Fix __attribute__ being treated as decl name.Daniel Jasper2015-07-061-1/+2
| | | | | | | | | | | __attribute__ was treated as the name of a function definition, with the tokens in parentheses being the parameter list. This formats incorrectly with AlwaysBreakAfterDefinitionReturnType. Fix it by treating __attribute__ like decltype. Patch by Strager Neds, thank you. llvm-svn: 241439
* clang-format: [JS] Allow line breaks after TypeScript type colons.Daniel Jasper2015-07-031-0/+2
| | | | llvm-svn: 241339
* clang-format: [Java/JS] Properly support instanceof and its precedence.Daniel Jasper2015-07-031-2/+7
| | | | llvm-svn: 241337
* clang-format: Support member function reference qualifiers withDaniel Jasper2015-07-011-1/+1
| | | | | | | | | | | | | | trailing return types. Before: template <typename T> auto x() & -> int {} After: template <typename T> auto x() & -> int {} llvm-svn: 241188
* clang-format: Add option to break after definition return type for top-level ↵Birunthan Mohanathas2015-06-291-2/+5
| | | | | | | | functions only Differential Revision: http://reviews.llvm.org/D10774 llvm-svn: 240959
* clang-format: [Proto] Don't treat "operator" as keyword.Daniel Jasper2015-06-251-5/+6
| | | | | | | | | | Before: optional string operator= 1; After: optional string operator = 1; llvm-svn: 240624
* Fix "the the" in comments/documentation/etc.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240110
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-1/+1
| | | | | | is(). llvm-svn: 240008
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-7/+7
| | | | llvm-svn: 239903
* clang-format: [JS] Don't put top-level typescript enums on a single line.Daniel Jasper2015-06-171-27/+34
| | | | | | | | | | | This makes this consistent with non-typescript enums. Also shuffle the language-dependent stuff in mustBreakBefore to a single location. Patch initiated by Martin Probst. llvm-svn: 239894
* clang-format: NFC. Add a function to test whether an annotated lineDaniel Jasper2015-06-171-15/+14
| | | | | | | starts with a given sequence of tokens. Only the one-token version is used yet, but other usages are coming up momentarily. llvm-svn: 239892
* clang-format: Always add space before lambda-{Daniel Jasper2015-06-121-0/+1
| | | | | | | | | | | | Before: int c = []() -> int *{ return 2; }(); After: int c = []() -> int * { return 2; }(); Based on patch by James Dennett (http://reviews.llvm.org/D10410), thank you! llvm-svn: 239600
* clang-format: Understand C-style case in case label.Daniel Jasper2015-06-121-1/+1
| | | | | | | | | | | | Before: case (my_int) ONE: After: case (my_int)ONE: This fixed llvm.org/PR23760 llvm-svn: 239597
* clang-format: [JS] Ensure that formatting actually takes place in tests.Daniel Jasper2015-06-111-1/+1
| | | | | | And fix formatting issue discovered by that :-). llvm-svn: 239530
* clang-format: [JS] Only special case top level object literalDaniel Jasper2015-06-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | assignments as enums. Top level object literals are treated as enums, and their k/v pairs are put on separate lines: X.Y = { A: 1, B: 2 }; However assignments within blocks should not be affected: function x() { y = {a:1, b:2}; } This change fixes the second case. Patch by Martin Probst. llvm-svn: 239462
* clang-format: [JS] Hotfix for runtime issue with deeply nested JS code.Daniel Jasper2015-06-091-0/+4
| | | | | | | | | | | | | | I have not succeeded in writing a proper test case for this yet and we also need to solve the underlying fundamental problem of trying too many combinations with nested blocks (basically this somewhat works around our Dijkstra algorithm). Preventing this linebreak is good anyways as usually the penalties never make us choose it (that's why I can't create a test) and it also looks ugly. Also cleaned up state comparison code that I discovered while hunting this down. llvm-svn: 239398
* clang-format: More eagerly wrap trailing return types.Daniel Jasper2015-06-051-6/+7
| | | | | | | | | | | | | | | | | 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: [JS] Let fat arrows have 'Assignment' precedence.Daniel Jasper2015-06-051-1/+1
| | | | | | | | | | | | | | | | | This is a more correct representation than using "Equality" introduced in r238942 which was a quick fix to solve an actual regression. According to the typescript spec, arrows behave like "low-precedence" assignments. Before: var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) && aaaaaaaaaaaaaaaaaaaaa(bbbbbbb)); After: var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) && aaaaaaaaaaaaaaaaaaaaa(bbbbbbb)); llvm-svn: 239137
* clang-format: [JS] Let fat arrows have 'Equality' precedence.Daniel Jasper2015-06-031-13/+15
| | | | | | | | | | | | | | | | | | | | | | | This fixes a regression in literal formatting: Before: aaaaaaaaaaaaa = { aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, }; After: var aaaaaaaaaaaaaaaaaaaa = { aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, }; Also apply no-else-after-return policy. llvm-svn: 238942
* clang-format: [JS] More aggressively keep array literals on one line.Daniel Jasper2015-06-031-1/+2
| | | | | | | | | | | | | | Before: var aaaaa: List<SomeThing> = [ new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB() ]; After: var aaaaa: List<SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()]; llvm-svn: 238909
* clang-format: [JS] Fix bug in type colon detection.Daniel Jasper2015-06-031-1/+2
| | | | | | | | | | | | | Before, this couldn't be formatted at all: class X { subs = { 'b': { 'c': 1, }, }; } llvm-svn: 238907
* clang-format: [JS] Always add space after fat arrow.Daniel Jasper2015-06-021-3/+2
| | | | | | | | | | Before: return () =>[]; After: return () => []; llvm-svn: 238875
* clang-format: [JS] Array literal detection fix #4.Daniel Jasper2015-06-021-1/+2
| | | | llvm-svn: 238873
* clang-format: [JS] Array literal detection fix #3.Daniel Jasper2015-06-021-2/+2
| | | | llvm-svn: 238839
* clang-format: [JS] Fix another regression when detecting array literals.Daniel Jasper2015-06-021-1/+2
| | | | llvm-svn: 238835
* clang-format: [JS] Fix regression of detecting array literals.Daniel Jasper2015-06-021-1/+3
| | | | llvm-svn: 238832
* clang-format: [JS] Making arrow function wrapping more consistent.Daniel Jasper2015-06-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | Before: someFunction(() => { doSomething(); // break }) .doSomethingElse( // break ); After: someFunction(() => { doSomething(); // break }) .doSomethingElse( // break ); This is still bad, but at least it is consistent with what we do for other function literals. Added corresponding tests. llvm-svn: 238736
* clang-format: [JS] Fix line breaks in computed property names.Daniel Jasper2015-05-311-1/+1
| | | | | | | | | | | | | | | | | | | Before: let foo = { [someLongKeyHere]: 1, someOtherLongKeyHere: 2, [keyLongEnoughToWrap]: 3, lastLongKey: 4 }; After: let foo = { [someLongKeyHere]: 1, someOtherLongKeyHere: 2, [keyLongEnoughToWrap]: 3, lastLongKey: 4 }; llvm-svn: 238671
* clang-format: [JS] Support ES6 computed property names.Daniel Jasper2015-05-291-0/+3
| | | | | | | | | | | | | | | | Before: var x = { [a]: 1, b: 2 }; After: var x = { [a]: 1, b: 2 }; llvm-svn: 238544
* clang-format: Lower binding strengths created by the [] created by ObjCDaniel Jasper2015-05-281-13/+17
| | | | | | | | | | | | | | | | | | method expressions and array literals. They should not bind stronger than regular parentheses or the braces of braced lists. Specific test case in JavaScript: Before: var aaaaa: List< SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()]; After: var aaaaa: List<SomeThing> = [ new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB() ]; llvm-svn: 238400
* clang-format: Fix false positive in function annotation detection.Daniel Jasper2015-05-271-1/+1
| | | | llvm-svn: 238285
OpenPOWER on IntegriCloud