[all-commits] [llvm/llvm-project] 46f6c8: [clang-format] Fix QualifierOrder breaking the cod...

Marek Kurdej via All-commits all-commits at lists.llvm.org
Thu Feb 24 01:16:21 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 46f6c834d9f95d99e0a85aa0c6dc07419aa6dee2
      https://github.com/llvm/llvm-project/commit/46f6c834d9f95d99e0a85aa0c6dc07419aa6dee2
  Author: Marek Kurdej <marek.kurdej+llvm.org at gmail.com>
  Date:   2022-02-24 (Thu, 24 Feb 2022)

  Changed paths:
    M clang/lib/Format/QualifierAlignmentFixer.cpp
    M clang/unittests/Format/QualifierFixerTest.cpp

  Log Message:
  -----------
  [clang-format] Fix QualifierOrder breaking the code with requires clause.

Fixes https://github.com/llvm/llvm-project/issues/53962.

Given the config:
```
BasedOnStyle: LLVM
QualifierAlignment: Custom
QualifierOrder: ['constexpr', 'type']
```

The code:
```
template <typename F>
  requires std::invocable<F>
constexpr constructor();
```
was incorrectly formatted to:
```
template <typename F>
  requires
constexpr std::invocable<F> constructor();
```
because we considered `std::invocable<F> constexpr` as a type, not recognising the requires clause.

This patch avoids moving the qualifier across the boundary of the requires clause (checking `ClosesRequiresClause`).

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D120309




More information about the All-commits mailing list