[clang] [C++][Modules][Preprocessor] Clang should not convert a import preprocessing token to contextual keyword if a digraph character following import (PR #191004)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 13:32:42 PDT 2026


https://github.com/zygoloid requested changes to this pull request.

Sorry, this is fundamentally the wrong approach. When `import` is followed by `<`, we should attempt to form a *header-name* token. For example,
```c++
import <:foo:>;
```
is an import directive; the `<:foo:>` should be lexed as a single token. It doesn't matter if the character after the `<` is a `:` or something else.

Instead, we should not recognize a line starting with `import` as an import directive if it's followed by a `<:` token. We also get this wrong for `#include`, for example Clang allows the invalid:
```c++
#define FOO foo>
#include <:FOO
```
if the file `:foo` exists, but should instead reject because *header-name-tokens* is required to start with a `<` token, not a `<:` token.

https://github.com/llvm/llvm-project/pull/191004


More information about the cfe-commits mailing list