-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Labels
Description
clang-format is currently unable to break user-defined string literals. For instance,
"A very very very very very very very very very very very very very long string literal";is split into
"A very very very very very very very very very very very very very long "
"string literal";to fit into the 80 characters column limit.
But
unsigned operator ""_s(const char*);
"A very very very very very very very very very very very very very long string literal"_s;remains the same (Godbolt). clang-format is allowed to break the string into
"A very very very very very very very very very very very very very long "
"string literal"_s;as explained by cppreference.com:

Implementation-wise, this is because clang-format only recognizes a hardcoded set of string literal encodings to be breakable:
llvm-project/clang/lib/Format/ContinuationIndenter.cpp
Lines 2520 to 2527 in 9d1b6ee
| if ((Text.ends_with(Postfix = "\"") && | |
| (Text.starts_with(Prefix = "@\"") || Text.starts_with(Prefix = "\"") || | |
| Text.starts_with(Prefix = "u\"") || | |
| Text.starts_with(Prefix = "U\"") || | |
| Text.starts_with(Prefix = "u8\"") || | |
| Text.starts_with(Prefix = "L\""))) || | |
| (Text.starts_with(Prefix = "_T(\"") && | |
| Text.ends_with(Postfix = "\")"))) { |