Skip to content

clang-format oscillates formatting of // clang-format off #62107

@ghost

Description

clang-format oscillates between two different choices for how to format the following minimal example. It will continuously reformat its own output. Here is the relevant .clang-format:

---
Language:        Cpp
BasedOnStyle:  Google
ReflowComments: false

And here is a minimal example in C++ to reproduce this.

void func() {
  // clang-format off
  #define KV(value) #value, value
  // clang-format on
}

Running clang-format against this produces the result:

void func() {
// clang-format off
  #define KV(value) #value, value
  // clang-format on
}

But running clang-format again on that output re-formats it back to the original code (i.e. it adds the indentation back before the comment). I have tested this against clang-format 16.0.1 and 12.0.0, and am able to reproduce the bug with both.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions