[clang] [Clang][Preprocessor] Unify header-name lookahead for import and include (PR #191004)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 3 13:57:03 PDT 2026
================
@@ -4695,11 +4696,17 @@ bool Lexer::LexDependencyDirectiveToken(Token &Result) {
MIOpt.ReadToken();
}
- if (ParsingFilename && DDTok.is(tok::less)) {
- BufferPtr = BufferStart + DDTok.Offset;
- LexAngledStringLiteral(Result, BufferPtr + 1);
- if (Result.isNot(tok::header_name))
+ const char *DDTokPtr = BufferStart + DDTok.Offset;
+ if (ParsingFilename && *DDTokPtr == '<') {
----------------
zygoloid wrote:
What happens if the `<` is immediately after an escaped newline? Eg:
```
... \
<foo>
```
I *think* we use the location of the `\` as the `DDTok.Offset` in this case. Worth adding a testcase. If it fails, this would be the fix:
```suggestion
const char *DDTokPtr = SkipEscapedNewLines(BufferStart + DDTok.Offset);
if (ParsingFilename && *DDTokPtr == '<') {
```
https://github.com/llvm/llvm-project/pull/191004
More information about the cfe-commits
mailing list