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 @@ -565,14 +565,11 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
565565std::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}
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 @@ -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>(
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