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 15, 2017
  3. Jun 14, 2017
  4. Jun 13, 2017
  5. Jun 09, 2017
  6. Jun 07, 2017
  7. 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
  8. Jun 04, 2017
  9. Jun 02, 2017
  10. 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
  11. May 29, 2017
  12. May 24, 2017
    • Serge Pavlov's avatar
      Driver must return non-zero code on errors in command line · 4e7d2c58
      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
      4e7d2c58
    • Krasimir Georgiev's avatar
      [clang-format] Remove unused using directive, NFC · 59a0553f
      Krasimir Georgiev authored
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303742 91177308-0d34-0410-b5e6-96231b3b80d8
      59a0553f
    • Serge Pavlov's avatar
      Method loadFromCommandLine should be able to report errors · 5bfd35d6
      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
      5bfd35d6
    • 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
  13. 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
  14. 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
  15. May 18, 2017
  16. May 15, 2017
  17. May 12, 2017
  18. May 10, 2017
Loading