[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 6 00:01:25 PDT 2022


owenpan added a comment.

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`.


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