[all-commits] [llvm/llvm-project] 784722: [clang-format] Correctly annotate static and const...

Emilia Dreamer via All-commits all-commits at lists.llvm.org
Sun Sep 25 11:16:23 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7847225576d571fb7101463de56330e1f0e84856
      https://github.com/llvm/llvm-project/commit/7847225576d571fb7101463de56330e1f0e84856
  Author: Emilia Dreamer <emilia at rymiel.space>
  Date:   2022-09-25 (Sun, 25 Sep 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/TokenAnnotatorTest.cpp

  Log Message:
  -----------
  [clang-format] Correctly annotate static and consteval lambdas

`P1169` "static operator()" (https://wg21.link/P1169) is accepted to
C++23 and while clang itself doesn't exactly support it yet,
clang-format could quite easily.

This simply allows the keyword `static` to be a part of lambdas as
specified by the addition to [expr.prim.lambda.general]

While adding this, I noticed `consteval` lambdas also aren't handled,
so that keyword is now allowed to be a part of lambdas as well

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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


  Commit: 39e6077d97238ec13c9ed1b9dbae1e6408e5aba3
      https://github.com/llvm/llvm-project/commit/39e6077d97238ec13c9ed1b9dbae1e6408e5aba3
  Author: Emilia Dreamer <emilia at rymiel.space>
  Date:   2022-09-25 (Sun, 25 Sep 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/TokenAnnotatorTest.cpp

  Log Message:
  -----------
  [clang-format] Look ahead before consuming `bool` in requires clause.

The comment handling the bool case says:
"bool is only allowed if it is directly followed by a paren for a cast"

This change more closely follows this directive by looking ahead for
the paren before consuming the bool keyword itself. Without a following
paren, the bool would be part of something else, such as a return type
for a function declaration

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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


Compare: https://github.com/llvm/llvm-project/compare/bcb1397bda66...39e6077d9723


More information about the All-commits mailing list