[clang][deps] Canonicalize module map path
authorBen Langmuir <blangmuir@apple.com>
Thu, 29 Sep 2022 23:04:38 +0000 (16:04 -0700)
committerBen Langmuir <blangmuir@apple.com>
Wed, 5 Oct 2022 22:42:38 +0000 (15:42 -0700)
commit074fcec1eabfc992c46c95df215b1caf5cf58970
tree7fcfcd5cb3de12e4584a39ca6c951e956de64acf
parentff7a2b60555a28754b9513b78c5a6b4678b6656f
[clang][deps] Canonicalize module map path

When dep-scanning, canonicalize the module map path as much as we can.
This avoids unnecessarily needing to build multiple versions of a module
due to symlinks or case-insensitive file paths.

Despite the name `tryGetRealPathName`, the previous implementation did
not actually return the realpath most of the time, and indeed it would
be incorrect to do so since the realpath could be outside the module
directory, which would have broken finding headers relative to the
module.

Instead, use a canonicalization that is specific to the needs of
modulemap files (canonicalize the directory separately from the
filename).

Differential Revision: https://reviews.llvm.org/D134923
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-symlink-dir.c [new file with mode: 0644]