r174744 - Never cache the result of a module file lookup.

Douglas Gregor dgregor at apple.com
Fri Feb 8 13:27:45 PST 2013


Author: dgregor
Date: Fri Feb  8 15:27:45 2013
New Revision: 174744

URL: http://llvm.org/viewvc/llvm-project?rev=174744&view=rev
Log:
Never cache the result of a module file lookup.

Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
    cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=174744&r1=174743&r2=174744&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Feb  8 15:27:45 2013
@@ -996,7 +996,8 @@ CompilerInstance::loadModule(SourceLocat
 
       BuildingModule = true;
       compileModule(*this, ModuleNameLoc, Module, ModuleFileName);
-      ModuleFile = FileMgr->getFile(ModuleFileName);
+      ModuleFile = FileMgr->getFile(ModuleFileName, /*OpenFile=*/false,
+                                    /*CacheFailure=*/false);
 
       if (!ModuleFile && getPreprocessorOpts().FailedModules)
         getPreprocessorOpts().FailedModules->addFailed(ModuleName);
@@ -1079,14 +1080,14 @@ CompilerInstance::loadModule(SourceLocat
           << ModuleName
           << SourceRange(ImportLoc, ModuleNameLoc);
         ModuleBuildFailed = true;
-
         return ModuleLoadResult();
       }
 
       compileModule(*this, ModuleNameLoc, Module, ModuleFileName);
 
       // Try loading the module again.
-      ModuleFile = FileMgr->getFile(ModuleFileName);
+      ModuleFile = FileMgr->getFile(ModuleFileName, /*OpenFile=*/false,
+                                    /*CacheFailure=*/false);
       if (!ModuleFile ||
           ModuleManager->ReadAST(ModuleFileName,
                                  serialization::MK_Module, ImportLoc,

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=174744&r1=174743&r2=174744&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Fri Feb  8 15:27:45 2013
@@ -203,7 +203,8 @@ GlobalModuleIndex::GlobalModuleIndex(Fil
         Dependencies(Record.begin() + Idx, Record.begin() + Idx + NumDeps);
 
       // Find the file. If we can't find it, ignore it.
-      const FileEntry *File = FileMgr.getFile(FileName);
+      const FileEntry *File = FileMgr.getFile(FileName, /*openFile=*/false,
+                                              /*cacheFailure=*/false);
       if (!File) {
         AnyOutOfDate = true;
         break;
@@ -635,7 +636,9 @@ bool GlobalModuleIndexBuilder::loadModul
         Idx += Length;
 
         // Find the imported module file.
-        const FileEntry *DependsOnFile = FileMgr.getFile(ImportedFile);
+        const FileEntry *DependsOnFile
+          = FileMgr.getFile(ImportedFile, /*openFile=*/false,
+                            /*cacheFailure=*/false);
         if (!DependsOnFile)
           return true;
 

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=174744&r1=174743&r2=174744&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Fri Feb  8 15:27:45 2013
@@ -25,12 +25,14 @@ using namespace clang;
 using namespace serialization;
 
 ModuleFile *ModuleManager::lookup(StringRef Name) {
-  const FileEntry *Entry = FileMgr.getFile(Name);
+  const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
+                                           /*cacheFailure=*/false);
   return Modules[Entry];
 }
 
 llvm::MemoryBuffer *ModuleManager::lookupBuffer(StringRef Name) {
-  const FileEntry *Entry = FileMgr.getFile(Name);
+  const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
+                                           /*cacheFailure=*/false);
   return InMemoryBuffers[Entry];
 }
 
@@ -38,7 +40,8 @@ std::pair<ModuleFile *, bool>
 ModuleManager::addModule(StringRef FileName, ModuleKind Type,
                          SourceLocation ImportLoc, ModuleFile *ImportedBy,
                          unsigned Generation, std::string &ErrorStr) {
-  const FileEntry *Entry = FileMgr.getFile(FileName);
+  const FileEntry *Entry = FileMgr.getFile(FileName, /*openFile=*/false,
+                                           /*cacheFailure=*/false);
   if (!Entry && FileName != "-") {
     ErrorStr = "file not found";
     return std::make_pair(static_cast<ModuleFile*>(0), false);





More information about the cfe-commits mailing list