[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros
Noah Goldstein via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 6 01:04:29 PST 2022
goldstein.w.n added a comment.
In D137181#3910566 <https://reviews.llvm.org/D137181#3910566>, @owenpan wrote:
> In D137181#3910404 <https://reviews.llvm.org/D137181#3910404>, @goldstein.w.n wrote:
>
>> Doesn't that add an arbitrary +1 to the begining of the indentation?
>> Shouldn't it be:
>>
>> // IndentPPDirectives: AfterHash
>> #ifdef foo
>> # define bar() \\
>> if (A) { \\
>> B(); \\
>> } \\
>> C();
>> #endif
>>
>> // IndentPPDirectives: BeforeHash
>> #ifdef foo
>> #define bar() \\
>> if (A) { \\
>> B(); \\
>> } \\
>> C();
>> #endif
>>
>> // IndentPPDirectives: NoneHash
>> #ifdef foo
>> #define bar() \\
>> if (A) { \\
>> B(); \\
>> } \\
>> C();
>> #endif
>
> Given the settings used in your example:
>
> PPIndentWidth: 1
> IndentWidth: 4
>
> IMO the macro body should be shifted to the right by 1 column (except when `IndentPPDirectives` is set to `None`). That is, the indent of the macro body relative to the start of `define` should be the same with any setting of `IndentPPDirective`.
Okay set it up so that where the 'd' in "define" is is always where indentation starts.
Essentially track `PPLevel` independently of `Level` and use the two seperarely.
I probably missed a few places / added in a few bad places.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137181/new/
https://reviews.llvm.org/D137181
More information about the cfe-commits
mailing list