llvm / llvm-project

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

Clang-format does not split very long raw string literal #61087

Open JVApen opened 1 year ago

JVApen commented 1 year ago

Given the following code and a Clang-Format file that has a maximum line length:

auto veryLong =
      R"raw(aaaaaa...aaaaaaaa)raw";

Clang-Format does not want to split the raw string literal into smaller chunks. Expected:

auto veryLong =
      R"raw(aaaaaa...a)raw"
      R"raw(aaaaaaa)raw";

The actual string in our code does contain several spaces on which splitting could be possible.

I've tried this with a string containing 5000 characters, even put PenaltyBreakString: 0 in the config file. Tried updating RawStringFormats to contain raw or raw( and several other variations, I can't seem to get Clang-Format to split a raw string literal into parts.

Removing the R and making this a regular string does cause it to jump onto multiple lines.

JVApen commented 1 year ago

I tried this with 16-rc2, although, I don't have any indications that this is a regression.

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-format

blackworm27 commented 8 months ago

Just want to add that the issue also happens with a literal string suffix, e.g.: auto str = "some string"_suffix;