<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63252>63252</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang can occasionally, flakily find `#include`d files that don't exist on disk when using `-fmodules-embed-all-files`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zygoloid
</td>
</tr>
</table>
<pre>
When files are embedded into an AST file, and then the corresponding `SLocEntry` gets lazily loaded from that AST file, we register the file from the AST file with the `FileManager` so that we can override its contents. But this causes flaky behavior if the file doesn't actually exist on disk: a `#include` that names that file in *just the right way* will work. Eg:
- The AST file contains an embedded copy of `foo/bar.h`, which doesn't exist on disk.
- For some reason, we load in an `SLocEntry` referring to that file. This can happen in very subtle and fragile ways, eg due to #63228.
- Loading that file registers it with `FileManager` and overrides its contents.
- A later `#include "bar.h"` will work, if we have `-iquote foo`, because we'll look for `foo/bar.h` and the `FileManager` will produce one.
- But a later `#include "bar.h"` will *not* work if we have `-iquote ./foo`, and similarly `#include "foo/bar.h"` will not work if we have `-iquote .`, because `./foo/bar.h` is *not* registered with `FileManager`. (If the file exists on disk, these file names work because we map them to the same `FileEntry`, whose contents are overridden.)
Perhaps we shouldn't associate the virtual file the a file name in `FileManager::SeenFileEntries` in this case, so that later queries for the same file name will still go to disk and fail? (I think we still need to create a virtual file so that we can override its contents and provide a corresponding `FileEntry`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVV-P4roP_TThxaJq06EDDzywM4v0k_YnXWlGus-mcdssacImKVz20185pfwRu1f7UlCT2sfnHNsYgm4t0VosvojF-wyH2Dm__nlunXFazXZOndd_d2Sh0YYCoCegfkdKkQJtowO0sPn4TMdCvgFaBZHvx46gdt5TODirtG1BVPnHN1d_tdGfRZVDSzGAwZ_anME45IiNdz3EDuNDzBOBp1aHSD6F5ffTVbrehJOOXXoj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