Skip to content
Snippets Groups Projects
  1. Feb 06, 2018
    • Hans Wennborg's avatar
      Merging r324246: · 11cd7cef
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324246 | mzeren-vmw | 2018-02-05 16:59:00 +0100 (Mon, 05 Feb 2018) | 33 lines
      
      [clang-format] Re-land: Fixup #include guard indents after parseFile()
      
      Summary:
      When a preprocessor indent closes after the last line of normal code we do not
      correctly fixup include guard indents. For example:
      
        #ifndef HEADER_H
        #define HEADER_H
        #if 1
        int i;
        #  define A 0
        #endif
        #endif
      
      incorrectly reformats to:
      
        #ifndef HEADER_H
        #define HEADER_H
        #if 1
        int i;
        #    define A 0
        #  endif
        #endif
      
      To resolve this issue we must fixup levels after parseFile(). Delaying
      the fixup introduces a new state, so consolidate include guard search
      state into an enum.
      
      Reviewers: krasimir, klimek
      
      Subscribers: cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D42035
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324331 91177308-0d34-0410-b5e6-96231b3b80d8
      11cd7cef
    • Hans Wennborg's avatar
      Merging r323904: · 51390c59
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r323904 | mzeren-vmw | 2018-01-31 21:05:50 +0100 (Wed, 31 Jan 2018) | 34 lines
      
      [clang-format] Align preprocessor comments with #
      
      Summary:
      r312125, which introduced preprocessor indentation, shipped with a known
      issue where "indentation of comments immediately before indented
      preprocessor lines is toggled on each run". For example these two forms
      toggle:
      
        #ifndef HEADER_H
        #define HEADER_H
        #if 1
        // comment
        #   define A 0
        #endif
        #endif
      
        #ifndef HEADER_H
        #define HEADER_H
        #if 1
           // comment
        #   define A 0
        #endif
        #endif
      
      This happens because we check vertical alignment against the '#' yet
      indent to the level of the 'define'. This patch resolves this issue by
      aligning against the '#'.
      
      Reviewers: krasimir, klimek, djasper
      
      Reviewed By: krasimir
      
      Subscribers: cfe-commits
      Differential Revision: https://reviews.llvm.org/D42408
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324329 91177308-0d34-0410-b5e6-96231b3b80d8
      51390c59
  2. Dec 14, 2017
    • Ben Hamilton's avatar
      Revert "[ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC style" · d32e8534
      Ben Hamilton authored
      This reverts commit 37e69667f748e1458b46483b7c1b8f9ba33eec44.
      
      We're going to discuss its ramifications further before making a
      conclusion.
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320747 91177308-0d34-0410-b5e6-96231b3b80d8
      d32e8534
    • Ben Hamilton's avatar
      [ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC style · 71ce0c7b
      Ben Hamilton authored
      Summary:
      If we write the following code, it goes over 100 columns, so we need to wrap it:
      
      ```
      - (VeryLongReturnTypeName)veryLongMethodParameter:(VeryLongParameterName)thisIsAVeryLongParameterName
                                    longMethodParameter:(LongParameterName)thisIsAlsoAnotherLongParameterName;
      ```
      
      Currently, clang-format with the google style aligns the method parameter names on the first column:
      
      ```
      - (VeryLongReturnTypeName)
      veryLongMethodParameter:(VeryLongParameterName)thisIsAVeryLongParameterName
          longMethodParameter:(LongParameterName)thisIsAlsoAnotherLongParameterName;
      ```
      
      We'd like clang-format in the google style to align these to column 4 for Objective-C:
      
      ```
      - (VeryLongReturnTypeName)
          veryLongMethodParameter:(VeryLongParameterName)thisIsAVeryLongParameterName
                  longMethodParameter:(LongParameterName)thisIsAlsoAnotherLongParameterName;
      ```
      
      Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
      
      Reviewers: krasimir, djasper, klimek
      
      Reviewed By: djasper
      
      Subscribers: cfe-commits, thakis
      
      Differential Revision: https://reviews.llvm.org/D41195
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320714 91177308-0d34-0410-b5e6-96231b3b80d8
      71ce0c7b
    • Richard Smith's avatar
      [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. · 96881be7
      Richard Smith authored
      Adding the new enumerator forced a bunch more changes into this patch than I
      would have liked. The -Wtautological-compare warning was extended to properly
      check the new comparison operator, clang-format needed updating because it uses
      precedence levels as weights for determining where to break lines (and several
      operators increased their precedence levels with this change), thread-safety
      analysis needed changes to build its own IL properly for the new operator.
      
      All "real" semantic checking for this operator has been deferred to a future
      patch. For now, we use the relational comparison rules and arbitrarily give
      the builtin form of the operator a return type of 'void'.
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320707 91177308-0d34-0410-b5e6-96231b3b80d8
      96881be7
  3. Dec 12, 2017
  4. Dec 05, 2017
    • Shoaib Meenai's avatar
      [CMake] Use PRIVATE in target_link_libraries for executables · 456e35cb
      Shoaib Meenai authored
      We currently use target_link_libraries without an explicit scope
      specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
      Dependencies added in this way apply to both the target and its
      dependencies, i.e. they become part of the executable's link interface
      and are transitive.
      
      Transitive dependencies generally don't make sense for executables,
      since you wouldn't normally be linking against an executable. This also
      causes issues for generating install export files when using
      LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
      library dependencies, which are currently added as interface
      dependencies. If clang is in the distribution components but the LLVM
      libraries it depends on aren't (which is a perfectly legitimate use case
      if the LLVM libraries are being built static and there are therefore no
      run-time dependencies on them), CMake will complain about the LLVM
      libraries not being in export set when attempting to generate the
      install export file for clang. This is reasonable behavior on CMake's
      part, and the right thing is for LLVM's build system to explicitly use
      PRIVATE dependencies for executables.
      
      Unfortunately, CMake doesn't allow you to mix and match the keyword and
      non-keyword target_link_libraries signatures for a single target; i.e.,
      if a single call to target_link_libraries for a particular target uses
      one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
      also be updated to use those keywords. This means we must do this change
      in a single shot. I also fully expect to have missed some instances; I
      tested by enabling all the projects in the monorepo (except dragonegg),
      and configuring both with and without shared libraries, on both Darwin
      and Linux, but I'm planning to rely on the buildbots for other
      configurations (since it should be pretty easy to fix those).
      
      Even after this change, we still have a lot of target_link_libraries
      calls that don't specify a scope keyword, mostly for shared libraries.
      I'm thinking about addressing those in a follow-up, but that's a
      separate change IMO.
      
      Differential Revision: https://reviews.llvm.org/D40823
      
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319840 91177308-0d34-0410-b5e6-96231b3b80d8
      456e35cb
  5. Dec 04, 2017
    • Manuel Klimek's avatar
      Fix bug where we wouldn't break columns over the limit. · b779bc4d
      Manuel Klimek authored
      Before, we would not break:
        int a = foo(/* trailing */);
      when the end of /* trailing */ was exactly the column limit; the reason
      is that block comments can have an unbreakable tail length - in this case
      2, for the trailing ");"; we would unconditionally account that when
      calculating the column state at the end of the token, but not correctly
      add it into the remaining column length before, as we do for string
      literals.
      The fix is to correctly account the trailing unbreakable sequence length
      into our formatting decisions for block comments. Line comments cannot
      have a trailing unbreakable sequence, so no change is needed for them.
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319642 91177308-0d34-0410-b5e6-96231b3b80d8
      b779bc4d
  6. Dec 01, 2017
    • Manuel Klimek's avatar
      Better trade-off for excess characters vs. staying within the column limits. · b1bb1031
      Manuel Klimek authored
      When we break a long line like:
      Column limit: 21
                            |
        // foo foo foo foo foo foo foo foo foo foo foo foo
      
      The local decision when to allow protruding vs. breaking can lead to this
      outcome (2 excess characters, 2 breaks):
        // foo foo foo foo foo
        // foo foo foo foo foo
        // foo foo
      
      While strictly staying within the column limit leads to this strictly better
      outcome (fully below the column limit, 2 breaks):
        // foo foo foo foo
        // foo foo foo foo
        // foo foo foo foo
      
      To get an optimal solution, we would need to consider all combinations of excess
      characters vs. breaking for all lines, but that would lead to a significant
      increase in the search space of the algorithm for little gain.
      
      Instead, we blindly try both approches and·select the one that leads to the
      overall lower penalty.
      
      Differential Revision: https://reviews.llvm.org/D40605
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319541 91177308-0d34-0410-b5e6-96231b3b80d8
      b1bb1031
  7. Nov 30, 2017
  8. Nov 29, 2017
    • Manuel Klimek's avatar
      Restructure how we break tokens. · 64d42a2f
      Manuel Klimek authored
      This fixes some bugs in the reflowing logic and splits out the concerns
      of reflowing from BreakableToken.
      
      Things to do after this patch:
      - Refactor the breakProtrudingToken function possibly into a class, so we
        can split it up into methods that operate on the common state.
      - Optimize whitespace compression when reflowing by using the next possible
        split point instead of the latest possible split point.
      - Retry different strategies for reflowing (strictly staying below the
        column limit vs. allowing excess characters if possible).
      
      Differential Revision: https://reviews.llvm.org/D40310
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319314 91177308-0d34-0410-b5e6-96231b3b80d8
      64d42a2f
  9. Nov 27, 2017
  10. Nov 25, 2017
  11. Nov 24, 2017
  12. Nov 17, 2017
  13. Nov 14, 2017
  14. Nov 10, 2017
  15. Nov 09, 2017
  16. Nov 06, 2017
  17. Nov 03, 2017
  18. Oct 30, 2017
  19. Oct 19, 2017
  20. Oct 16, 2017
  21. Oct 02, 2017
  22. Sep 27, 2017
  23. Sep 26, 2017
  24. Sep 22, 2017
  25. Sep 20, 2017
    • Manuel Klimek's avatar
      Fix clang-format's detection of structured bindings. · 9c03e2cb
      Manuel Klimek authored
      Correctly determine when [ is part of a structured binding instead of a
      lambda.
      
      To be able to reuse the implementation already available, this patch also:
      - sets the Previous link of FormatTokens in the UnwrappedLineParser
      - moves the isCppStructuredBinding function into FormatToken
      
      Before:
        auto const const &&[x, y] { A *i };
      
      After:
        auto const const && [x, y]{A * i};
      
      Fixing formatting of the type of the structured binding is still missing.
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313742 91177308-0d34-0410-b5e6-96231b3b80d8
      9c03e2cb
Loading