[clang] [clang][modules] Guard against bad -fmodule-file mappings (#132059) (PR #133462)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 03:25:07 PDT 2025
naveen-seth wrote:
Hi @ChuanqiXu9, @mpark, @shafik,
For context, here is how this PR would change clang's behavior when replicating the original crash in #132059:
The original crash, where the module `hello` wasn’t mapped to any BMI file, would now display the following:
```bash
clang++ -fmodule-file=std=std.pcm -fmodule-file=std=hello.pcm -stdlib=libc++ -std=c++23 main.ccp
```
```bash
main.cpp:2:8: fatal error: module 'hello' not found
2 | import hello;
| ~~~~~~~^~~~~
1 error generated.
```
When assigning the matching BMI file to `hello`, but the wrong one to `std`:
```bash
clang++ -stdlib=libc++ -std=c++23 -fmodule-file=std=std.pcm -fmodule-file=std=hello.pcm -fmodule-file=hello=hello.pcm main.ccp
```
```bash
main.ccp:2:1: fatal error: tried loading module 'std' from 'hello.pcm' but found module 'hello' instead
2 | import hello;
| ^
main.ccp:2:1: note: imported by module 'hello' in 'hello.pcm'
1 error generated.
```
Would you be able to review the PR?
https://github.com/llvm/llvm-project/pull/133462
More information about the cfe-commits
mailing list