[clang-format] Correctly annotate star/amp in function pointer params
authorEmilia Dreamer <emilia@rymiel.space>
Tue, 11 Oct 2022 19:16:48 +0000 (22:16 +0300)
committerEmilia Dreamer <emilia@rymiel.space>
Tue, 18 Oct 2022 05:17:23 +0000 (08:17 +0300)
commit94215d2b2103c5ad74596dd51704836f92afec89
treeab34cf8fa133b2d77c3241992be180d2db5b110f
parent8e7d5d5863105aa2c0610bc5d00e5cfad683c7fd
[clang-format] Correctly annotate star/amp in function pointer params

Inside the arguments part of a function pointer declaration,
`determineStarAmpUsage` results in a binary operator rather than
pointers, because said parens are assumed to be an expression.

This patch correctly marks the argument parens of a function
pointer type as not an expression. Note that this fix already
existed for Objective-C blocks as part of f1f267b447f60528440d2c066b29ab014ae7f90f.
As Objective-C blocks and C/C++ function pointers share a lot
of the same logic, that fix also makes sense here.

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

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