[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 29 16:18:39 PDT 2021


alexfh added a comment.

In D104601#2915102 <https://reviews.llvm.org/D104601#2915102>, @alexfh wrote:

> This commit changes the behavior of clang -E -P even when no -fminimize-whitespace is used. This breaks certain use cases like using clang to preprocess files for flex, which turns out to be sensitive to the presence of line breaks in places where C++ compilers aren't.
>
> An isolated test case:
>
>   $ clang-old -E -x c++ -P - -o /tmp/pp.good
>   #define I(x, ...) \
>    x { return X##x; }
>   
>   
>   
>   #ifndef A
>   #define A(op, x) I(op, x)
>   #endif
>   
>   A(foo, {
>   
>   
>   
>   
>   
>   
>   
>   })
>   A(bar, {})
>   $ cat /tmp/pp.good
>   foo { return Xfoo; }
>   bar { return Xbar; }
>   $ clang-new -E -x c++ -P - -o /tmp/pp.bad
>   #define I(x, ...) \
>    x { return X##x; }
>   
>   
>   
>   #ifndef A
>   #define A(op, x) I(op, x)
>   #endif
>   
>   A(foo, {
>   
>   
>   
>   
>   
>   
>   
>   })
>   A(bar, {})
>   $ cat /tmp/pp.bad
>   foo { return Xfoo; }bar { return Xbar; }
>
> Please fix or revert the commit.
>
> Thanks!

IIUC, c6b0b16c0f55c34f4eaa05184815bbbe97f4b750 <https://reviews.llvm.org/rGc6b0b16c0f55c34f4eaa05184815bbbe97f4b750> was aimed to fix a similar issue, but it doesn't fix this specific case. If providing a proper fix quickly isn't feasible, consider reverting these patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601



More information about the cfe-commits mailing list