[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 24 07:51:18 PDT 2025
================
@@ -1295,13 +1305,18 @@ FormatToken *FormatTokenLexer::getNextToken() {
case '/':
// The text was entirely whitespace when this loop was entered. Thus
// this has to be an escape sequence.
- assert(Text.substr(i, 2) == "\\\r" || Text.substr(i, 2) == "\\\n" ||
- Text.substr(i, 4) == "\?\?/\r" ||
+ assert(Text.substr(i, 4) == "\?\?/\r" ||
Text.substr(i, 4) == "\?\?/\n" ||
(i >= 1 && (Text.substr(i - 1, 4) == "\?\?/\r" ||
Text.substr(i - 1, 4) == "\?\?/\n")) ||
(i >= 2 && (Text.substr(i - 2, 4) == "\?\?/\r" ||
- Text.substr(i - 2, 4) == "\?\?/\n")));
+ Text.substr(i - 2, 4) == "\?\?/\n")) ||
+ (Text[i] == '\\' && [&]() -> bool {
+ size_t j = i + 1;
+ while (j < Text.size() && isHorizontalWhitespace(Text[j]))
+ ++j;
+ return j < Text.size() && (Text[j] == '\n' || Text[j] == '\r');
+ }()));
----------------
naveen-seth wrote:
The latest commit (ed80aca), which addresses the other feedback, doesn’t change anything here. I’m also having trouble understanding this, so I’ll wait for @sstwcw’s input.
https://github.com/llvm/llvm-project/pull/145243
More information about the cfe-commits
mailing list