- 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 15, 2017
-
-
Galina Kistanova authored
Added braces to work around gcc warning in googletest: suggest explicit braces to avoid ambiguous 'else'. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305507 91177308-0d34-0410-b5e6-96231b3b80d8
-
Erich Keane authored
A new LexerTest unittest introduced a memory leak. This patch uses a unique_ptr with a custom deleter to ensure it is properly deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305491 91177308-0d34-0410-b5e6-96231b3b80d8
-
Erich Keane authored
Werror was catching a signed/unsigned compare in an assert, correct the signed 'expected' value to be unsigned. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305435 91177308-0d34-0410-b5e6-96231b3b80d8
-
Erich Keane authored
correct getNumArguments StringifiedArguments is allocated (resized) based on the size the getNumArguments function. However, this function ACTUALLY currently returns the amount of total UnexpArgTokens which is minimum the same as the new implementation of getNumMacroArguments, since empty/omitted arguments result in 1 UnexpArgToken, and included ones at minimum include 2 (1 for the arg itself, 1 for eof). This patch renames the otherwise unused getNumArguments to be more clear that it is the number of arguments that the Macro expects, and thus the maximum number that can be stringified. This patch also replaces the explicit memset (which results in value instantiation of the new tokens, PLUS clearing the memory) with brace initialization. Differential Revision: https://reviews.llvm.org/D32046 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305425 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
-
-
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 09, 2017
-
-
Richard Smith authored
as part of a compilation. This is intended for two purposes: 1) Writing self-contained test cases for modules: we can now write a single source file test that builds some number of module files on the side and imports them. 2) Debugging / test case reduction. A single-source testcase is much more amenable to reduction, compared to a VFS tarball or .pcm files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305101 91177308-0d34-0410-b5e6-96231b3b80d8
-
Richard Smith authored
No-one was using this, and it's not meaningful in general -- FrontendActions can be run on inputs that don't have a corresponding source file. The current frontend input can be obtained by asking the FrontendAction if any future action actually needs it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305045 91177308-0d34-0410-b5e6-96231b3b80d8
-
Peter Wu authored
r305022 assumed that floatLiteral(equals(1.2)) would also match 1.2f and 1.2l, but apparently that is not the case. Until it is clear how to match, temporary disable the test to fix CI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305025 91177308-0d34-0410-b5e6-96231b3b80d8
-
Peter Wu authored
Summary: This allows the clang-query tool to use matchers like "integerLiteral(equals(32))". For this to work, an overloaded function is added for each possible parameter type. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33094 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305022 91177308-0d34-0410-b5e6-96231b3b80d8
-
Peter Wu authored
Summary: Needed to support something like "floatLiteral(equals(1.0))". The parser for floating point numbers is kept simple, so instead of ".1" you have to use "0.1". Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33135 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305021 91177308-0d34-0410-b5e6-96231b3b80d8
-
Peter Wu authored
Summary: Recognize boolean literals for future extensions ("equals(true)"). Note that a specific VariantValue constructor is added to resolve ambiguity (like "Value = 5") between unsigned and bool. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33093 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305020 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
-
- Jun 02, 2017
-
-
Alex Lorenz authored
the return type rdar://32332039 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304553 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
-
-
Serge Pavlov authored
This is recommit of r302775, reverted in r302777 due to a fail in clang-tidy. Original mesage is below. Now if clang driver is given wrong arguments, in some cases it continues execution and returns zero code. This change fixes this behavior. The fix revealed some errors in clang test set. File test/Driver/gfortran.f90 added in r118203 checks forwarding gfortran flags to GCC. Now driver reports error on this file, because the option -working-directory implemented in clang differs from the option with the same name implemented in gfortran, in clang the option requires argument, in gfortran does not. In the file test/Driver/arm-darwin-builtin.c clang is called with options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed in r191435 and now clang reports error on this test. File arm-default-build-attributes.s uses option -verify, which is not supported by driver, it is cc1 option. Similarly, the file split-debug.h uses options -fmodules-embed-all-files and -fmodule-format=obj, which are not supported by driver. Other revealed errors are mainly mistypes. Differential Revision: https://reviews.llvm.org/D33013 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303756 91177308-0d34-0410-b5e6-96231b3b80d8
-
Krasimir Georgiev authored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303742 91177308-0d34-0410-b5e6-96231b3b80d8
-
Serge Pavlov authored
Now FixedCompilationDatabase::loadFromCommandLine has no means to report which error occurred if it fails to create compilation object. This is a block for implementing D33013, because after that change driver will refuse to create compilation if command line contains erroneous options. This change adds additional argument to loadFromCommandLine, which is assigned error message text if compilation object was not created. This is the same way as other methods of CompilationDatabase report failure. Differential Revision: https://reviews.llvm.org/D33272 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303741 91177308-0d34-0410-b5e6-96231b3b80d8
-
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 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: 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
-
-
Alex Lorenz authored
rdar://31960860 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302689 91177308-0d34-0410-b5e6-96231b3b80d8
-
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
-