]> granicus.if.org Git - clang/commitdiff
Set the file entry for a Module* that was created during deserialization
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 3 Oct 2012 01:58:42 +0000 (01:58 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 3 Oct 2012 01:58:42 +0000 (01:58 +0000)
of a module file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165086 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/Module.h
include/clang/Serialization/ModuleManager.h
lib/Serialization/ASTReader.cpp
lib/Serialization/Module.cpp
lib/Serialization/ModuleManager.cpp

index 653fe222b64f3935810ecec9fb865c6e6d72f817..87a0e40e9e90f83fd491abf0d42f3c7272ac4dca 100644 (file)
@@ -25,6 +25,7 @@
 
 namespace clang {
 
+class FileEntry;
 class DeclContext;
 class Module;
 template<typename Info> class OnDiskChainedHashTable;
@@ -74,6 +75,9 @@ public:
   /// \brief The file name of the module file.
   std::string FileName;
 
+  /// \brief The file entry for the module file.
+  const FileEntry *File;
+
   /// \brief Whether this module has been directly imported by the
   /// user.
   bool DirectlyImported;
index 6ff0640b64d11f05a4b672f6222c070d0295e523..2233eaf828b55b9abc3cd7380bd80c8cca6ed856 100644 (file)
@@ -34,7 +34,7 @@ class ModuleManager {
   
   /// \brief FileManager that handles translating between filenames and
   /// FileEntry *.
-  FileManager FileMgr;
+  FileManager &FileMgr;
   
   /// \brief A lookup of in-memory (virtual file) buffers
   llvm::DenseMap<const FileEntry *, llvm::MemoryBuffer *> InMemoryBuffers;
@@ -45,7 +45,7 @@ public:
   typedef SmallVector<ModuleFile*, 2>::reverse_iterator ModuleReverseIterator;
   typedef std::pair<uint32_t, StringRef> ModuleOffset;
   
-  ModuleManager(const FileSystemOptions &FSO);
+  explicit ModuleManager(FileManager &FileMgr);
   ~ModuleManager();
   
   /// \brief Forward iterator to traverse all loaded modules.  This is reverse
index 3960fa29ce75cfebf91f04c768ed8b4a29a8f6c6..cc6d073b1033a4ce439f8588e262bcddc58a253d 100644 (file)
@@ -3177,6 +3177,7 @@ ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
         return Failure;
       }
       
+      CurrentModule->setASTFile(F.File);
       CurrentModule->IsFromModuleFile = true;
       CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;
       CurrentModule->InferSubmodules = InferSubmodules;
@@ -6497,7 +6498,7 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context,
   : Listener(new PCHValidator(PP, *this)), DeserializationListener(0),
     SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
     Diags(PP.getDiagnostics()), SemaObj(0), PP(PP), Context(Context),
-    Consumer(0), ModuleMgr(FileMgr.getFileSystemOptions()),
+    Consumer(0), ModuleMgr(PP.getFileManager()),
     RelocatablePCH(false), isysroot(isysroot),
     DisableValidation(DisableValidation),
     DisableStatCache(DisableStatCache),
index 5fab02b1fb4da1dcfd6e9adc617a411bf35d9028..a5f709153c7e112e1aabd7fbbdc467777097286a 100644 (file)
@@ -21,7 +21,8 @@ using namespace serialization;
 using namespace reader;
 
 ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)
-  : Kind(Kind), DirectlyImported(false), Generation(Generation), SizeInBits(0), 
+  : Kind(Kind), File(0), DirectlyImported(false),
+    Generation(Generation), SizeInBits(0),
     LocalNumSLocEntries(0), SLocEntryBaseID(0),
     SLocEntryBaseOffset(0), SLocEntryOffsets(0),
     SLocFileOffsets(0), LocalNumIdentifiers(0), 
index ab364b7ebd2c116d73a70a4143c42e0e6fa9c910..c46e9f060831464ebc61ea4691ba8f5008b620cf 100644 (file)
@@ -50,6 +50,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
     // Allocate a new module.
     ModuleFile *New = new ModuleFile(Type, Generation);
     New->FileName = FileName.str();
+    New->File = Entry;
     Chain.push_back(New);
     NewModule = true;
     ModuleEntry = New;
@@ -95,7 +96,7 @@ void ModuleManager::addInMemoryBuffer(StringRef FileName,
   InMemoryBuffers[Entry] = Buffer;
 }
 
-ModuleManager::ModuleManager(const FileSystemOptions &FSO) : FileMgr(FSO) { }
+ModuleManager::ModuleManager(FileManager &FileMgr) : FileMgr(FileMgr) { }
 
 ModuleManager::~ModuleManager() {
   for (unsigned i = 0, e = Chain.size(); i != e; ++i)