summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format clang-format.Manuel Klimek2017-09-2014-286/+264
| | | | llvm-svn: 313744
* Fix clang-format's detection of structured bindings.Manuel Klimek2017-09-204-23/+22
| | | | | | | | | | | | | | | | | | | 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
* Fix formatting of lambda introducers with initializers.Manuel Klimek2017-09-192-54/+16
| | | | | | | | | | | | | | | | | | | | | Most of the work was already done when we introduced a look-behind based lambda introducer detection. This patch finishes the transition by completely relying on the simple lambda introducer detection and simply recursing into normal brace-parsing code to parse until the end of the introducer. This fixes initializers in lambdas, including nested lambdas. Before: auto a = [b = [c = 42]{}]{}; auto b = [c = &i + 23]{}; After: auto a = [b = [c = 42] {}] {}; auto b = [c = &i + 23] {}; llvm-svn: 313622
* [clang-format] New flag - BraceWrapping.AfterExternBlockKrasimir Georgiev2017-09-153-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **"extern C part"** **Problem:** Due to the lack of "brace wrapping extern" flag, clang format does parse the block after **extern** keyword moving the opening bracket to the header line always! **Patch description:** A new style added, new configuration flag - **BraceWrapping.AfterExternBlock** that allows us to decide whether we want a break before brace or not. Reviewers: djasper, krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37845 Contributed by @PriMee! llvm-svn: 313354
* SplitEmptyFunction should be true in the Mozilla coding styleSylvestre Ledru2017-09-131-1/+1
| | | | | | | | | | | | | | | | Summary: As defined here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes See for the downstream bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1399359 Reviewers: Typz, djasper Reviewed By: Typz Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37795 llvm-svn: 313182
* 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] Fixed one-line if statementKrasimir Georgiev2017-09-111-42/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: **Short overview:** Fixed bug: https://bugs.llvm.org/show_bug.cgi?id=34001 Clang-format bug resulting in a strange behavior of control statements short blocks. Different flags combinations do not guarantee expected result. Turned on option AllowShortBlocksOnASingleLine does not work as intended. **Description of the problem:** Cpp source file UnwrappedLineFormatter does not handle AllowShortBlocksOnASingleLine flag as it should. Putting a single-line control statement without any braces, clang-format works as expected (depending on AllowShortIfStatementOnASingleLine or AllowShortLoopsOnASingleLine value). Putting a single-line control statement in braces, we can observe strange and incorrect behavior. Our short block is intercepted by tryFitMultipleLinesInOne function. The function returns a number of lines to be merged. Unfortunately, our control statement block is not covered properly. There are several if-return statements, but none of them handles our block. A block is identified by the line first token and by left and right braces. A function block works as expected, there is such an if-return statement doing proper job. A control statement block, from the other hand, falls into strange conditional construct, which depends on BraceWrapping.AfterFunction flag (with condition that the line’s last token is left brace, what is possible in our case) or goes even further. That should definitely not happen. **Description of the patch:** By adding three different if statements, we guarantee that our short control statement block, however it looks like (different brace wrapping flags may be turned on), is handled properly and does not fall into wrong conditional construct. Depending on appropriate options we return either 0 (when something disturbs our merging attempt) or let another function (tryMergeSimpleBlock) take the responsibility of returned result (number of merged lines). Nevertheless, one more correction is required in mentioned tryMergeSimpleBlock function. The function, previously, returned either 0 or 2. The problem was that this did not handle the case when our block had the left brace in a separate line, not the header one. After change, after adding condition, we return the result compatible with block’s structure. In case of left brace in the header’s line we do everything as before the patch. In case of left brace in a separate line we do the job similar to the one we do in case of a “non-header left brace” function short block. To be precise, we try to merge the block ignoring the header line. Then, if success, we increment our returned result. **After fix:** **CONFIG:** ``` AllowShortBlocksOnASingleLine: true AllowShortIfStatementsOnASingleLine: true BreakBeforeBraces: Custom BraceWrapping: { AfterClass: true, AfterControlStatement: true, AfterEnum: true, AfterFunction: true, AfterNamespace: false, AfterStruct: true, AfterUnion: true, BeforeCatch: true, BeforeElse: true } ``` **BEFORE:** ``` if (statement) doSomething(); if (statement) { doSomething(); } if (statement) { doSomething(); } if (statement) { doSomething(); } if (statement) doSomething(); if (statement) { doSomething1(); doSomething2(); } ``` **AFTER:** ``` if (statement) doSomething(); if (statement) { doSomething(); } if (statement) { doSomething(); } if (statement) { doSomething(); } if (statement) doSomething(); if (statement) { doSomething1(); doSomething2(); } ``` Contributed by @PriMee! Reviewers: krasimir, djasper Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37140 llvm-svn: 312904
* Recommit "Add _Float16 as a C/C++ source language type"Sjoerd Meijer2017-09-081-0/+1
| | | | | | | | This is a recommit of r312781; in some build configurations variable names are omitted, so changed the new regression test accordingly. llvm-svn: 312794
* Revert "Add _Float16 as a C/C++ source language type"Sjoerd Meijer2017-09-081-1/+0
| | | | | | | The clang-with-lto-ubuntu bot didn't like the new regression test, revert while I investigate the issue. llvm-svn: 312784
* Add _Float16 as a C/C++ source language typeSjoerd Meijer2017-09-081-0/+1
| | | | | | | | | | | This adds _Float16 as a source language type, which is a 16-bit floating point type defined in C11 extension ISO/IEC TS 18661-3. In follow up patches documentation and more tests will be added. Differential Revision: https://reviews.llvm.org/D33719 llvm-svn: 312781
* [clang-format] Add support for C++17 structured bindings.Marek Kurdej2017-09-072-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 indentation of macros in include guards (after r312125).Daniel Jasper2017-09-041-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Before: #ifndef A_H #define A_H #define A() \ int i; \ int j; #endif // A_H After: #ifndef A_H #define A_H #define A() \ int i; \ int j; #endif // A_H llvm-svn: 312484
* 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: Add preprocessor directive indentationKrasimir Georgiev2017-08-305-4/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is an implementation for [bug 17362](https://bugs.llvm.org/attachment.cgi?bugid=17362) which adds support for indenting preprocessor statements inside if/ifdef/endif. This takes previous work from fmauch (https://github.com/fmauch/clang/tree/preprocessor_indent) and makes it into a full feature. The context of this patch is that I'm a VMware intern, and I implemented this because VMware needs the feature. As such, some decisions were made based on what VMware wants, and I would appreciate suggestions on expanding this if necessary to use-cases other people may want. This adds a new enum config option, `IndentPPDirectives`. Values are: * `PPDIS_None` (in config: `None`): ``` #if FOO #if BAR #include <foo> #endif #endif ``` * `PPDIS_AfterHash` (in config: `AfterHash`): ``` #if FOO # if BAR # include <foo> # endif #endif ``` This is meant to work whether spaces or tabs are used for indentation. Preprocessor indentation is independent of indentation for non-preprocessor lines. Preprocessor indentation also attempts to ignore include guards with the checks: 1. Include guards cover the entire file 2. Include guards don't have `#else` 3. Include guards begin with ``` #ifndef <var> #define <var> ``` This patch allows `UnwrappedLineParser::PPBranchLevel` to be decremented to -1 (the initial value is -1) so the variable can be used for indent tracking. Defects: * This patch does not handle the case where there's code between the `#ifndef` and `#define` but all other conditions hold. This is because when the #define line is parsed, `UnwrappedLineParser::Lines` doesn't hold the previous code line yet, so we can't detect it. This is out of the scope of this patch. * This patch does not handle cases where legitimate lines may be outside an include guard. Examples are `#pragma once` and `#pragma GCC diagnostic`, or anything else that does not change the meaning of the file if it's included multiple times. * This does not detect when there is a single non-preprocessor line in front of an include-guard-like structure where other conditions hold because `ScopedLineState` hides the line. * Preprocessor indentation throws off `TokenAnnotator::setCommentLineLevels` so the indentation of comments immediately before indented preprocessor lines is toggled on each run. Fixing this issue appears to be a major change and too much complexity for this patch. Contributed by @euhlmann! Reviewers: djasper, klimek, krasimir Reviewed By: djasper, krasimir Subscribers: krasimir, mzeren-vmw, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D35955 llvm-svn: 312125
* [clang-format] Refactor likely xml a bit, NFCKrasimir Georgiev2017-08-291-6/+8
| | | | llvm-svn: 312000
* [clang-format] Do not format likely xmlKrasimir Georgiev2017-08-291-3/+9
| | | | | | | | | | | | | | | | | Summary: This patch detects the leading '<' in likely xml files and stops formatting in that case. A recent use of a Qt xml file with a .ts extension triggered this: http://doc.qt.io/qt-4.8/linguist-ts-file-format.html Reviewers: djasper Reviewed By: djasper Subscribers: sammccall, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37136 llvm-svn: 311999
* [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] simplify template string wrapping.Martin Probst2017-08-291-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would try to wrap template string substitutions by indenting relative to the openening `${`. This helped with indenting structured strings, such as strings containing HTML, as the substitutions would be aligned according to the structure of the string. However it turns out that the overwhelming majority of template string + substitution usages are for substitutions into non-structured strings, e.g. URLs or just plain messages. For these situations, clang-format would often produce very ugly indents, in particular for strings containing no line breaks: return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${ row },${ col }): `; This change makes clang-format indent template string substitutions as if they were string concatenation operations. It wraps +4 on overlong lines and keeps all operands on the same line: return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${ row},${col}): `; While this breaks some lexical continuity between the `${` and `row}` here, the overall effects are still a huge improvement, and users can still manually break the string using `+` if desired. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37142 llvm-svn: 311988
* [Format] Invert nestingAndIndentLevel pair in WhitespaceManager used forDaniel Jasper2017-08-252-12/+11
| | | | | | | | | | | | | alignments Indent should be compared before nesting level to determine if a token is on the same scope as the one we align with. Because it was inverted, clang-format sometimes tried to align tokens with tokens from outer scopes, causing the assert(Shift >= 0) to fire. This fixes bug #33507. Patch by Beren Minor, thank you! llvm-svn: 311792
* [clang-format] Emit absolute splits before lines for comments, try 2Krasimir Georgiev2017-08-241-12/+10
| | | | | | | | | | | | | | | | Summary: This recommits https://reviews.llvm.org/D36956 with an update to the added test case to not use raw string literals, since this makes gcc unhappy. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37109 llvm-svn: 311672
* Revert "[clang-format] Break non-trailing block comments"Krasimir Georgiev2017-08-241-1/+1
| | | | | | | | This reverts commit r311457. It reveals some dormant bugs in comment reflowing, like breaking a single line jsdoc type annotation before a parameter into multiple lines. llvm-svn: 311641
* Revert "[clang-format] Emit absolute splits before lines for comments"Krasimir Georgiev2017-08-231-10/+12
| | | | | | | | This reverts commit r311559, which added a test containing raw string literals in macros, which chokes gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55971 llvm-svn: 311566
* [clang-format] Emit absolute splits before lines for commentsKrasimir Georgiev2017-08-231-12/+10
| | | | | | | | | | | | | | | | | | | Summary: This patch makes the splits emitted for the beginning of comment lines during reformatting absolute. Previously, they were relative to the start of the non-whitespace content of the line, which messes up further TailOffset calculations in breakProtrudingToken. This fixes an assertion failure reported in bug 34236: https://bugs.llvm.org/show_bug.cgi?id=34236. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36956 llvm-svn: 311559
* [clang-format] Align trailing comments if ColumnLimit is 0Krasimir Georgiev2017-08-231-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: ColumnLimit = 0 means no limit, so comment should always be aligned if requested. This was broken with https://llvm.org/svn/llvm-project/cfe/trunk@304687 introduced via https://reviews.llvm.org/D33830 and is included in 5.0.0-rc2. This commit fixes it and adds a unittest for this property. Should go into clang-5.0 IMHO. Contributed by @pboettch! Reviewers: djasper, krasimir Reviewed By: djasper, krasimir Subscribers: hans, klimek Differential Revision: https://reviews.llvm.org/D36967 llvm-svn: 311532
* [clang-format] Break non-trailing block commentsKrasimir Georgiev2017-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is an alternative to https://reviews.llvm.org/D36614, by resolving a non-idempotency issue by breaking non-trailing comments: Consider formatting the following code with column limit at `V`: ``` V const /* comment comment */ A = B; ``` The comment is not a trailing comment, breaking before it doesn't bring it under the column limit. The formatter breaks after it, resulting in: ``` V const /* comment comment */ A = B; ``` For a next reformat, the formatter considers the comment as a trailing comment, so it is free to break it further, resulting in: ``` V const /* comment comment */ A = B; ``` This patch improves the situation by directly producing the third case. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37007 llvm-svn: 311457
* 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: Fix bug with ENAS_DontAlign and empty linesJacob Bandes-Storch2017-08-102-12/+14
| | | | | | | | This fixes a bug in `ENAS_DontAlign` (introduced in D32733) where blank lines had an EscapedNewlineColumn of 0, causing a subtraction to overflow when converted back to unsigned and leading to runaway memory allocation. Differential Revision: https://reviews.llvm.org/D36019 llvm-svn: 310539
* clang-format: [JS] detect ASI after closing parens.Martin Probst2017-08-091-1/+2
| | | | | | | | | | | | Summary: A closing parenthesis followed by a declaration or statement should always terminate the current statement. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36491 llvm-svn: 310482
* [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment ↵Krasimir Georgiev2017-08-093-12/+18
| | | | | | | | | | | | | | | | | | pragmas Summary: This handles a case where the trailing '*/' of a multiline jsdoc eding in a comment pragma wouldn't be put on a new line. Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D36359 llvm-svn: 310458
* 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] handle single lines comments ending in `\\`.Martin Probst2017-08-081-0/+28
| | | | | | | | | | | | | | Summary: Previously, clang-format would consider the following code line to be part of the comment and incorrectly format the rest of the file. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36159 llvm-svn: 310365
* clang-format: [JS] support fields with case/switch/default labels.Martin Probst2017-08-041-0/+14
| | | | | | | | | | | | | | | | | | | | | Summary: `case:` and `default:` would normally parse as labels for a `switch` block. However in TypeScript, they can be used in field declarations, e.g.: interface I { case: string; } This change special cases parsing them in declaration lines to avoid wrapping them. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36148 llvm-svn: 310070
* [clang-format] Fix indent of 'key <...>' and 'key {...}' in text protosKrasimir Georgiev2017-08-031-1/+4
| | | | | | | | | | | | | | | | | Summary: This patch fixes the indentation of the code pattern `key <...>`and `key {...}` in text protos. Previously, such line would be alinged depending on the column of the previous colon, which usually indents too much. I'm gonna go ahead and commit this since it's a straightforward bugfix. Reviewers: djasper, klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36143 llvm-svn: 309941
* [clang-format] Fix parsing of <>-style proto optionsKrasimir Georgiev2017-08-031-0/+9
| | | | | | | | | | | | | | | | | Summary: This patch fixes the parsing of proto option fields like `option op = <...>`. Previously the parser did not enter the right code path inside the angle braces, causing the contents to be split into several unwrapped lines inside. I'll just go ahead and commit this since it's a straightforward bugfix. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36217 llvm-svn: 309937
* clang-format: [JS] no whitespace between typeof operator and l_paren.Martin Probst2017-08-012-2/+4
| | | | 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
* clang-format: [JS] consistenly format enums.Martin Probst2017-08-011-1/+3
| | | | | | | | | | | | Summary: Previously, const enums would get formatted differently because the modifier was not recognized. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36144 llvm-svn: 309703
* clang-format: [JS] support default imports.Martin Probst2017-08-011-2/+2
| | | | | | | | | | | | Summary: Formerly, `import {default as X} from y;` would not be recognized as an import. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36132 llvm-svn: 309697
* clang-format: [JS] handle object types in extends positions.Martin Probst2017-08-012-1/+13
| | | | | | | | | | | | | | | | | Summary: clang-format would previously drop the whitespace after `extends` in code such as: class Foo extends {} {} Where the first set of curly braces is an inline object literal type. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36131 llvm-svn: 309695
* clang-format: merge short case labels with trailing commentsFrancois Ferrand2017-07-281-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Allow merging short case labels when they actually end with a comment (like a comment after the ``break``) and when followed by switch-level comments (e.g. aligned with next case): switch(a) { case 0: break; // comment at end of case case 1: return value; // comment related to next case // comment related to next case case 2: } Reviewers: krasimir, djasper Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35557 llvm-svn: 309370
* clang-format: fix block OpeningLineIndex around preprocessorFrancois Ferrand2017-07-282-14/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The current code would return an incorrect value when a preprocessor directive is present immediately after the opening brace: this causes the nanespace end comment fixer to break in some places, for exemple it would not add the comment in this case: namespace a { #define FOO } Fixing the computation is simple enough, but it was breaking a feature, as it would cause comments to be added also when the namespace declaration was dependant on conditional compilation. To fix this, a hash of the current preprocessor stack/branches is computed at the beginning of parseBlock(), so that we explicitely do not store the OpeningLineIndex when the beginning and end of the block are not in the same preprocessor conditions. Tthe hash is computed based on the line, but this could propbably be improved by using the actual condition, so that clang-format would be able to match multiple identical #ifdef blocks. Reviewers: krasimir, djasper Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35483 llvm-svn: 309369
* [clang-format] Reorder assignments, NFCKrasimir Georgiev2017-07-241-1/+1
| | | | llvm-svn: 308918
* [clang-format] Fix comment levels between '} else {' and PPDirective.Krasimir Georgiev2017-07-243-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a regression exposed by r307795 and rL308725 in which the level of a comment line between '} else {' and a preprocessor directive is incorrectly set as the level of the '} else {' line. For example, this : ``` int f(int i) { if (i) { ++i; } else { // comment #ifdef A --i; #endif } } ``` was formatted as: ``` int f(int i) { if (i) { ++i; } else { // comment #ifdef A --i; #endif } } ``` Reviewers: djasper, klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35794 llvm-svn: 308882
* [clang-format] Fix comment levels between '}' and PPDirectiveKrasimir Georgiev2017-07-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a regression exposed by r307795 in which the level of a comment line between '}' and a preprocessor directive is incorrectly set as the level of the line before the '}'. In effect, this: ``` int f(int i) { int j = i; return i + j; } // comment #ifdef A #endif ``` was formatted as: ``` int f(int i) { int j = i; return i + j; } // comment #ifdef A #endif ``` Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D35485 llvm-svn: 308725
* [clang-format] Put '/**' and '*/' on own lines in multiline jsdocsKrasimir Georgiev2017-07-203-3/+103
| | | | | | | | | | | | Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D35683 llvm-svn: 308684
OpenPOWER on IntegriCloud