summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Don't generate unnecessary replacements for \r\n line endings.Daniel Jasper2015-06-171-1/+1
| | | | | | Patch by Mathieu Champlon. Thank you. llvm-svn: 239900
* 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: [JS] Fix typescript enum formatting.Daniel Jasper2015-06-171-5/+13
| | | | | | | | | | | | | | | | | | | Patch by Martin Probst. Before: enum { A, B } var x = 1; After: enum { A, B } var x = 1; llvm-svn: 239893
* clang-format: NFC. Add a function to test whether an annotated lineDaniel Jasper2015-06-173-23/+39
| | | | | | | 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: [JS] Tweak behavior for multiline array initializer parametersDaniel Jasper2015-06-151-1/+2
| | | | | | | | | | | | | | | | | | | | | Before: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); After: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); llvm-svn: 239722
* clang-format: [JS] Fix corner case in template string parsing.Daniel Jasper2015-06-141-1/+2
| | | | | | | | | | Before, these would not properly detected because of the char/string literal found when re-lexing after the first `: var x = `'`; // comment with matching quote ' var x = `"`; // comment with matching quote " llvm-svn: 239693
* [clang-format] Use in-class initializers to simplify constructor.Benjamin Kramer2015-06-121-17/+14
| | | | | | Sadly C++11 doesn't let us use initializers on bitfield members (DR1341). NFC. llvm-svn: 239606
* [clang-format] Reorder and pack ParenState members to minimize paddingBenjamin Kramer2015-06-121-36/+36
| | | | | | sizeof(ParenState) goes from 64 bytes to 52 bytes. NFC. llvm-svn: 239605
* [clang-format] Hoist vector allocation out of loop. NFC.Benjamin Kramer2015-06-121-2/+5
| | | | llvm-svn: 239604
* 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] Support "export enum" declarations.Daniel Jasper2015-06-121-1/+2
| | | | llvm-svn: 239595
* clang-format: [JS] Fix regression caused by r239592.Daniel Jasper2015-06-121-0/+1
| | | | | | | | | | Without it, it would do: interface I { x: string; } var y; llvm-svn: 239593
* clang-format: [JS] fix incorrectly collapsed lines after exportDaniel Jasper2015-06-121-6/+8
| | | | | | | | | | | | | statement. When an exported function would follow a class declaration, it would not be recognized as a stand-alone function. That would then collapse the following line with the current one, e.g. class C {} export function f() {} var x; llvm-svn: 239592
* clang-format: Make SFS_Inline imply SFS_Empty.Daniel Jasper2015-06-111-1/+1
| | | | | | | | | | In the long run, these two might be independent or we might to only allow specific combinations. Until we have a corresponding request, however, it is hard to do the right thing and choose the right configuration options. Thus, just don't touch the options yet and just modify the behavior slightly. llvm-svn: 239531
* 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
* Fix crash in clang-format.Manuel Klimek2015-06-111-2/+4
| | | | | | | | | | | The following example used to crash clang-format. #define a\ /**/} Adjusting the indentation level cache for the line starting with the comment would lead to an out-of-bounds array read. llvm-svn: 239521
* clang-format: Don't add spaces in foreach macro definition.Daniel Jasper2015-06-111-1/+4
| | | | | | | | | | | | Before clang-format would e.g. add a space into #define Q_FOREACH(x, y) which turns this into a non-function-like macro. Patch by Strager Neds, thank you! llvm-svn: 239513
* 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: Support //!-comments, increase test coverage.Daniel Jasper2015-06-091-1/+3
| | | | llvm-svn: 239404
* clang-format: [JS] Hotfix for runtime issue with deeply nested JS code.Daniel Jasper2015-06-092-3/+7
| | | | | | | | | | | | | | 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-053-8/+9
| | | | | | | | | | | | | | | | | 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: Properly reset BreakBeforeParameter when wrappingDaniel Jasper2015-06-031-0/+2
| | | | | | | | | | | | | | | | | operators to the new line. Before: LOG_IF(aaa == // bbb) << a << b; After: LOG_IF(aaa == // bbb) << a << b; llvm-svn: 238911
* 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: Don't try to detect C++ lambdas in other languages.Daniel Jasper2015-06-021-0/+4
| | | | llvm-svn: 238845
* clang-format: [JS] Fix incorrect line length calculation.Daniel Jasper2015-06-021-1/+2
| | | | llvm-svn: 238841
* 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
* Remove error message when using the fallback style.Manuel Klimek2015-06-021-2/+0
| | | | llvm-svn: 238822
* clang-format: [JS] Making arrow function wrapping more consistent.Daniel Jasper2015-06-012-10/+6
| | | | | | | | | | | | | | | | | | | | | | 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
* [Format] Move UnwrappedLines instead of copying.Benjamin Kramer2015-05-311-7/+4
| | | | | | No functional change intended. llvm-svn: 238673
* clang-format: NFC. Cleanup after r237895.Daniel Jasper2015-05-312-31/+8
| | | | | | | | | | | Specifically adhere to LLVM Coding Standards (no 'else' after return/break/continue) and remove yet another implementation of paren counting. We already have enough of those in the UnwrappedLineParser. No functional changes intended. llvm-svn: 238672
* 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-292-0/+4
| | | | | | | | | | | | | | | | Before: var x = { [a]: 1, b: 2 }; After: var x = { [a]: 1, b: 2 }; llvm-svn: 238544
* [Format] Skip creating temporary std::strings when filling another string.Benjamin Kramer2015-05-281-6/+6
| | | | | | No functional change intended. llvm-svn: 238466
* 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: [JS] Fix incorrect detection of ternary expressions.Daniel Jasper2015-05-271-4/+3
| | | | | | | | | | | | | A definintion like this could not be formatted at all: constructor({aa}: { aa?: string, aaaaaaaa?: string, aaaaaaaaaaaaaaa?: boolean, aaaaaa?: List<string> }) { } llvm-svn: 238291
* clang-format: Fix false positive in function annotation detection.Daniel Jasper2015-05-271-1/+1
| | | | llvm-svn: 238285
* clang-format: Guard the bin-packing in braced lists on BinPackArgumentsDaniel Jasper2015-05-262-4/+4
| | | | | | | | instead of BinPackParameters. Braced lists are used as constructor calls in many places and so the bin-packing should follow what is done for other calls and not what is done for function declarations. llvm-svn: 238184
* 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: Fix child-formatting in macros.Daniel Jasper2015-05-261-4/+8
| | | | | | | | | | | | | | | This fixes a case where the column limit was incorrectly calculated leading to a macro like this: #define A \ [] { \ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx( \ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx); \ } exceeding the column limit. llvm-svn: 238182
* clang-format: [JS] Better support for fat arrows.Manuel Klimek2015-05-214-18/+70
| | | | | | | | | | | | 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: 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
OpenPOWER on IntegriCloud