Skip to content

[clang-format] auto variable initialized with arrow operator can be seen as trailing return type #61469

@rymiel

Description

@rymiel

Input code:

auto a = (b)->c;

Result from clang-format-17 (main), with default style ({}):

auto a = (b) -> c;

The arrow is annotated as a trailing return type arrow due to an imperfect heuristic in determineTokenType.

This also applies to decltype(auto):

decltype(auto) a = (b) -> c;

This issue isn't encountered without the (redundant) parentheses:

auto a = b->c;

Originally discovered in https://reviews.llvm.org/D141811; I planned to make a fix for it there, but it turned out harder than I expected, so I'm adding an issue for it so I don't forget.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions