@@ -829,36 +829,37 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
829
829
OptionValidateNone);
830
830
}
831
831
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.
834
833
// /
835
834
// / \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 ;
853
853
}
854
854
855
855
bool PCHValidator::ReadHeaderSearchOptions (const HeaderSearchOptions &HSOpts,
856
856
StringRef SpecificModuleCachePath,
857
857
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 ());
862
863
}
863
864
864
865
void PCHValidator::ReadCounter (const ModuleFile &M, unsigned Value) {
@@ -5376,9 +5377,9 @@ namespace {
5376
5377
bool ReadHeaderSearchOptions (const HeaderSearchOptions &HSOpts,
5377
5378
StringRef SpecificModuleCachePath,
5378
5379
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);
5382
5383
}
5383
5384
5384
5385
bool ReadPreprocessorOptions (const PreprocessorOptions &PPOpts,
0 commit comments