[all-commits] [llvm/llvm-project] fd8678: [clang-format] Don't allow variable decls to have ...

Emilia Dreamer via All-commits all-commits at lists.llvm.org
Mon Apr 3 05:49:06 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd86789962964a98157e8159c3d95cdc241942e3
      https://github.com/llvm/llvm-project/commit/fd86789962964a98157e8159c3d95cdc241942e3
  Author: Emilia Dreamer <emilia at rymiel.space>
  Date:   2023-04-03 (Mon, 03 Apr 2023)

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

  Log Message:
  -----------
  [clang-format] Don't allow variable decls to have trailing return arrows

The heuristic for determining if an arrow is a trailing return arrow
looks for the auto keyword, along with parentheses. This isn't
sufficient, since it also triggers on variable declarations with an auto
type, and with an arrow operator.

This patch makes sure a function declaration is being parsed, instead of
any other declaration.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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




More information about the All-commits mailing list