Skip to content

[clang-format] Additional flag of SpaceBeforeParensOptions for C variable declaration required. #115617

@adong660

Description

@adong660

At present, SpaceBeforeParens and its associated SpaceBeforeParensOptions options have limited support on C variable declaration.

If we have a line of C code like
int (*ptr)[4];
It turns out that, if I want to reserve the space between int and (*ptr), I have no choice but to set SpaceBeforeParens to be Always, which prevents me from control the existence of spaces at other places more better. Therefore, I hope there would be a flag called AfterBaseType for SpaceBeforeParensOptions.

I believe that a space at that place is a desired feature among many people, because the exsiting PointerAlignment and ReferenceAlignment options both add at least one space after the type, such as int *ptr, int* ptr, or int * ptr. Generally speaking, a space between the type name and "something following it" should be desired (although some people like to put int and * together, in which case the space comes a bit later, after the *).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions