- Jun 19, 2017
-
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305696 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305667 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305666 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jun 14, 2017
-
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305384 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jun 13, 2017
-
-
Krasimir Georgiev authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305293 91177308-0d34-0410-b5e6-96231b3b80d8
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305272 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jun 07, 2017
-
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304912 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
Summary: Support "export type T = {...};", in addition to just "type T = {...};". Reviewers: klimek Differential Revision: https://reviews.llvm.org/D33980 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304904 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jun 06, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304791 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Jun 04, 2017
-
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304687 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 31, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304290 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 29, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304141 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304135 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 24, 2017
-
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303739 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 22, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303557 91177308-0d34-0410-b5e6-96231b3b80d8
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303556 91177308-0d34-0410-b5e6-96231b3b80d8
-
Krasimir Georgiev authored
[clang-format] Keep trailing preprocessor line comments separate from the 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303541 91177308-0d34-0410-b5e6-96231b3b80d8
-
Francois Ferrand authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303534 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 21, 2017
-
-
Craig Topper authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303501 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 19, 2017
-
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303415 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 18, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303382 91177308-0d34-0410-b5e6-96231b3b80d8
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303353 91177308-0d34-0410-b5e6-96231b3b80d8
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303332 91177308-0d34-0410-b5e6-96231b3b80d8
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303330 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 15, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303106 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303049 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303038 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 12, 2017
-
-
Martin Probst authored
Summary: Previously: x = namespace !; Now: x = namespace!; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33113 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302893 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 10, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302658 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 09, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302580 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302523 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 08, 2017
-
-
Daniel Jasper authored
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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302428 91177308-0d34-0410-b5e6-96231b3b80d8
-
Daniel Jasper authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302427 91177308-0d34-0410-b5e6-96231b3b80d8
-
- May 04, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302156 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Apr 27, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301538 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Apr 26, 2017
-
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301399 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301398 91177308-0d34-0410-b5e6-96231b3b80d8
-
Martin Probst authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301397 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Apr 24, 2017
-
-
Daniel Jasper authored
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301182 91177308-0d34-0410-b5e6-96231b3b80d8
-
- Apr 21, 2017
-
-
Krasimir Georgiev authored
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300985 91177308-0d34-0410-b5e6-96231b3b80d8
-