[clang-format] Allow trailing return types in macros
authorEmilia Dreamer <emilia@rymiel.space>
Thu, 23 Mar 2023 17:31:39 +0000 (19:31 +0200)
committerEmilia Dreamer <emilia@rymiel.space>
Thu, 23 Mar 2023 17:37:53 +0000 (19:37 +0200)
commitc70e360b355ad30a7dd299435aae0324c5033b3f
tree0b5086db28852670914ea1b4b3832baca233ab78
parent6a2a5f08de0a09171bb92f91cd7b9deea97f6cce
[clang-format] Allow trailing return types in macros

The trailing return type arrow checker verifies that a declaration is
being parsed, however, this isn't true when inside of macros.

It turns out the existence of the auto keyword is enough to make
sure that we're dealing with a trailing return type, and whether we're
in a declaration doesn't matter.

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

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D141811
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp