[clang][deps][lex] Avoid canonicalization of remapped framework directories
authorJan Svoboda <jan_svoboda@apple.com>
Fri, 2 Dec 2022 03:09:09 +0000 (19:09 -0800)
committerJan Svoboda <jan_svoboda@apple.com>
Fri, 2 Dec 2022 03:59:54 +0000 (19:59 -0800)
commit935a07ed21434825a96eb6d3acd2163edd0abe88
tree10aa8785ff11ae65a2ae2b396050311962086b8b
parentf9ed86a5fd952864da44c1f51b978e467fc4cdc6
[clang][deps][lex] Avoid canonicalization of remapped framework directories

In D134923, the scanner introduced canonicalization of framework directories when reporting module map paths in order to increase module sharing. However, if we canonicalize framework directory that plays a role in a VFS remapping, and later try to use that module map to build the module, header lookup can fail. This happens when the module headers are remapped using the original framework path.

This patch fixes that. The implementation relies on the fact that the chain of directories in VFS remapping are assigned `DirectoryEntry` objects distinct from their on-disk counterparts. If we detect that case, we avoid the canonicalization.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D135841
clang/lib/Lex/ModuleMap.cpp
clang/test/ClangScanDeps/modules-symlink-dir-vfs.c [new file with mode: 0644]