Skip to content

[clang-format] Unstable output with AllowShortFunctionsOnASingleLine=inline #102937

Closed
@vient

Description

@vient

Somewhat minified test case:

void f() {
#define M(x)     \
  case 0: {      \
    return {#x}; \
  }
}

Formatting it with clang-format-18 -Werror --style='{AllowShortFunctionsOnASingleLine: Inline}' results in oscillating outputs - original code produces output 1, it produces output 2, which produces output 1, and so on (1️⃣🔄2️⃣).
Output 1:

void f() {
#define M(x)                                                                   \
  case 0: {                                                                    \
    return {                                                                   \
      #x                                                                       \
    };                                                                         \
  }
}

Output 2:

void f() {
#define M(x)                                                                   \
  case 0: {                                                                    \
    return {#x};                                                               \
  }
}

It is a regression in clang-format-18, 17 works fine. Issue is still present in clang-format-19, did not check with trunk.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions