File tree Expand file tree Collapse file tree 4 files changed +27
-12
lines changed
Tooling/DependencyScanning Expand file tree Collapse file tree 4 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -546,14 +546,11 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
546546std::string CompilerInstance::getSpecificModuleCachePath (StringRef ModuleHash) {
547547 assert (FileMgr && " Specific module cache path requires a FileManager" );
548548
549- if (getHeaderSearchOpts ().ModuleCachePath .empty ())
550- return " " ;
551-
552549 // Set up the module path, including the hash for the module-creation options.
553550 SmallString<256 > SpecificModuleCache;
554551 normalizeModuleCachePath (*FileMgr, getHeaderSearchOpts ().ModuleCachePath ,
555552 SpecificModuleCache);
556- if (!getHeaderSearchOpts ().DisableModuleHash )
553+ if (!SpecificModuleCache. empty () && ! getHeaderSearchOpts ().DisableModuleHash )
557554 llvm::sys::path::append (SpecificModuleCache, ModuleHash);
558555 return std::string (SpecificModuleCache);
559556}
Original file line number Diff line number Diff line change @@ -2186,6 +2186,8 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
21862186void 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}
Original file line number Diff line number Diff line change @@ -524,13 +524,12 @@ bool initializeScanCompilerInstance(
524524 // Use the dependency scanning optimized file system if requested to do so.
525525 if (DepFS) {
526526 DepFS->resetBypassedPathPrefix ();
527- if (!ScanInstance. getHeaderSearchOpts (). ModuleCachePath . empty ()) {
528- SmallString< 256 > ModulesCachePath;
529- normalizeModuleCachePath (
530- ScanInstance. getFileManager (),
531- ScanInstance. getHeaderSearchOpts (). ModuleCachePath , ModulesCachePath);
527+ SmallString< 256 > ModulesCachePath;
528+ normalizeModuleCachePath (ScanInstance. getFileManager (),
529+ ScanInstance. getHeaderSearchOpts (). ModuleCachePath ,
530+ ModulesCachePath);
531+ if (!ModulesCachePath. empty ())
532532 DepFS->setBypassedPathPrefix (ModulesCachePath);
533- }
534533
535534 ScanInstance.setDependencyDirectivesGetter (
536535 std::make_unique<ScanningDependencyDirectivesGetter>(
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments