[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 18 06:06:01 PDT 2021


HazardyKnusperkeks added a comment.

In D109951#3007425 <https://reviews.llvm.org/D109951#3007425>, @guitard0g wrote:

> When looking at test case suggestions, I happened upon another problem that occurs when handling preprocessor directives. The following code is properly formatted (following llvm style, with ColumnLimit=0):
>
>   SomeClass::SomeClass()
>     : a{a},
>       b{b} {}
>
> However this code:
>
>   Foo::Foo()
>       : x{x},
>   #if DEBUG
>         y{y},
>   #endif
>         z{z} {}
>
> Is transformed by clang-format (under the same style guidelines) into this:
>
>   Foo::Foo()
>       : x{x},
>   #if DEBUG
>         y{y},
>   #endif
>         z{z} {
>   }
>
> It seems there is some wonkiness with how it handles preprocessor statements here. I can address this in a another patch.

`ColumnLimit` of 0 seems to work very differently in many occasions.



================
Comment at: clang/unittests/Format/FormatTest.cpp:19308
+               "#if WINDOWS\n"
+               "#if DEBUG\n"
+               "    , b{0}\n"
----------------
And now I'm curious, if there is a line between the nested PPs?

```
SomeClass::Constructot()
  : a{}
#if X
, b{}
#if Y
...
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109951/new/

https://reviews.llvm.org/D109951



More information about the cfe-commits mailing list