Skip to content

clang-format outputs broken JSON in raw string literals #65400

@AdamBucior

Description

@AdamBucior

clang-format breaks content of raw string literals containing JSON.

C:\bug>clang-format --version
clang-format version 18.0.0 (https://github.com/llvm/llvm-project.git c8544d280a8ef1e41efc5c036e00dc671edbb93d)

C:\bug>type .clang-format
BasedOnStyle: LLVM
RawStringFormats:
  - Language: Json
    Delimiters: [json]

C:\bug>type test.cpp
void foo() {
  const char *json = R"json({
    "str": "test"
  })json";
}

C:\bug>clang-format -style=file test.cpp
void foo() {
  const char *json = R"json(tr": "test" })json";
}

Metadata

Metadata

Assignees

Labels

clang-formatinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compiles

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions