@@ -829,36 +829,37 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
829829 OptionValidateNone);
830830}
831831
832- // / Check the header search options deserialized from the control block
833- // / against the header search options in an existing preprocessor.
832+ // / Check that the specified and the existing module cache paths are equivalent.
834833// /
835834// / \param Diags If non-null, produce diagnostics for any mismatches incurred.
836- static bool checkHeaderSearchOptions (const HeaderSearchOptions &HSOpts,
837- StringRef SpecificModuleCachePath,
838- StringRef ExistingModuleCachePath,
839- DiagnosticsEngine *Diags,
840- const LangOptions &LangOpts,
841- const PreprocessorOptions &PPOpts) {
842- if (LangOpts.Modules ) {
843- if (SpecificModuleCachePath != ExistingModuleCachePath &&
844- !PPOpts.AllowPCHWithDifferentModulesCachePath ) {
845- if (Diags)
846- Diags->Report (diag::err_pch_modulecache_mismatch)
847- << SpecificModuleCachePath << ExistingModuleCachePath;
848- return true ;
849- }
850- }
851-
852- return false ;
835+ // / \returns true when the module cache paths differ.
836+ static bool checkModuleCachePath (llvm::vfs::FileSystem &VFS,
837+ StringRef SpecificModuleCachePath,
838+ StringRef ExistingModuleCachePath,
839+ DiagnosticsEngine *Diags,
840+ const LangOptions &LangOpts,
841+ const PreprocessorOptions &PPOpts) {
842+ if (!LangOpts.Modules || PPOpts.AllowPCHWithDifferentModulesCachePath ||
843+ SpecificModuleCachePath == ExistingModuleCachePath)
844+ return false ;
845+ auto EqualOrErr =
846+ VFS.equivalent (SpecificModuleCachePath, ExistingModuleCachePath);
847+ if (EqualOrErr && *EqualOrErr)
848+ return false ;
849+ if (Diags)
850+ Diags->Report (diag::err_pch_modulecache_mismatch)
851+ << SpecificModuleCachePath << ExistingModuleCachePath;
852+ return true ;
853853}
854854
855855bool PCHValidator::ReadHeaderSearchOptions (const HeaderSearchOptions &HSOpts,
856856 StringRef SpecificModuleCachePath,
857857 bool Complain) {
858- return checkHeaderSearchOptions (HSOpts, SpecificModuleCachePath,
859- PP.getHeaderSearchInfo ().getModuleCachePath (),
860- Complain ? &Reader.Diags : nullptr ,
861- PP.getLangOpts (), PP.getPreprocessorOpts ());
858+ return checkModuleCachePath (Reader.getFileManager ().getVirtualFileSystem (),
859+ SpecificModuleCachePath,
860+ PP.getHeaderSearchInfo ().getModuleCachePath (),
861+ Complain ? &Reader.Diags : nullptr ,
862+ PP.getLangOpts (), PP.getPreprocessorOpts ());
862863}
863864
864865void PCHValidator::ReadCounter (const ModuleFile &M, unsigned Value) {
@@ -5376,9 +5377,9 @@ namespace {
53765377 bool ReadHeaderSearchOptions (const HeaderSearchOptions &HSOpts,
53775378 StringRef SpecificModuleCachePath,
53785379 bool Complain) override {
5379- return checkHeaderSearchOptions (HSOpts, SpecificModuleCachePath,
5380- ExistingModuleCachePath, nullptr ,
5381- ExistingLangOpts, ExistingPPOpts);
5380+ return checkModuleCachePath (
5381+ FileMgr. getVirtualFileSystem (), SpecificModuleCachePath ,
5382+ ExistingModuleCachePath, nullptr , ExistingLangOpts, ExistingPPOpts);
53825383 }
53835384
53845385 bool ReadPreprocessorOptions (const PreprocessorOptions &PPOpts,
0 commit comments