summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-format] Improve detection of Objective-C block typesBen Hamilton2018-03-121-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect the following as an Objective-C block type: FOO(^); when it actually must be a C or C++ macro dealing with an XOR statement or an XOR operator overload. According to the Clang Block Language Spec: https://clang.llvm.org/docs/BlockLanguageSpec.html block types are of the form: int (^)(char, float) and block variables of block type are of the form: void (^blockReturningVoidWithVoidArgument)(void); int (^blockReturningIntWithIntAndCharArguments)(int, char); void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int); This tightens up the detection so we don't unnecessarily detect C macros which pass in the XOR operator. Depends On D43904 Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak, djasper Reviewed By: djasper Subscribers: djasper, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43906 llvm-svn: 327285
* [clang-format] Don't detect C++11 attribute specifiers as ObjCBen Hamilton2018-03-121-11/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect C++11 and C++17 attribute specifiers like the following as Objective-C method invocations: [[noreturn]]; [[clang::fallthrough]]; [[noreturn, deprecated("so sorry")]]; [[using gsl: suppress("type")]]; To fix this, I ported part of the logic from tools/clang/lib/Parse/ParseTentative.cpp into TokenAnnotator.cpp so we can explicitly parse and identify C++11 attribute specifiers. This allows the guessLanguage() and getStyle() APIs to correctly guess files containing the C++11 attribute specifiers as C++, not Objective-C. Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak, djasper Reviewed By: djasper Subscribers: aaron.ballman, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43902 llvm-svn: 327284
* clang-format: Properly handle implicit string concatenation in text protosDaniel Jasper2018-03-121-1/+1
| | | | | | | | | | | | | Three issues to fix: - char_constants weren't properly treated as string literals - Prevening the break after "label: " does not make sense in concunction with AlwaysBreakBeforeMultilineStrings. It leads to situations where clang-format just cannot find a viable format (it must break and yet it must not break). - AlwaysBreakBeforeMultilineStrings should not be on for LK_TextProto in Google style. llvm-svn: 327255
* [clang-format] Break consecutive string literals in text protosKrasimir Georgiev2018-03-071-1/+2
| | | | | | | | | | | | | | | | Summary: This patch fixes a bug where consecutive string literals in text protos were put on the same line. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44204 llvm-svn: 326945
* [clang-format] Improve detection of ObjC for-in statementsBen Hamilton2018-03-061-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect the following as an Objective-C for-in statement: for (int x = in.value(); ...) {} because the logic only decided a for-loop was definitely *not* an Objective-C for-in loop after it saw a semicolon or a colon. To fix this, I delayed the decision of whether this was a for-in statement until after we found the matching right-paren, at which point we know if we've seen a semicolon or not. Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak Reviewed By: jolesiak Subscribers: djasper, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43904 llvm-svn: 326815
* [clang-format] fix handling of consecutive unary operatorsKrasimir Georgiev2018-03-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Code that used to be formatted as `if (! + object) {` is now formatted as `if (!+object) {` (we have a particular object in our codebase where unary `operator+` is overloaded to return the underlying value, which in this case is a `bool`) We still preserve the TypeScript behavior where `!` is a trailing non-null operator. (This is already tested by an existing unit test in `FormatTestJS.cpp`) It doesn't appear like handling of consecutive unary operators are tested in general, so I added another test for completeness Patch contributed by @kevinl! Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43312 llvm-svn: 326792
* [clang-format] Add SpaceBeforeColon optionFrancois Ferrand2018-03-011-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When disabled, this option allows removing the space before colon, making it act more like the semi-colon. When enabled (default), the current behavior is not affected. This mostly affects C++11 loop, initializer list, inheritance list and container literals: class Foo: Bar {} Foo::Foo(): a(a) {} for (auto i: myList) {} f({a: 1, b: 2, c: 3}); Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32525 llvm-svn: 326426
* [clang-format] Format operator key in protosKrasimir Georgiev2018-02-271-0/+3
| | | | | | | | | | Summary: This fixes a glitch where ``operator: value`` in a text proto would mess up the underlying formatting since it gets parsed as a kw_operator instead of an identifier. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43830 llvm-svn: 326227
* [clang-format] Fixup a case of text proto message attributesKrasimir Georgiev2018-02-191-0/+6
| | | | | | | | | | Summary: This patch fixes a case where a proto message attribute is wrongly identified as an text proto extension. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43465 llvm-svn: 325509
* clang-format: [JS] fix `of` detection.Martin Probst2018-02-191-1/+1
| | | | | | | | | | | | | | | | | | | Summary: `of` is only a keyword when after an identifier, but not when after an actual keyword. Before: return of (a, b, c); After: return of(a, b, c); Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43440 llvm-svn: 325489
* [clang-format] Support repeated field lists in protosKrasimir Georgiev2018-02-151-7/+24
| | | | | | | | | | | | | | | | | | Summary: This patch adds support for list initialization of proto repeated fields: ``` keys: [1, 2, 3] ``` Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43298 llvm-svn: 325252
* [clang-format] Recognize percents as format specifiers in protosKrasimir Georgiev2018-02-141-0/+3
| | | | | | | | | | | | | | | | Summary: Frequently, a percent in protos denotes a formatting specifier for string replacement. Thus it is desirable to keep the percent together with what follows after it. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43294 llvm-svn: 325159
* [clang-format] Support text proto extensionsKrasimir Georgiev2018-02-131-6/+38
| | | | | | | | | | | | | | | | | | | | | | Summary: This adds support for text proto extensions, like: ``` msg { [type.type/ext] { key: value } } ``` Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43180 llvm-svn: 324995
* clang-format: keep ObjC colon alignment with short object nameFrancois Ferrand2018-02-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When the target object expression is short and the first selector name is long, clang-format used to break the colon alignment: [I performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; This happens because the colon is placed at `ContinuationIndent + LongestObjCSelectorName`, so that any selector can be wrapped. This is however not needed in case the longest selector is the firstone, and not wrapped. To overcome this, this patch does not include the first selector in `LongestObjCSelectorName` computation (in TokenAnnotator), and lets `ContinuationIndenter` decide how to account for the first selector when wrapping. (Note this was already partly the case, see line 521 of ContinuationIndenter.cpp) This way, the code gets properly aligned whenever possible without breaking the continuation indent. [I performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; [I // force break performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; [I perform:@selector(loadAccessories) withSelectorOnMainThread:true waitUntilDone:false]; Reviewers: krasimir, djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43121 llvm-svn: 324741
* [clang-format] Do not break before long string literals in protosKrasimir Georgiev2018-02-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is a follow-up to r323319 (which disables string literal breaking for text protos) and it disables breaking before long string literals. For example this: ``` keyyyyy: "long string literal" ``` used to get broken into: ``` keyyyyy: "long string literal" ``` While at it, I also enabled it for LK_Proto and fixed a bug in the mustBreak code. Reviewers: djasper, sammccall Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42957 llvm-svn: 324591
* [clang-format] Fix ObjC message arguments formatting.Jacek Olesiak2018-02-071-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixes formatting of ObjC message arguments when inline block is a first argument. Having inline block as a first argument when method has multiple parameters is discouraged by Apple: "It’s best practice to use only one block argument to a method. If the method also needs other non-block arguments, the block should come last" (https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW7), it should be correctly formatted nevertheless. Current formatting: ``` [object blockArgument:^{ a = 42; } anotherArg:42]; ``` Fixed (colon alignment): ``` [object blockArgument:^{ a = 42; } anotherArg:42]; ``` Test Plan: make -j12 FormatTests && tools/clang/unittests/Format/FormatTests Reviewers: krasimir, benhamilton Reviewed By: krasimir, benhamilton Subscribers: benhamilton, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42493 llvm-svn: 324469
* [clang-format] Adds space around angle brackets in text protosKrasimir Georgiev2018-02-061-6/+40
| | | | | | | | | | | | | | | | | | Summary: This patch adds spaces around angle brackets in text proto Google style. Previously these were detected as template openers and closers, which happened to have the expected effect. Now we detect them as scope openers and closers similarly to the way braces are handled in this context. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42727 llvm-svn: 324337
* [clang-format] Align preprocessor comments with #Mark Zeren2018-01-311-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: r312125, which introduced preprocessor indentation, shipped with a known issue where "indentation of comments immediately before indented preprocessor lines is toggled on each run". For example these two forms toggle: #ifndef HEADER_H #define HEADER_H #if 1 // comment # define A 0 #endif #endif #ifndef HEADER_H #define HEADER_H #if 1 // comment # define A 0 #endif #endif This happens because we check vertical alignment against the '#' yet indent to the level of the 'define'. This patch resolves this issue by aligning against the '#'. Reviewers: krasimir, klimek, djasper Reviewed By: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42408 llvm-svn: 323904
* clang-format: [JS] Prevent ASI before [ and (.Martin Probst2018-01-261-3/+5
| | | | | | | | | | | | | | | Summary: JavaScript automatic semicolon insertion can trigger before [ and (, so avoid breaking before them if the previous token is likely to terminate an expression. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42570 llvm-svn: 323532
* [clang-format] Fixes indentation of inner text proto messagesKrasimir Georgiev2018-01-251-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Consider the text proto: ``` message { sub { key: value } } ``` Previously the first `{` was TT_Unknown, which caused the inner message to be indented by the continuation width. This didn't happen for: ``` message { sub: { key: value } } ``` This is because the code to mark the first `{` as a TT_DictLiteral was only considering the case where it marches forward and reaches a `:`. This patch updates this by looking not only for `:`, but also for `<` and `{`. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42500 llvm-svn: 323419
* Fix typo in comment.Nico Weber2018-01-241-1/+1
| | | | llvm-svn: 323293
* [c++20] P0515R3: Parsing support and basic AST construction for operator <=>.Richard Smith2017-12-141-1/+1
| | | | | | | | | | | | | | | Adding the new enumerator forced a bunch more changes into this patch than I would have liked. The -Wtautological-compare warning was extended to properly check the new comparison operator, clang-format needed updating because it uses precedence levels as weights for determining where to break lines (and several operators increased their precedence levels with this change), thread-safety analysis needed changes to build its own IL properly for the new operator. All "real" semantic checking for this operator has been deferred to a future patch. For now, we use the relational comparison rules and arbitrarily give the builtin form of the operator a return type of 'void'. llvm-svn: 320707
* clang-format: [JS] do not wrap after async/await.Martin Probst2017-11-301-6/+6
| | | | | | | | | | | | | | Summary: Otherwise automatic semicolon insertion can trigger, i.e. wrapping produces invalid syntax. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40642 llvm-svn: 319415
* clang-format: [JS] handle `for` as object label.Martin Probst2017-11-251-1/+3
| | | | | | | | | | | | Summary: Previously, clang-format would fail formatting `{for: 1}`. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40441 llvm-svn: 318974
* clang-format: [JS] do not break in ArrayType[].Martin Probst2017-11-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: Wrapping between the type name and the array type indicator creates invalid syntax in TypeScript. Before: const xIsALongIdent: YJustBarelyFitsLinex []; // illegal syntax. After: const xIsALongIdent: YJustBarelyFitsLinex[]; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40436 llvm-svn: 318959
* clang-format: [JS] do not wrap before yield.Martin Probst2017-11-241-2/+2
| | | | | | | | | | | | Summary: The same rules apply as for `return`. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40431 llvm-svn: 318958
* clang-format: [JS] space between ! assert and in.Martin Probst2017-11-241-2/+3
| | | | | | | | | | | | | | | | Summary: Before: x = y!in z; After: x = y! in z; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40433 llvm-svn: 318957
* clang-format: [JS] handle destructuring `of`.Martin Probst2017-11-241-2/+4
| | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would drop a space character between `of` and then following (non-identifier) token if the preceding token was part of a destructuring assignment (`}` or `]`). Before: for (const [a, b] of[]) {} After: for (const [a, b] of []) {} Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40411 llvm-svn: 318942
* Update link to protobufHans Wennborg2017-11-131-1/+1
| | | | llvm-svn: 318110
* [clang-format] Handle unary operator overload with arguments and specifiersDaniel Jasper2017-11-061-1/+2
| | | | | | | | | | | | Before: int operator++(int)noexcept; After: int operator++(int) noexcept; Patch by Igor Sugak. Thank you! llvm-svn: 317473
* [clang-format] Make parseUnaryOperator non-recursive, NFCIKrasimir Georgiev2017-11-011-10/+8
| | | | | | | | | | | | | | | | | Summary: This patch makes the implementation of parseUnaryOperator non-recursive. We had a problem with a file starting with tens of thousands of +'es and -'es which caused clang-format to stack overflow. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39498 llvm-svn: 317113
* [clang-format] Format raw string literalsKrasimir Georgiev2017-10-301-1/+2
| | | | | | | | | | | | | | | Summary: This patch adds raw string literal formatting. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: klimek, mgorny Differential Revision: https://reviews.llvm.org/D35943 llvm-svn: 316903
* clang-format/java: Unbreak genenrics formatting after r299952.Nico Weber2017-09-271-2/+2
| | | | | | | | | | | | | | https://reviews.llvm.org/rL299952 merged '>>>' tokens into a single JavaRightLogicalShift token. This broke formatting of generics nested more than two deep, e.g. Foo<Bar<Baz>>> because the '>>>' now weren't three '>' for parseAngle(). Luckily, just deleting JavaRightLogicalShift fixes things without breaking the test added in r299952, so do that. https://reviews.llvm.org/D38291 llvm-svn: 314325
* [clang-format] Adjust space around &/&& of structured bindingsChih-Hung Hsieh2017-09-271-4/+12
| | | | | | | | | | | Keep space before or after the &/&& tokens, but not both. For example, auto [x,y] = a; auto &[xr, yr] = a; // LLVM style auto& [xr, yr] = a; // google style Differential Revision:https://reviews.llvm.org/D35743 llvm-svn: 314264
* clang-format/java: Always put space after `assert` keyword.Nico Weber2017-09-251-0/+2
| | | | | | Previously, it was missing if the expression after the assert started with a (. llvm-svn: 314172
* clang-format clang-format.Manuel Klimek2017-09-201-53/+50
| | | | llvm-svn: 313744
* Fix clang-format's detection of structured bindings.Manuel Klimek2017-09-201-11/+1
| | | | | | | | | | | | | | | | | | | Correctly determine when [ is part of a structured binding instead of a lambda. To be able to reuse the implementation already available, this patch also: - sets the Previous link of FormatTokens in the UnwrappedLineParser - moves the isCppStructuredBinding function into FormatToken Before: auto const const &&[x, y] { A *i }; After: auto const const && [x, y]{A * i}; Fixing formatting of the type of the structured binding is still missing. llvm-svn: 313742
* clang-format: [JS] wrap and indent `goog.setTestOnly` calls.Martin Probst2017-09-111-1/+0
| | | | | | | | | | | | | | | | | | Summary: While `goog.setTestOnly` usually appears in the imports section of a file, it is not actually an import, and also usually doesn't take long parameters (nor namespaces as a parameter, it's a description/message that should be wrapped). This fixes a regression where a `goog.setTestOnly` call nested in a function was not wrapped. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D37685 llvm-svn: 312918
* [clang-format] Add support for C++17 structured bindings.Marek Kurdej2017-09-071-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before: ``` auto[a, b] = f(); ``` After: ``` auto [a, b] = f(); ``` or, if SpacesInSquareBrackets is true: ``` auto [ a, b ] = f(); ``` Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37132 llvm-svn: 312723
* clang-format: Fix formatting of for loops with multiple increments.Daniel Jasper2017-09-031-0/+5
| | | | | | This fixes llvm.org/PR34366. llvm-svn: 312437
* [clang-format] Fixed typedef enum brace wrappingKrasimir Georgiev2017-08-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **Typedef enum part** **Problem:** Clang format does not allow the flag **BraceWrapping.AfterEnum** control the case when our **enum** is preceded by **typedef** keyword (what is common in C language). **Patch description:** Added case to the **"AfterEnum"** flag when our enum does not start a line - is preceded by **typedef** keyword. **After fix:** **CONFIG:** ``` BreakBeforeBraces: Custom BraceWrapping: { AfterClass: true, AfterControlStatement: true, AfterEnum: true, AfterFunction: true, AfterNamespace: false, AfterStruct: true, AfterUnion: true, BeforeCatch: true, BeforeElse: true } ``` **BEFORE:** ``` typedef enum { a, b, c } SomeEnum; ``` **AFTER:** ``` typedef enum { a, b, c } SomeEnum; ``` Contributed by @PriMee! Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37143 llvm-svn: 311998
* clang-format: [JS] wrap optional properties in type aliases.Martin Probst2017-08-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang-format wraps object literal keys in an object literal if they are marked as `TT_SelectorName`s and/or the colon is marked as `TT_DictLiteral`. Previously, clang-format would accidentally work because colons in type aliases were marked as `TT_DictLiteral`. r310367 fixed this to assing `TT_JsTypeColon`, which broke wrapping in certain situations. However the root cause was that clang-format incorrectly didn't skip questionmarks when detecting selector name. This change fixes both locations to (1) assign `TT_SelectorName` and (2) treat `TT_JsTypeColon` like `TT_DictLiteral`. Previously: type X = { a: string, b?: string, }; Now: type X = { a: string, b?: string, }; Reviewers: djasper, sammccall Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D36684 llvm-svn: 310852
* clang-format: [JS] do not insert whitespace in call positions.Martin Probst2017-08-141-7/+14
| | | | | | | | | | | | | | | | | | | | Summary: In JavaScript, may keywords can be used in method names and thus call sites: foo.delete(); foo.instanceof(); clang-format would previously insert whitespace after the `instanceof`. This change generically skips inserting whitespace between a keyword and a parenthesis if preceded by a dot, i.e. in a callsite. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36142 llvm-svn: 310851
* clang-format: Fix left pointer alignment after delctype/typeofKrasimir Georgiev2017-08-141-8/+19
| | | | | | | | | | | | | Change 272124* introduced a regression in spaceRequiredBetween for left aligned pointers to decltype and typeof expressions. This fix adds logic to fix this. The test added is based on a related test in determineStarAmpUsage. Also add test cases for the regression. http://llvm.org/viewvc/llvm-project?view=revision&revision=272124 LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=30407 Differential revision: https://reviews.llvm.org/D35847 Fix contributed by euhlmann! llvm-svn: 310831
* [clang-format] let PointerAlignment dictate spacing of function ref qualifiersJacob Bandes-Storch2017-08-101-2/+1
| | | | | | | | | | | | | | Summary: The original changes for ref qualifiers in rL272537 and rL272548 allowed function const+ref qualifier spacing to diverge from the spacing used for variables. It seems more consistent for `T const& x;` to match `void foo() const&;`. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34324 llvm-svn: 310544
* clang-format: [JS] fix union type spacing in object & array types.Martin Probst2017-08-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would insert whitespace in union types nested in object and array types, as it wouldn't recognize those as a type operator: const x: {foo: number | null}; const x: [number | null]; While this is correct for actual binary operators, clang-format should not insert whitespace into union and intersection types to mark those: const x: {foo: number|null}; const x: [number|null]; This change propagates that the context is not an expression by inspecting the preceding token and marking as non-expression if it was a type colon. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36136 llvm-svn: 310367
* clang-format: [JS] no whitespace between typeof operator and l_paren.Martin Probst2017-08-011-1/+1
| | | | llvm-svn: 309713
* clang-format: [JS] prefer wrapping chains over empty literals.Martin Probst2017-08-011-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: E.g. don't wrap like this: (foo.bar.baz).and.bam(Blah.of({ })) But rather: (foo.bar.baz) .and.bam(Blah.of({})) Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36139 llvm-svn: 309712
* clang-format: [JS] whitespace between keywords and parenthesized expressions.Martin Probst2017-08-011-0/+3
| | | | | | | | | | | | Summary: `throw (...)` should have a whitespace following it, as do await and void. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36146 llvm-svn: 309710
* clang-format: [JS] handle union types in arrow functions.Martin Probst2017-08-011-0/+1
| | | | | | | | | | | | Summary: clang-format would previously fail to detect that an arrow functions parameter block is not an expression, and thus insert whitespace around the `|` and `&` type operators in it. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36147 llvm-svn: 309707
OpenPOWER on IntegriCloud