[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
Sat Nov 5 15:44:33 PDT 2022


goldstein.w.n added a comment.

In D137181#3904383 <https://reviews.llvm.org/D137181#3904383>, @owenpan wrote:

> With `ColumnLimit: 16` and `IndentPPDirectives: BeforeHash`, the format should be:
>
>   #ifdef foo
>    #define bar() \
>        if (A) {  \
>            B();  \
>        }         \
>        C();
>   #endif
>
> With `IndentPPDirectives: AfterHash`, it should look like:
>
>   #ifdef foo
>   # define bar() \
>        if (A) {  \
>            B();  \
>        }         \
>        C();
>   #endif

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


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