[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 2 06:41:48 PDT 2025
================
@@ -393,7 +393,7 @@ static bool isQuoteCppDigitSeparator(const char *const Start,
}
void Scanner::skipLine(const char *&First, const char *const End) {
----------------
naveen-seth wrote:
My bad! The bug was introduced because I initialized `char LastNonWhitespace = ' ';` one scope too far out.
This can cause `LastNonWhitespace` to not be reset (it remains `'\'`), which then results in an additional line being skipped.
To fix this bug, the only change needed is to move it one scope down, into the for loop:
```cpp
void Scanner::skipLine(const char *&First, const char *const End) {
for (;;) {
assert(First <= End);
if (First == End)
return;
if (isVerticalWhitespace(*First)) {
skipNewline(First, End);
return;
}
const char *Start = First;
char LastNonWhitespace = ' ';
while (First != End && !isVerticalWhitespace(*First)) {
```
https://github.com/llvm/llvm-project/pull/146645
More information about the cfe-commits
mailing list