summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* clang-format: [JS] Support ES6 spread operator.Daniel Jasper2015-05-261-0/+2
| | | | | | | | | | | | | | Specifically, don't add a space before it. Before: someFunction(... a); var x = [1, 2, ... a]; After: someFunction(...a); var x = [1, 2, ...a]; llvm-svn: 238183
* clang-format: Add space in function pointers with SpaceBeforeParens=AlwaysAnders Waldenborg2015-05-191-1/+1
| | | | | | | | | "void (*my_function)(void)" should become "void (*my_function) (void)" when SpaceBeforeParens is set to 'Always' Differential Revision: http://reviews.llvm.org/D9835 llvm-svn: 237704
* clang-format: Improve *-detection.Daniel Jasper2015-05-191-0/+3
| | | | | | | | | | | | Before: S << a *(10); After: S << a * (10); This fixes llvm.org/PR16500. llvm-svn: 237690
* clang-format: Improve for-loop formatting.Daniel Jasper2015-05-191-1/+2
| | | | | | | | | | | | | | | | | | Before: for (SmallVectorImpl<TemplateIdAnnotationn *>::iterator I = Container.begin(), E = Container.end(); I != E; ++I) After: for (SmallVectorImpl<TemplateIdAnnotationn *>::iterator I = Container.begin(), E = Container.end(); I != E; ++I) This fixes llvm.org/PR23544. llvm-svn: 237688
* clang-format: Support #include_nextDaniel Jasper2015-05-191-0/+1
| | | | | | | | | | | | Before: #include_next < test.h > After: #include_next <test.h> This fixes llvm.org/PR23500 llvm-svn: 237686
* clang-format: Correctly detect casts to qualified types.Daniel Jasper2015-05-191-1/+2
| | | | | | | | | | | | Before: ns::E f() { return (ns::E) - 1; } After: ns::E f() { return (ns::E)-1; } This fixes llvm.org/PR23503. llvm-svn: 237684
* clang-format: Fix regression caused by r237244.Daniel Jasper2015-05-191-1/+1
| | | | | | | | | | | | | | | Before: [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa. aaaaaaaa]; After: [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa .aaaaaaaa]; This merely papers over the fact that we aren't parsing ObjC method calls correctly. Also, the indentation is weird. llvm-svn: 237681
* clang-format: Improve detection of macros annotating functions.Daniel Jasper2015-05-181-13/+9
| | | | | | | | | | | | | | | | 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-1/+14
| | | | | | | | | | | | 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: Improve line wrapping around << operators.Daniel Jasper2015-05-171-1/+2
| | | | | | | | | | | | | | | | | | Generally, clang-format tries to keep label-value pairs on a single line for stream operators. However, we should not do that if there is just a single such pair, as that doesn't help much. Before: llvm::errs() << "aaaaaaaaaaaa: " << aaaaaaa(aaaaaaaaa, aaaaaaaaa); After: llvm::errs() << "aaaaaaaaaaaa: " << aaaaaaa(aaaaaaaaa, aaaaaaaaa); Also remove old test case that was testing actual behavior any more. llvm-svn: 237535
* clang-format: Slightly change format decisions around macro annotations.Daniel Jasper2015-05-151-1/+1
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 237430
* clang-format: Add missing space before ObjC selector.Daniel Jasper2015-05-151-1/+6
| | | | | | | | | | Before: [self aaaaa:(1 + 2)bbbbb:3]; After: [self aaaaa:(1 + 2) bbbbb:3]; llvm-svn: 237424
* clang-format: Fix incorrect */& classification.Daniel Jasper2015-05-131-0/+4
| | | | | | | | | | Before: void f() { f(new a(), c *d); } After: void f() { f(new a(), c * d); } llvm-svn: 237249
* clang-format: [ObjC] Further improve wrapping of methods calls without inputs.Daniel Jasper2015-05-131-1/+2
| | | | | | | | | | | | Before: [aaaaaaaaaaaaaaaaaaaaaaa .aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa]; llvm-svn: 237244
* clang-format: Prefer formatting local lambdas like functions.Daniel Jasper2015-05-131-0/+3
| | | | | | | | | | | | | Before: auto my_lambda = [](const string &some_parameter) { return some_parameter.size(); }; After: auto my_lambda = [](const string &some_parameter) { return some_parameter.size(); }; llvm-svn: 237235
* clang-format: Fix */& detection for lambdas in macros.Daniel Jasper2015-05-121-5/+5
| | | | | | | | | | Before: #define MACRO() [](A * a) { return 1; } After: #define MACRO() [](A *a) { return 1; } llvm-svn: 237109
* clang-format: Support aligning ObjC string literals.Daniel Jasper2015-05-111-13/+19
| | | | | | | | | | | | Before: NSString s = @"aaaa" @"bbbb"; After: NSString s = @"aaaa" @"bbbb"; llvm-svn: 237000
* clang-format: Preserve line break before } in __asm { ... }.Daniel Jasper2015-05-101-1/+4
| | | | | | | | 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: [JS] Avoid bad line-warp around "function".Daniel Jasper2015-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | Before: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function( aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); After: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); llvm-svn: 236813
* clang-format: Improve r236597, Properly indent method calls without inputs.Daniel Jasper2015-05-071-1/+1
| | | | | | | | | | | | Before: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaa(aaaaaa) aaaaaaaaaaaaaaaaaaaa]; llvm-svn: 236730
* clang-format: Merge labels and subsequent semicolons.Daniel Jasper2015-05-061-1/+1
| | | | | | | | | | | 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: Allow ternary expressions inside template parameters ifDaniel Jasper2015-05-061-2/+7
| | | | | | | | the template parameters aren't inside an expression context. This fixes llvm.org/PR23270. llvm-svn: 236603
* clang-format: Consider operator precedence as penalty when breakingDaniel Jasper2015-05-061-0/+3
| | | | | | | | before operators. This fixes llvm.org/23382. llvm-svn: 236602
* clang-format: Prevent assertion discovered by fuzzer.Daniel Jasper2015-05-061-2/+10
| | | | llvm-svn: 236578
* clang-format: Prevent exponential runtime in token annotator.Daniel Jasper2015-05-061-1/+11
| | | | llvm-svn: 236577
* clang-format: [JS] support optional methods.Daniel Jasper2015-05-051-15/+37
| | | | | | | | | | | | | | | 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-7/+6
| | | | llvm-svn: 236415
* clang-format: Force aligning different brackets relative to each other.Daniel Jasper2015-05-041-2/+6
| | | | | | | | | | | | Before: void SomeFunction(vector< // break int> v); After: void SomeFunction(vector< // break int> v); llvm-svn: 236412
* clang-format: [JS] Fix templated parameter default values.Daniel Jasper2015-05-021-1/+1
| | | | | | | | | | Parameters can have templated types and default values (= ...), which is another location in which a template closer should be followed by whitespace. Patch by Martin Probst, thank you. llvm-svn: 236382
* clang-format: Properly detect variable declarations with ObjC.Daniel Jasper2015-04-231-1/+2
| | | | | | | | | | | | Before: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); After: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); llvm-svn: 235599
* clang-format: Allow splitting "= default" and "= delete".Daniel Jasper2015-04-231-1/+2
| | | | | | Otherwise, this can violate the column limit. llvm-svn: 235592
* clang-format: Don't add unwanted space when creating new arrays.Daniel Jasper2015-04-231-1/+2
| | | | | | | | | | Before: char** newargv = new char* [argc]; After: char** newargv = new char*[argc]; llvm-svn: 235583
* clang-format: [Proto] Don't linewrap top-level options.Daniel Jasper2015-04-231-2/+10
| | | | | | They are very similar to import statements. llvm-svn: 235582
* clang-format: Fix for #pragma option formatting.Daniel Jasper2015-04-221-2/+5
| | | | | | Adapted patch from Sergey Razmetov. Thank you. llvm-svn: 235492
* clang-format: Fix incorrect multi-var declstmt detection.Daniel Jasper2015-04-201-3/+3
| | | | | | | | | | | | This is now obvious as the pointer alignment behavior was changed. Before (even with pointer alignment "Left"): MACRO Constructor(const int &i) : a(a), b(b) {} After: MACRO Constructor(const int& i) : a(a), b(b) {} llvm-svn: 235301
* clang-format: Undo r214508. It was essentially always removing theDaniel Jasper2015-04-161-1/+1
| | | | | | | space where we already had the flag ObjCSpaceBeforeProtocolList to control it. I don't know what I was thinking. llvm-svn: 235076
* clang-format: Determine "in" as a keyword in ObjC for loops more preciselyDaniel Jasper2015-04-151-23/+21
| | | | | | | | | | | | Before: for (int i = 0; i < in [a]; ++i) .. After: for (int i = 0; i < in[a]; ++i) .. Also do some related cleanups. llvm-svn: 234980
* clang-format: [JS] Support index signature types.Daniel Jasper2015-04-131-1/+2
| | | | | | Patch by Martin Probst. llvm-svn: 234754
* clang-format: [JS] support optionality markers in JS types.Daniel Jasper2015-04-131-10/+22
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234753
* clang-format: [JS] Understand object literals with only methods.Daniel Jasper2015-04-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Before: let theObject = {someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); }}; After: let theObject = { someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); } }; llvm-svn: 234091
* clang-format: Force line break in trailing calls after multline exprs.Daniel Jasper2015-03-261-3/+3
| | | | | | | | | | | | | Before: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb).a(); After: aaaaaaaa(aaaaaaaaaa, bbbbbbbbbb) .a(); llvm-svn: 233304
* clang-format: Fix another bug in wrapping around "*".Daniel Jasper2015-03-191-3/+3
| | | | | | | | | | | | Before: void aaaaa( aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} // even violation the column limit After: void aaaaa(aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} llvm-svn: 232717
OpenPOWER on IntegriCloud