summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Add option to break after definition return type for top-level ↵Birunthan Mohanathas2015-06-293-5/+23
| | | | | | | | functions only Differential Revision: http://reviews.llvm.org/D10774 llvm-svn: 240959
* clang-format: Adjust Mozilla style defaultsBirunthan Mohanathas2015-06-291-3/+5
| | | | | | | | Summary: This makes the Mozilla style defaults more compliant with the Mozilla style guide. A few options were removed in order to use the LLVM style defaults. Differential Revision: http://reviews.llvm.org/D10771 llvm-svn: 240957
* clang-format: Don't indent relative to unary operators (some more).Daniel Jasper2015-06-291-1/+1
| | | | | | | | | | | | | | | | Before: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); After: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); llvm-svn: 240934
* clang-format: Stop old options from overriding new optionsBirunthan Mohanathas2015-06-281-10/+10
| | | | | | | | | | | | | | Summary: Depends on D10785. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D10786 llvm-svn: 240909
* clang-format: Alphabetize FormatStyle membersBirunthan Mohanathas2015-06-281-33/+33
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D10784 llvm-svn: 240907
* clang-format: Support @autoreleasepool.Nico Weber2015-06-281-0/+10
| | | | | | | | | | Format @autoreleasepool properly for the Attach brace style by recognizing @autoreleasepool as a block introducer. Patch from Strager Neds! http://reviews.llvm.org/D10372 llvm-svn: 240896
* 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
* clang-format: [JS] Support regex literals containing quotes (' and ").Daniel Jasper2015-06-241-3/+23
| | | | llvm-svn: 240548
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* clang-format: Make exception to AlwaysBreakBeforeMultilineStrings moreDaniel Jasper2015-06-191-1/+1
| | | | | | | | | | | | | | | | | | conservative. In particular, this fixes an unwanted corner case. Before: string s = someFunction("aaaa" "bbbb"); After: string s = someFunction( "aaaa" "bbbb"); llvm-svn: 240129
* clang-format: Better fix to detect elaborated enum return types.Daniel Jasper2015-06-191-3/+8
| | | | | | | The previous one (r240021) regressed: enum E Type::f() { .. } llvm-svn: 240127
* Fix "the the" in comments/documentation/etc.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240110
* clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change.Daniel Jasper2015-06-181-1/+2
| | | | | | | | | | | | | | | It was a bit too aggressive. With this patch, we keep on breaking here: aaaaaaaaaaaaa(aaaaaaa, "aaaaaaa" "bbbbbbb"); But don't break in: aaaaaaaaaaaaa(aaaaaaa, aaaaaaaa("aaaaaaa" "bbbbbbb")); llvm-svn: 240024
* clang-format: Better support functions with elaborated enum return types.Daniel Jasper2015-06-181-0/+2
| | | | | | | | | Before, this wasn't formatted properly: enum ::C f() { return a; } llvm-svn: 240021
* clang-format: [JS] Add a special case for indenting function literals.Daniel Jasper2015-06-181-1/+15
| | | | | | | | | | | | | | | | | | | | Before: var func = function() { doSomething(); }; After: var func = function() { doSomething(); }; This is a very narrow special case which fixes most of the discrepency with what our users do. In the long run, we should try to come up with a more generic fix for indenting these. llvm-svn: 240014
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-1/+1
| | | | | | is(). llvm-svn: 240008
* clang-format: Make AlwaysBreakBeforeMultilineStrings more conservative.Daniel Jasper2015-06-181-7/+9
| | | | | | | | | | | | | | | | | In essence this is meant to consistently indent multiline strings by a fixed amount of spaces from the start of the line. Don't do this in cases where it wouldn't help anyway. Before: someFunction(aaaaa, "aaaaa" "bbbbb"); After: someFunction(aaaaa, "aaaaa" "bbbbb"); llvm-svn: 240004
* clang-format: clang-format (NFC)Daniel Jasper2015-06-179-46/+33
| | | | llvm-svn: 239903
* 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
OpenPOWER on IntegriCloud