Skip to content
Snippets Groups Projects
  1. Jun 19, 2017
    • Francois Ferrand's avatar
      clang-format: Fix C99 designated initializers corner cases · 0e83c02b
      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
      0e83c02b
    • Daniel Jasper's avatar
      clang-format: Improve understanding of combined typedef+record declarations · 2d7e549a
      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
      2d7e549a
    • Daniel Jasper's avatar
      clang-format: Handle "if constexpr". · 57fae474
      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
      57fae474
  2. Jun 14, 2017
  3. Jun 13, 2017
  4. Jun 07, 2017
  5. Jun 06, 2017
    • Martin Probst's avatar
      clang-format: [JS] Correctly Indent Nested JavaScript Literals. · 069779a6
      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
      069779a6
  6. Jun 04, 2017
  7. May 31, 2017
    • Martin Probst's avatar
      clang-format: [JS] improve calculateBraceType heuristic · e22ee5cb
      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
      e22ee5cb
  8. May 29, 2017
  9. May 24, 2017
    • Francois Ferrand's avatar
      clang-format: Introduce BreakConstructorInitializers option · eaa2b10e
      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
      eaa2b10e
  10. May 22, 2017
    • Martin Probst's avatar
      clang-format: [JS] avoid line breaks before unindented r_parens. · 0e60ff15
      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
      0e60ff15
    • Francois Ferrand's avatar
      clang-format: do not reflow bullet lists · 6c88fb85
      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
      6c88fb85
    • Krasimir Georgiev's avatar
      [clang-format] Keep trailing preprocessor line comments separate from the... · 51ee6cef
      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
      51ee6cef
    • Francois Ferrand's avatar
      clang-format: Allow customizing the penalty for breaking assignment · beecc655
      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
      beecc655
  11. May 21, 2017
  12. May 19, 2017
    • Krasimir Georgiev's avatar
      [clang-format] Handle trailing comment sections in import statement lines · 354737f8
      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
      354737f8
  13. May 18, 2017
  14. May 15, 2017
  15. May 12, 2017
  16. May 10, 2017
  17. May 09, 2017
  18. May 08, 2017
  19. May 04, 2017
  20. Apr 27, 2017
  21. Apr 26, 2017
  22. Apr 24, 2017
    • Daniel Jasper's avatar
      clang-format: Fix bad corner case in formatting of function types. · 089f73f8
      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
      089f73f8
  23. Apr 21, 2017
Loading