summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] Correctly format JavaScript imports with long module pathsMartin Probst2017-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Currently the `UnwrappedLineParser` fails to correctly unwrap JavaScript imports where the module path is not on the same line as the `from` keyword. For example: import {A} from 'some/path/longer/than/column/limit/module.js';``` This causes issues when in the middle a list of imports because the formatter thinks it has reached the end of the imports, and therefore will not sort any imports lower in the list. The formatter will, however, split the `from` keyword and the module path if the path exceeds the column limit, which triggers the issue the next time the file is formatted. Patch originally by Jared Neil - thanks! Differential Revision: https://reviews.llvm.org/D34920 llvm-svn: 308306
* Fix dereference of pointers in throw statements.Manuel Klimek2017-07-171-1/+2
| | | | | | | | | | | | Before: throw * x; After: throw *x; Patch by Erik Uhlmann. llvm-svn: 308185
* [clang-format] Keep level of comment before an empty lineKrasimir Georgiev2017-07-121-4/+13
| | | | | | | | | | | | | | | | | Summary: This patch fixes bug https://bugs.llvm.org/show_bug.cgi?id=3313: a comment line was aligned with the next #ifdef even in the presence of an empty line between them. Reviewers: djasper, klimek Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35296 llvm-svn: 307795
* clang-format: [JS] do not wrap after "readonly".Martin Probst2017-07-072-7/+10
| | | | | | | | | | | | | | Summary: Breaks after "readonly" trigger automatic semicolon insertion in field declarations. Reviewers: krasimir, djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D35112 llvm-svn: 307394
* [clang-format] Add space between a message field key and the opening bracket ↵Krasimir Georgiev2017-07-061-0/+2
| | | | | | | | | | | | | | | | | | in proto messages Summary: This patch updates the formatting of message fields of type `a{...}` to `a {...}` for proto messages. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35015 llvm-svn: 307261
* [clang-format] Fix an uninitialized memory accessKrasimir Georgiev2017-07-051-7/+9
| | | | llvm-svn: 307147
* clang-format: [JS] space between pseudo keywords and template literals.Martin Probst2017-07-042-1/+25
| | | | | | | | | | | | | | | | | | | | Summary: Before: yield`foo`; After: yield `foo`; This reinstates commit 71d3b5cd91 / r307023 and fixes the logic by introducing an explicit table of JavaScript pseudo keywords. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34953 llvm-svn: 307087
* Revert "clang-format: [JS] space between pseudo keywords and template literals."Martin Probst2017-07-031-5/+1
| | | | | | This reverts commit 71d3b5cd916106005ef23467e3f6c7fbca7bc499. llvm-svn: 307034
* [clang-format] Support text proto messagesKrasimir Georgiev2017-07-035-29/+85
| | | | | | | | | | | | | | Summary: This patch adds support for textual protocol buffer messages. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek, mgorny Differential Revision: https://reviews.llvm.org/D34441 llvm-svn: 307029
* clang-format: [JS] space between pseudo keywords and template literals.Martin Probst2017-07-031-1/+5
| | | | | | | | | | | | | | | | | Summary: Before: yield`foo`; After: yield `foo`; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34938 llvm-svn: 307023
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding LLVM change is r306878. llvm-svn: 306881
* clang-format: add options to merge empty record bodyFrancois Ferrand2017-06-303-10/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces a few extra BraceWrapping options, similar to `SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g. class, struct, union and namespace): * SplitEmptyClass * SplitEmptyStruct * SplitEmptyUnion * SplitEmptyNamespace The `SplitEmptyFunction` option name has also been simplified/ shortened (from `SplitEmptyFunctionBody`). These options are helpful when the correspond AfterXXX option is enabled, to allow merging the empty record: class Foo {}; In addition, this fixes an unexpected merging of short records, when the AfterXXXX options are used, which caused to be formatted like this: class Foo { void Foo(); }; This is now properly formatted as: class Foo { void Foo(); }; Reviewers: djasper, krasimir Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34395 llvm-svn: 306874
* clang-format: Do not binpack initialization listsFrancois Ferrand2017-06-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch tries to avoid binpacking when initializing lists/arrays, to allow things like: static int types[] = { registerType1(), registerType2(), registerType3(), }; std::map<int, std::string> x = { { 0, "foo fjakfjaklf kljj" }, { 1, "bar fjakfjaklf kljj" }, { 2, "stuff fjakfjaklf kljj" }, }; This is similar to how dictionnaries are formatted, and actually corresponds to the same conditions: when initializing a container (and not just 'calling' a constructor). Such formatting involves 2 things: * Line breaks around the content of the block. This can be forced by adding a comma or comment after the last element * Elements should not be binpacked This patch considers the block is an initializer list if it either ends with a comma, or follows an assignment, which seems to provide a sensible approximation. Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: malcolm.parsons, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34238 llvm-svn: 306868
* [clang-format] Switch to case-insensitive header matching and use it toChandler Carruth2017-06-291-5/+7
| | | | | | | | | | | | | | | | | | | | | | | improve support for LLVM-style include sorting. This really is a collection of improvements to the rules for LLVM include sorting: - We have gmock headers now, so it adds support for those to one of the categories. - LLVM does use 'FooTest.cpp' files to test 'Foo.h' so it adds that suffix for finding a main header. - At times the test file's case may not match the header file's case, so switch to case-insensitive regex matching of header names. With this set of changes, I can't spot any misbehaviors when re-sorting all of LLVM's unittest '#include' lines. Thanks to Eric and Daniel for help testing and refining the patch during review! Differential Revision: https://reviews.llvm.org/D33932 llvm-svn: 306759
* [clang-format] Fix parsing of msg{field}-style proto optionsKrasimir Georgiev2017-06-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch makes the `{` in `msg_field{field: OK}` in a proto option scope be treated as an assignment operator. Previosly the added test case was formatted as: ``` option (MyProto.options) = { field_a: OK field_b{field_c: OK} field_d: OKOKOK field_e: OK } ``` Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34749 llvm-svn: 306672
* [clang-format] Fix a clang-tidy warning, NFCKrasimir Georgiev2017-06-271-1/+1
| | | | llvm-svn: 306409
* [clang-format] Fix a buildbot failure after r306406Krasimir Georgiev2017-06-271-1/+2
| | | | llvm-svn: 306408
* [clang-format] Support <>-style proto message fieldsKrasimir Georgiev2017-06-275-15/+52
| | | | | | | | | | | | | | | | | Summary: This patch adds support for <>-style proto message fields inside proto options. Previously these were wrongly treated as binary operators and as such were working only by chance for a limited number of cases. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34621 llvm-svn: 306406
* [clang-format] Add a SortUsingDeclaration option and enable it by defaultKrasimir Georgiev2017-06-231-26/+44
| | | | | | | | | | | | | | | | Summary: This patch adds a `SortUsingDeclaration` style option and enables it for llvm style. Reviewers: klimek Reviewed By: klimek Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34453 llvm-svn: 306094
* clang-format: introduce InlineOnly short function styleFrancois Ferrand2017-06-213-3/+4
| | | | | | | | | | | | | | | | | | | Summary: This is the same as Inline, except it does not imply all empty functions are merged: with this style, empty functions are merged only if they also match the 'inline' criteria (i.e. defined in a class). This is helpful to avoid inlining functions in implementations files. Reviewers: djasper, krasimir Reviewed By: djasper Subscribers: klimek, rengolin, cfe-commits Differential Revision: https://reviews.llvm.org/D34399 llvm-svn: 305912
* [clang-format] Support sorting using declarationsKrasimir Georgiev2017-06-214-0/+193
| | | | | | | | | | | | | | | | Summary: This patch adds UsingDeclarationsSorter, a TokenAnalyzer that sorts consecutive using declarations. Reviewers: klimek Reviewed By: klimek Subscribers: Typz, djasper, cfe-commits, klimek, mgorny Differential Revision: https://reviews.llvm.org/D33823 llvm-svn: 305901
* clang-format: Fix C99 designated initializers corner casesFrancois Ferrand2017-06-193-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes the missing space before the designated initializer when `Cpp11BracedListStyle=false` : const struct A a = { .a = 1, .b = 2 }; ^ Also, wrapping between opening brace and designated array initializers used to have an excessive penalty (like breaking between an expression and the subscript operator), leading to unexpected wrapping: const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = {[1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa, [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb}; instead of: const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = { [1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa, [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb}; Finally, designated array initializers are not binpacked, just like designated member initializers. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, krasimir, klimek Differential Revision: https://reviews.llvm.org/D33491 llvm-svn: 305696
* clang-format: Improve understanding of combined typedef+record declarationsDaniel Jasper2017-06-191-2/+5
| | | | | | | | | | Fixes an issue where struct A { int X; }; would be broken onto multiple lines, but typedef struct A { int X; } A2; was collapsed onto a single line. Patch by Jacob Bandes-Storch. Thank you. llvm-svn: 305667
* clang-format: Handle "if constexpr".Daniel Jasper2017-06-193-2/+10
| | | | | | | | | | | | | | | | | | | | c++1z adds the following constructions to the language: if constexpr (cond) statement1; else if constexpr (cond) statement2; else if constexpr (cond) statement3; else statement4; A first version of this was proposed in reviews.llvm.org/D26953 by Francis Visoiu Mistrih, but never commited. This patch additionally fixes the behavior when allowing short if statements on a single line and was authored by Jacob Bandes-Storch. Thank you to both authors. llvm-svn: 305666
* clang-format: Add CompactNamespaces optionFrancois Ferrand2017-06-144-23/+123
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add CompactNamespaces option, to pack namespace declarations on the same line (somewhat similar to C++17 nested namespace definition). With this option, consecutive namespace declarations are kept on the same line: namespace foo { namespace bar { ... }} // namespace foo::bar Reviewers: krasimir, djasper, klimek Reviewed By: djasper Subscribers: kimgr, cfe-commits, klimek Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D32480 llvm-svn: 305384
* [clang-format] Document the StartOfTokenColumn parameter, NFCKrasimir Georgiev2017-06-131-0/+4
| | | | llvm-svn: 305293
* clang-format: add option to merge empty function bodyFrancois Ferrand2017-06-132-4/+15
| | | | | | | | | | | | | | | | | | | | Summary: This option supplements the AllowShortFunctionsOnASingleLine flag, to merge empty function body at the beginning of the line: e.g. when the function is not short-enough and breaking braces after function. int f() {} Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33447 llvm-svn: 305272
* [clang-format] Fix alignment of preprocessor trailing commentsKrasimir Georgiev2017-06-071-8/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is a follow-up of https://reviews.llvm.org/rL304687, which fixed an overflow in the comment alignment code in clang-format. The token length of trailing comments of preprocessor directives is calculated incorrectly by including the text between consecutive directives. That causes them to not being aligned. For example, in this code with column limit 20 ``` #if A #else // A int iiii; #endif // B ``` the length of the token `// A` was wrongly calculated as 14 = 5 (the size of `// A\n`) plus 9 (the size of `int iiii;`) and so `// A` wouldn't be aligned with `// B` and this was produced: ``` #if A #else // A int iiii; #endif // B ``` This patch fixes this case. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33982 llvm-svn: 304912
* clang-format: [JS] recognize exported type definitions.Martin Probst2017-06-071-3/+9
| | | | | | | | | | Summary: Support "export type T = {...};", in addition to just "type T = {...};". Reviewers: klimek Differential Revision: https://reviews.llvm.org/D33980 llvm-svn: 304904
* clang-format: [JS] Correctly Indent Nested JavaScript Literals.Martin Probst2017-06-061-2/+2
| | | | | | | | | | | | | | | | | Nested literals are sometimes only indented by 2 spaces, instead of respecting the IndentWidth option. There are existing unit tests (FormatTestJS.ArrayLiterals) that only pass because the style used to test them uses an IndentWidth of 2. This change removes the magic 2 and always uses the IndentWidth. I've added 6 tests. The first 4 of these tests fail before this change, while the last 2 already pass, but were added just to make sure it the change works with all types of braces. Patch originally by Jared Neil, thanks! Differential Revision: https://reviews.llvm.org/D33857 llvm-svn: 304791
* [clang-format] Don't align too long broken trailing commentsKrasimir Georgiev2017-06-041-2/+4
| | | | | | | | | | | | | | | | | | Summary: This patch fixes a bug where clang-format will align newly broken trailing comments even if this will make them exceed the line limit. The bug was caused by a combination of unsigned arithmetic overflow and an imprecise computation of the length of broken comment lines. Reviewers: djasper, alexfh Reviewed By: alexfh Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33830 llvm-svn: 304687
* clang-format: [JS] improve calculateBraceType heuristicMartin Probst2017-05-311-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: calculateBraceTypes decides for braced init for empty brace pairs ({}). In context of a function declaration, this incorrectly classifies empty function or method bodies as braced inits, leading to missing wraps: class C { foo() {}[bar]() {} } Where code should have wrapped after "}", before "[". This change adds another piece of contextual information in that braces following closing parentheses must always be the opening braces of function blocks. This fixes brace detection for methods immediately followed by brackets (computed property declarations), but also curlies. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33714 llvm-svn: 304290
* clang-format: [JS] do not clean up duplicated commas.Martin Probst2017-05-291-0/+3
| | | | | | | | | | | | | | | | Summary: In JavaScript, duplicated commas have semantic meaning. x = [a,,b]; The statement above creates an array with three entries, the middle being undefined. Because clang-format should not change semantics, disable this cleanup in JS. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33641 llvm-svn: 304141
* clang-format: [JS] fix indenting bound functions.Martin Probst2017-05-291-2/+13
| | | | | | | | | | | | | | | | Summary: The previous fix to force build style wrapping if the previous token is a closing parenthesis broke a peculiar pattern where users parenthesize the function declaration in a bind call: fn((function() { ... }).bind(this)); This restores the previous behaviour by reverting that change, but narrowing the special case for unindenting closing parentheses to those followed by semicolons and opening braces, i.e. immediate calls and function declarations. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33640 llvm-svn: 304135
* clang-format: Introduce BreakConstructorInitializers optionFrancois Ferrand2017-05-243-20/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This option replaces the BreakConstructorInitializersBeforeComma option with an enum, thus introducing a mode where the colon stays on the same line as constructor declaration: // When it fits on line: Constructor() : initializer1(), initializer2() {} // When it does not fit: Constructor() : initializer1(), initializer2() {} // When ConstructorInitializerAllOnOneLineOrOnePerLine = true: Constructor() : initializer1(), initializer2() {} Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32479 llvm-svn: 303739
* clang-format: [JS] avoid line breaks before unindented r_parens.Martin Probst2017-05-222-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change that enabled wrapping at the previous scope's indentation had unintended side-effects in that clang-format would prefer to wrap closing parentheses to the next line if it avoided a wrap on the next line (assuming very narrow lines): fooObject .someCall(barbazbam) .then(bam); Would get formatted as: fooObject.someCall(barbazbam ).then(bam); Because the ')' is now indented at the parent level (fooObject). Normally formatting a builder pattern style call sequence like that is outlawed in clang-format anyway. However for JavaScript this is special cased to support trailing .bind calls. This change disallows this special case when following a closing ')' to avoid the problem. Included are some random comment fixes. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33399 llvm-svn: 303557
* clang-format: do not reflow bullet listsFrancois Ferrand2017-05-221-2/+19
| | | | | | | | | | | | | | | | | | | Summary: This patch prevents reflowing bullet lists in block comments. It handles all lists supported by doxygen and markdown, e.g. bullet lists starting with '-', '*', '+', as well as numbered lists starting with -# or a number followed by a dot. Reviewers: krasimir Reviewed By: krasimir Subscribers: djasper, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33285 llvm-svn: 303556
* [clang-format] Keep trailing preprocessor line comments separate from the ↵Krasimir Georgiev2017-05-221-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | following section comments Summary: r303415 changed the way a sequence of line comments following a preprocessor macro is handled, which has the unfortunate effect of aligning a trailing preprocessor line comment and following unrelated section comments, so: ``` #ifdef A // comment about A // section comment #endif ``` gets turned into: ``` #ifdef A // comment about A // section comment #endif ``` This patch fixes this by additionally checking the original start columns of the line comments. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33394 llvm-svn: 303541
* clang-format: Allow customizing the penalty for breaking assignmentFrancois Ferrand2017-05-222-3/+7
| | | | | | | | | | | | | | | | | | | | | Summary: Add option to customize the penalty for breaking assignment This allows increasing the priority of the assignment, to prefer spliting an operation instead of splitting the assignment, e.g. : int a = bbbbbbbbbbbbbbbb + cccccccccccccccc; Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32477 llvm-svn: 303534
* [Format] Add curly braces to suppress a -Wmisleading-indentation warning ↵Craig Topper2017-05-211-1/+2
| | | | | | from gcc. llvm-svn: 303501
* [clang-format] Handle trailing comment sections in import statement linesKrasimir Georgiev2017-05-193-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch updates the handling of multiline trailing comment sections in import statement lines to make it more consistent with the case in general. This includes updating the parsing logic to collect the trailing comment sections and the formatting logic to not insert escaped newlines at the end of comment lines in import statement lines. Specifically, before this patch this code: ``` #include <a> // line 1 // line 2 ``` will be turned into two unwrapped lines, whereas this code: ``` int i; // line 1 // line 2 ``` is turned into a single unwrapped line, enabling reflowing across comments. An example where the old behaviour is bad is when partially formatting the lines 3 to 4 of this code: ``` #include <a> // line 1 // line 2 int i; ``` which gets turned into: ``` #include <a> // line 1 // line 2 int i; ``` because the two comment lines were independent and the indent was copied. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33351 llvm-svn: 303415
* clang-format: [JS] for await, and fix a crash with for loops.Martin Probst2017-05-182-6/+6
| | | | | | | | | | | | | | Summary: The syntax is actually `for await (const x of y)` (d'oh). This also fixes a crash for `for` tokens not followed by additional tokens. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33329 llvm-svn: 303382
* [clang-format] Fix MatchingOpeningBlockLineIndex computationKrasimir Georgiev2017-05-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: Computed line index must be relative to the current 'parent' node, and thus use CurrentLines instead of Lines. Without this, a child line's MatchingOpeningBlockLineIndex is out of range of the parent's list of line, which can cause crash or unexpected behavior if this field is used in childs. Contributed by @Typz! Reviewers: krasimir, djasper Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32524 llvm-svn: 303353
* [clang-format] Make NoLineBreakFormatter respect MustBreakBeforeKrasimir Georgiev2017-05-182-17/+21
| | | | | | | | | | | | | | | | Summary: This patch makes NoLineBreakFormatter to insert a break before tokens where MustBreakBefore is true. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33238 llvm-svn: 303332
* clang-format: fix prefix for doxygen comments after memberKrasimir Georgiev2017-05-181-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Doxygen supports putting documentation blocks after member, by adding an additional < marker in the comment block. This patch makes sure this marker is used in lines which are introduced by breaking the comment. int foo; ///< Some very long comment. becomes: int foo; ///< Some very long ///< comment. Contributed by @Typz! Reviewers: krasimir Reviewed By: krasimir Subscribers: djasper, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33282 llvm-svn: 303330
* clang-format: [JS] for async loops.Martin Probst2017-05-152-3/+14
| | | | | | | | | | | | | | | Summary: JavaScript supports asynchronous loop iteration in async functions: for async (const x of y) ... Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33193 llvm-svn: 303106
* JavaScript allows parameter lists to include trailing commas:Martin Probst2017-05-152-6/+22
| | | | | | | | | | | | | | | | | | | myFunction(param1, param2,); For symmetry with other parenthesized lists ([...], {...}), clang-format should wrap parenthesized lists one-per-line if they contain a trailing comma: myFunction( param1, param2, ); This is particularly useful in function declarations or calls with many arguments, e.g. commonly in constructors. Differential Revision: https://reviews.llvm.org/D33023 llvm-svn: 303049
* clang-format: [JS] fix non-null assertion operator recognition.Martin Probst2017-05-151-3/+3
| | | | | | | | | | | | | | | | | Summary: `getIdentifierInfo()` includes all keywords, whereas non-null assertion operators should only be recognized after non-keywords or pseudo keywords. Ideally this should list all tokens that clang-format recognizes as a keyword, but that are pseudo or no keywords in JS. For the time being, just recognize the specific bits users ran into (`namespace` in this case). Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33182 llvm-svn: 303038
* clang-format: [JS] support non-null assertions after all identifiers.Martin Probst2017-05-121-1/+2
| | | | | | | | | | | | | | | | | Summary: Previously: x = namespace !; Now: x = namespace!; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33113 llvm-svn: 302893
* clang-format: refine calculating brace types.Martin Probst2017-05-101-1/+2
| | | | | | | | | | | | | | | | | | Summary: For C++ code, opening parenthesis following a } indicate a braced init. For JavaScript and other languages, this is an invalid syntactical construct, unless the closing parenthesis belongs to a function - in which situation its a BK_Block. This fixes indenting IIFEs following top level functions: function foo() {} (function() { codeHere(); }()); clang-format used to collapse these lines together. Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33006 llvm-svn: 302658
OpenPOWER on IntegriCloud