Skip to content

Commit 700f71b

Browse files
author
git apple-llvm automerger
committed
Merge commit '1ab6c0d60c52' from llvm.org/main into next
2 parents 8b6d366 + 1ab6c0d commit 700f71b

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,11 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
565565
std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) {
566566
assert(FileMgr && "Specific module cache path requires a FileManager");
567567

568-
if (getHeaderSearchOpts().ModuleCachePath.empty())
569-
return "";
570-
571568
// Set up the module path, including the hash for the module-creation options.
572569
SmallString<256> SpecificModuleCache;
573570
normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath,
574571
SpecificModuleCache);
575-
if (!getHeaderSearchOpts().DisableModuleHash)
572+
if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
576573
llvm::sys::path::append(SpecificModuleCache, ModuleHash);
577574
return std::string(SpecificModuleCache);
578575
}

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,8 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
21862186
void clang::normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
21872187
SmallVectorImpl<char> &NormalizedPath) {
21882188
NormalizedPath.assign(Path.begin(), Path.end());
2189-
FileMgr.makeAbsolutePath(NormalizedPath);
2190-
llvm::sys::path::remove_dots(NormalizedPath);
2189+
if (!NormalizedPath.empty()) {
2190+
FileMgr.makeAbsolutePath(NormalizedPath);
2191+
llvm::sys::path::remove_dots(NormalizedPath);
2192+
}
21912193
}

clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,12 @@ bool initializeScanCompilerInstance(
676676
// Use the dependency scanning optimized file system if requested to do so.
677677
if (DepFS) {
678678
DepFS->resetBypassedPathPrefix();
679-
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
680-
SmallString<256> ModulesCachePath;
681-
normalizeModuleCachePath(
682-
ScanInstance.getFileManager(),
683-
ScanInstance.getHeaderSearchOpts().ModuleCachePath, ModulesCachePath);
679+
SmallString<256> ModulesCachePath;
680+
normalizeModuleCachePath(ScanInstance.getFileManager(),
681+
ScanInstance.getHeaderSearchOpts().ModuleCachePath,
682+
ModulesCachePath);
683+
if (!ModulesCachePath.empty())
684684
DepFS->setBypassedPathPrefix(ModulesCachePath);
685-
}
686685

687686
ScanInstance.setDependencyDirectivesGetter(
688687
std::make_unique<ScanningDependencyDirectivesGetter>(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This test checks that explicitly building the same module from different
2+
// working directories results in the same PCM contents.
3+
4+
// RUN: rm -rf %t
5+
// RUN: split-file %s %t
6+
// RUN: mkdir %t/one
7+
// RUN: mkdir %t/two
8+
9+
//--- module.modulemap
10+
module M { header "M.h" }
11+
12+
//--- M.h
13+
14+
// RUN: cd %t/one && %clang_cc1 -fmodules -emit-module %t/module.modulemap -fmodule-name=M -o %t/M_one.pcm
15+
// RUN: cd %t/two && %clang_cc1 -fmodules -emit-module %t/module.modulemap -fmodule-name=M -o %t/M_two.pcm
16+
17+
// RUN: diff %t/M_one.pcm %t/M_two.pcm

0 commit comments

Comments
 (0)