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

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


alexfh added a comment.

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!


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