diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2025-09-10 15:29:26 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2025-09-10 15:56:04 -0700 |
commit | 55bef46146f05e1911fcb98715716d914efd518c (patch) | |
tree | 32aa1c460b4c4f4b4fc42b4abb87bf277d3cec7f /clang/lib/Frontend/CompilerInstance.cpp | |
parent | d7318ebe9338cd2d4cd4023bd308d981b5e01ece (diff) | |
download | llvm-55bef46146f05e1911fcb98715716d914efd518c.zip llvm-55bef46146f05e1911fcb98715716d914efd518c.tar.gz llvm-55bef46146f05e1911fcb98715716d914efd518c.tar.bz2 |
Reland "[clang] Delay normalization of `-fmodules-cache-path` (#150123)"
This reverts commit 613caa909c78f707e88960723c6a98364656a926, essentially
reapplying 4a4bddec3571d78c8073fa45b57bbabc8796d13d after moving
`normalizeModuleCachePath` from clangFrontend to clangLex.
This PR is part of an effort to remove file system usage from the
command line parsing code. The reason for that is that it's impossible
to do file system access correctly without a configured VFS, and the VFS
can only be configured after the command line is parsed. I don't want to
intertwine command line parsing and VFS configuration, so I decided to
perform the file system access after the command line is parsed and the
VFS is configured - ideally right before the file system entity is used
for the first time.
This patch delays normalization of the module cache path until
`CompilerInstance` is asked for the cache path in the current
compilation context.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 8d1e9d6..31a8d75 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -554,9 +554,16 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { } std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) { + assert(FileMgr && "Specific module cache path requires a FileManager"); + + if (getHeaderSearchOpts().ModuleCachePath.empty()) + return ""; + // Set up the module path, including the hash for the module-creation options. - SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath); - if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash) + SmallString<256> SpecificModuleCache; + normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath, + SpecificModuleCache); + if (!getHeaderSearchOpts().DisableModuleHash) llvm::sys::path::append(SpecificModuleCache, ModuleHash); return std::string(SpecificModuleCache); } |