@@ -1075,19 +1075,16 @@ static bool IsFromRootCling() {
10751075 return foundSymbol;
10761076}
10771077
1078- static std::string GetModuleNameAsString (clang::Module *M, const clang::Preprocessor &PP)
1078+ // / Checks if there is an ASTFile on disk for the given module \c M.
1079+ static bool HasASTFileOnDisk (clang::Module *M, const clang::Preprocessor &PP)
10791080{
10801081 const HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo ().getHeaderSearchOpts ();
10811082
10821083 std::string ModuleFileName;
10831084 if (!HSOpts.PrebuiltModulePaths .empty ())
10841085 // Load the module from *only* in the prebuilt module path.
10851086 ModuleFileName = PP.getHeaderSearchInfo ().getModuleFileName (M->Name , /* ModuleMapPath*/ " " , /* UsePrebuiltPath*/ true );
1086- if (ModuleFileName.empty ()) return " " ;
1087-
1088- std::string ModuleName = llvm::sys::path::filename (ModuleFileName);
1089- // Return stem of the filename
1090- return std::string (llvm::sys::path::stem (ModuleName));
1087+ return !ModuleFileName.empty ();
10911088}
10921089
10931090static bool HaveFullGlobalModuleIndex = false ;
@@ -1115,11 +1112,10 @@ static GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc, cling
11151112 bool RecreateIndex = false ;
11161113 for (ModuleMap::module_iterator I = MMap.module_begin (), E = MMap.module_end (); I != E; ++I) {
11171114 Module *TheModule = I->second ;
1118- // We do want the index only of the prebuilt modules
1119- std::string ModuleName = GetModuleNameAsString (TheModule, PP);
1120- if (ModuleName.empty ())
1115+ // We want the index only of the prebuilt modules.
1116+ if (!HasASTFileOnDisk (TheModule, PP))
11211117 continue ;
1122- LoadModule (ModuleName , interp);
1118+ LoadModule (TheModule-> Name , interp);
11231119 RecreateIndex = true ;
11241120 }
11251121 if (RecreateIndex) {
0 commit comments