llvm / llvm-project

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

clang-format: SeparateDefinitionBlocks does not fully honor 'clang-format off' #55179

Open jaredgrubb opened 2 years ago

jaredgrubb commented 2 years ago

I would expect clang-format should never touch code between the control markers. This is innocuous but is surprising. Here is a small reproduction:

Style file:

SeparateDefinitionBlocks: Always

Input file:

/* clang-format off */
 #define Foo 1
/* clang-format on */

struct Something {};

Output:

/* clang-format off */
 #define Foo 1

/* clang-format on */

struct Something {};

This was tested with clang-format 14.0.0. I haven't tried other versions.

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-format