summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "clang-format: [JS] space between pseudo keywords and template literals."Martin Probst2017-07-031-1/+0
| | | | | | This reverts commit 71d3b5cd916106005ef23467e3f6c7fbca7bc499. llvm-svn: 307034
* [clang-format] Support text proto messagesKrasimir Georgiev2017-07-032-0/+252
| | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | | | Summary: Before: yield`foo`; After: yield `foo`; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34938 llvm-svn: 307023
* clang-format: add options to merge empty record bodyFrancois Ferrand2017-06-301-3/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-302-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+23
| | | | | | | | | | | | | | | | | | | | | | | 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-0/+13
| | | | | | | | | | | | | | | | | | | | | | | 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] Support <>-style proto message fieldsKrasimir Georgiev2017-06-271-0/+136
| | | | | | | | | | | | | | | | | 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 test for associative map proto buffer fieldsKrasimir Georgiev2017-06-271-0/+23
| | | | | | | | | | | | | | | | Summary: The test suite was missing a test about associative maps: https://developers.google.com/protocol-buffers/docs/proto3#maps Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34623 llvm-svn: 306386
* [clang-format] Add a SortUsingDeclaration option and enable it by defaultKrasimir Georgiev2017-06-231-0/+8
| | | | | | | | | | | | | | | | 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-211-0/+46
| | | | | | | | | | | | | | | | | | | 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-212-0/+235
| | | | | | | | | | | | | | | | 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-191-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+8
| | | | | | | | | | 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-191-0/+68
| | | | | | | | | | | | | | | | | | | | 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-142-0/+192
| | | | | | | | | | | | | | | | | | | | | | | | | 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: add option to merge empty function bodyFrancois Ferrand2017-06-131-0/+125
| | | | | | | | | | | | | | | | | | | | 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-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+6
| | | | | | | | | | 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-0/+39
| | | | | | | | | | | | | | | | | 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-0/+9
| | | | | | | | | | | | | | | | | | 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-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+11
| | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | 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] Remove unused using directive, NFCKrasimir Georgiev2017-05-241-1/+0
| | | | llvm-svn: 303742
* clang-format: Introduce BreakConstructorInitializers optionFrancois Ferrand2017-05-241-7/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+65
| | | | | | | | | | | | | | | | | | | 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-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-221-0/+14
| | | | | | | | | | | | | | | | | | | | | 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
* [clang-format] Handle trailing comment sections in import statement linesKrasimir Georgiev2017-05-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-181-3/+2
| | | | | | | | | | | | | | 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 prefix for doxygen comments after memberKrasimir Georgiev2017-05-181-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-151-0/+9
| | | | | | | | | | | | | | | 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/+30
| | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | | | 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-0/+10
| | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Don't indent JavaScript IIFEs.Martin Probst2017-05-091-0/+19
| | | | | | | | | | | | | | | | Because IIFEs[1] are often used like an anonymous namespace around large sections of JavaScript code, it's useful not to indent to them (which effectively reduces the column limit by the indent amount needlessly). It's also common for developers to wrap these around entire files or libraries. When adopting clang-format, changing the indent entire file can reduce the usefulness of the blame annotations. Patch by danbeam, thanks! Differential Revision: https://reviews.llvm.org/D32989 llvm-svn: 302580
* clang-format: [JS] keep triple slash directives intact.Martin Probst2017-05-091-0/+1
| | | | | | | | | | | | | | | | | | | Summary: TypeScript uses triple slash directives of the form: /// <reference path="..."/> For various non-source instructions that should not be wrapped. Reference: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32997 llvm-svn: 302523
* [clang-format] Convert AlignEscapedNewlinesLeft to an enum, addingDaniel Jasper2017-05-082-10/+36
| | | | | | | | | | | | | | | | | | | | DontAlign This converts the clang-format option AlignEscapedNewlinesLeft from a boolean to an enum, named AlignEscapedNewlines, with options Left (prev. true), Right (prev. false), and a new option DontAlign. When set to DontAlign, the backslashes are placed just after the last token in each line: #define EXAMPLE \ do { \ int x = aaaaa; \ int b; \ int dddddddddd; \ } while (0) Patch by jtbandes. Thank you! llvm-svn: 302428
* [clang-format] Don’t propagate AvoidBinPacking into argumentDaniel Jasper2017-05-081-0/+54
| | | | | | | | | | | | subexpressions This is an attempt to fix the issue described in a recent email: http://lists.llvm.org/pipermail/cfe-dev/2017-April/053632.html Patch by jtbandes. Thank you! Review: https://reviews.llvm.org/D32475 llvm-svn: 302427
* clang-format: [JS] exponentiation operatorMartin Probst2017-05-041-0/+6
| | | | | | | | | | | | Summary: While its precedence should be higher than multiplicative, LLVM does not have a level for that, so for the time being just treat it as multiplicative. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32864 llvm-svn: 302156
* clang-format: [JS] parse async function declarations.Martin Probst2017-04-271-0/+17
| | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrapped line for async functions, causing subsequent functions to run into the function: async function f() { x(); } function g() { ... With this change, async functions get parsed as top level function declarations and get their own unwrapped line context. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32590 llvm-svn: 301538
* clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.Martin Probst2017-04-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: Java and JavaScript support annotations and decorators, respectively, that use a leading "@" token. clang-format currently detects this as an Objective-C construct and applies special formatting, for example no whitespace around "=" operators. This change disables the distinction for Java and JavaScript, which leads to normal formatting of single line annotated and initialized properties. Before: class X { @foo() bar=false; } After: class X { @foo() bar = false; } Reviewers: djasper, bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32532 llvm-svn: 301399
* clang-format: [JS] prevent wraps before class members.Martin Probst2017-04-261-0/+19
| | | | | | | | | | | | Summary: In JavaScript/TypeScript, class member definitions that use modifiers can be subject to Automatic Semicolon Insertion (ASI). For example, "class X { get \n foo }" defines a property called "get" and a property called "foo", both with no type annotation. This change prevents wrapping after the modifier keywords (visibility modifiers, static, get and set) to prevent accidental ASI. Reviewers: djasper, bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32531 llvm-svn: 301397
* clang-format: Fix bad corner case in formatting of function types.Daniel Jasper2017-04-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Before: std::function< LoooooooooooongTemplatedType<SomeType>*( LooooooooooooooooooooongType type)> function; After: std::function< LoooooooooooongTemplatedType< SomeType>*( LooooooooooooooooongType type)> function; clang-format generally avoids having lines like "SomeType>*(" as they lead to parameter lists that don't belong together to be aligned. However, in case it is better than the alternative, which can even be violating the column limit. llvm-svn: 301182
* [clang-format] Replace IncompleteFormat by a struct with LineKrasimir Georgiev2017-04-215-41/+44
| | | | | | | | | | | | | | Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by a struct that also contains a line number. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32298 llvm-svn: 300985
* [clang-format] Clang-tidy cleanup of NamespaceEndCommentFixerTest.cpp, NFCKrasimir Georgiev2017-04-211-1/+1
| | | | llvm-svn: 300983
* [clang-format] Clang-tidy cleanup of CleanupTest.cpp, NFCKrasimir Georgiev2017-04-211-3/+2
| | | | llvm-svn: 300982
OpenPOWER on IntegriCloud