llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.17k stars 12.03k forks source link

A feature to make clang format not touch macros #86277

Closed BGOPC closed 8 months ago

BGOPC commented 8 months ago

Hey, I'm using Clang format to format my competitive programming codes, I have a large coding template, and when I format using Clang it opens up everything and creates a 100-line mess while when it's compressed it's 31, mostly the thing that happens is this:

#define sik(x) {cout << x << nl; return;}

which turns to this:

#define sik(x)       \
  {                  \
    cout << x << nl; \
    return;          \
  }

please add a flag to tell clang not touch macros

llvmbot commented 8 months ago

@llvm/issue-subscribers-clang-format

Author: BGOPC (BGOPC)

Hey, I'm using Clang format to format my competitive programming codes, I have a large coding template, and when I format using Clang it opens up everything and creates a 100-line mess while when it's compressed it's 31, mostly the thing that happens is this: ```C++ #define sik(x) {cout << x << nl; return;} ``` which turns to this: ```C++ #define sik(x) \ { \ cout << x << nl; \ return; \ } ``` please add a flag to tell clang not touch macros
owenca commented 8 months ago

See https://releases.llvm.org/18.1.1/tools/clang/docs/ClangFormatStyleOptions.html#skipmacrodefinitionbody.