https://bugs.llvm.org/show_bug.cgi?id=52401

            Bug ID: 52401
           Summary: clang-format Require Clause fails to break correctly
                    when using parenthesis.
           Product: clang
           Version: 13.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: peecese...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

related to: https://bugs.llvm.org/show_bug.cgi?id=32165
It seems to have some basic formatting that works okay as long as you don't use
parenthesis. If I wrap the Requires clause in parenthesis the whole thing and
the following line will be combined into one line. At least in some of my
testing.
I'm using the ClangFormat built into Clion it appears to be ClangFormat 13.

//start without parenthesis
 template<
    bool nested = true,
    typename lambdaT,
    typename filterT = decltype(default_filter_lambda)>
  requires valid_execute_on_lambda<lambdaT> && valid_filter_lambda<filterT>
  bool
    execute_on(
      const std::initializer_list<std::string_view> &filename,
      lambdaT                                      &&lambda,
      filterT                                      &&filter_lambda = {}) const
  {
    return loop(get_execute_on_lambda<nested>(filename, lambda,
filter_lambda));
  }
//end without.
//start with
template<
    bool nested = true,
    typename lambdaT,
    typename filterT = decltype(default_filter_lambda)>
  requires(valid_execute_on_lambda<lambdaT> &&valid_filter_lambda<filterT>)
bool execute_on(
    const std::initializer_list<std::string_view> &filename,
    lambdaT                                      &&lambda,
    filterT                                      &&filter_lambda = {}) const
  {
    return loop(get_execute_on_lambda<nested>(filename, lambda,
filter_lambda));
  }
//end with
The one below here requires the parathesis because it has two conditions. See
how the function type and function name are forced to be on the same line as
the last condition?
//start another example with two groups of parenthesis
 template<
    bool nested = true,
    ArchiveTypeT... aT,
    typename lambdaT,
    typename filterT = decltype(default_filter_lambda)>
  requires(valid_execute_on_lambda<lambdaT> &&valid_filter_lambda<filterT>)
    && (sizeof...(aT) > 0) bool execute_on(
      const std::initializer_list<std::string_view> &filename,
      lambdaT                                      &&lambda,
      filterT                                      &&filter_lambda = {}) const
  {
    return specify<aT...>(
      get_execute_on_lambda<nested>(filename, lambda, filter_lambda));
  }
};
//end of another example.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to