[PATCH] D110833: [clang-format] Add ControlStatementsAndFunctionDefinitionsExceptControlMacros option to SpaceBeforeParens
Christian Rayroud via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 1 03:12:35 PDT 2021
crayroud added inline comments.
================
Comment at: clang/docs/ClangFormatStyleOptions.rst:3649
``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
backward compatibility.
----------------
MyDeveloperDay wrote:
> Now I look back here, why where these Macro considered the same as for loops? why would we want
>
> ```
> for (....)
> Q_FOREACH(...)
> ```
>
> So this really does need a struct or we'll be eventually be adding
>
> `SBPO_ControlStatementsAndFunctionDefinitionsExceptControlMacrosButNotIfAndDefinatelyWhilesAndSometimesSwitchButOnlyOnTheSecondThursdayOfTheMonth`
>
> ```
> SpaceBeforeParen:
> AfterFunctionDefinitionName: false
> AfterFunctionDeclarationName: true
> AfterSwitch: true
> AfterForeachMacros: false
> .... (there are likely others)
> ```
>
> `
>
>
>
>
>
Indeed replacing the enum with a struct as suggested is better to support the different possible combinations, compare to the current version of SpaceBeforeParens that results in very long names.
To support existing configuration files, I propose to keep the enum and to add a struct to handle the custom use cases and to cleanup the code. What do you think ?
```
SpaceBeforeParens: Custom
SpaceBeforeParensCustom:
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: true
AfterSwitch: true
AfterForeachMacros: false
…
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110833/new/
https://reviews.llvm.org/D110833
More information about the cfe-commits
mailing list