[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
Mon Nov 7 22:27:19 PST 2022


goldstein.w.n added a comment.

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

> In D137181#3911005 <https://reviews.llvm.org/D137181#3911005>, @sstwcw wrote:
>
>> Here is one problem:
>>
>>   clang-format -style='{IndentPPDirectives: BeforeHash, PPIndentWidth: 1, IndentWidth: 4, IndentCaseLabels: true}'
>>   
>>   actual:
>>   #define X                                                                      \
>>    switch (x) {                                                                  \
>>        case 0:                                                                   \
>>         break;                                                                   \
>>        default:                                                                  \
>>         break;                                                                   \
>>    }
>>   
>>   expected:
>>   #define X                                                                      \
>>    switch (x) {                                                                  \
>>        case 0:                                                                   \
>>            break;                                                                \
>>        default:                                                                  \
>>            break;                                                                \
>>    }
>
> Actually, the expected should be:
>
>   #define X                                                                         \
>       switch (x) {                                                                  \
>           case 0:                                                                   \
>               break;                                                                \
>           default:                                                                  \
>               break;                                                                \
>       }

Err I'm not sure that's right. I thought we where going for the C-code should start at the column that the 'd' in define is.
So it would be:

  #define X               \
   switch (x) {            \
       case 0:               \
           break;            \
       default:              \
           break;            \
   }


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