summaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-10-23 10:09:50 -0700
committerGitHub <noreply@github.com>2025-10-23 10:09:50 -0700
commit1ab6c0d60c52539b77e1cbfdc7f1ba47ad140b8d (patch)
tree3712e2ff135b6317e56f3d5feb5bd4a20ad96936 /clang/lib/Frontend/CompilerInstance.cpp
parentede9dd3951e29632a29e13b2fd8c4b6b9d185643 (diff)
[clang] Make explicitly-built modules independent of the CWD (#164840)
PR https://github.com/llvm/llvm-project/pull/150123 changed how we normalize the modules cache path. Unfortunately, empty path would get normalized to the current working directory. This means that even explicitly-built PCMs that don't rely on the CWD now embed it, leading to surprising behavior. This PR fixes that by normalizing an empty modules cache path to an empty string.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 374138fe4cf8..e3bf0eaa3c39 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -546,14 +546,11 @@ 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;
normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath,
SpecificModuleCache);
- if (!getHeaderSearchOpts().DisableModuleHash)
+ if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
llvm::sys::path::append(SpecificModuleCache, ModuleHash);
return std::string(SpecificModuleCache);
}