]> granicus.if.org Git - clang/commitdiff
Actually keep track of the source locations at which particular module
authorDouglas Gregor <dgregor@apple.com>
Fri, 30 Nov 2012 19:28:05 +0000 (19:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 30 Nov 2012 19:28:05 +0000 (19:28 +0000)
files are loaded.

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

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

index 6dcaa210d2d8b878e13e184f7a25bc755ea6af75..1e23ca2d687564bc593f2ed84ff8b346772b434d 100644 (file)
@@ -92,6 +92,8 @@ public:
   ///
   /// \param Type The kind of module being loaded.
   ///
+  /// \param ImportLoc The location at which the module is imported.
+  ///
   /// \param ImportedBy The module that is importing this module, or NULL if
   /// this module is imported directly by the user.
   ///
@@ -103,8 +105,9 @@ public:
   /// \return A pointer to the module that corresponds to this file name,
   /// and a boolean indicating whether the module was newly added.
   std::pair<ModuleFile *, bool> 
-  addModule(StringRef FileName, ModuleKind Type, ModuleFile *ImportedBy,
-            unsigned Generation, std::string &ErrorStr);
+  addModule(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc,
+            ModuleFile *ImportedBy, unsigned Generation,
+            std::string &ErrorStr);
 
   /// \brief Remove the given set of modules.
   void removeModules(ModuleIterator first, ModuleIterator last);
index ffed8356c90a8d3fbd3a48c506269e2e194c305e..c1428d5c68bfdaa057394d5b5b3b262f46ea1edc 100644 (file)
@@ -2818,8 +2818,9 @@ ASTReader::ReadASTCore(StringRef FileName,
   ModuleFile *M;
   bool NewModule;
   std::string ErrorStr;
-  llvm::tie(M, NewModule) = ModuleMgr.addModule(FileName, Type, ImportedBy,
-                                                CurrentGeneration, ErrorStr);
+  llvm::tie(M, NewModule) = ModuleMgr.addModule(FileName, Type, ImportLoc,
+                                                ImportedBy, CurrentGeneration,
+                                                ErrorStr);
 
   if (!M) {
     // We couldn't load the module.
index efe442101bb61a0a1a4c09042a5f50b2108acb81..d5a0a28bdb05dff0a390a35c20b7f21748a3cabb 100644 (file)
@@ -34,9 +34,9 @@ llvm::MemoryBuffer *ModuleManager::lookupBuffer(StringRef Name) {
 }
 
 std::pair<ModuleFile *, bool>
-ModuleManager::addModule(StringRef FileName, ModuleKind Type, 
-                         ModuleFile *ImportedBy, unsigned Generation,
-                         std::string &ErrorStr) {
+ModuleManager::addModule(StringRef FileName, ModuleKind Type,
+                         SourceLocation ImportLoc, ModuleFile *ImportedBy,
+                         unsigned Generation, std::string &ErrorStr) {
   const FileEntry *Entry = FileMgr.getFile(FileName);
   if (!Entry && FileName != "-") {
     ErrorStr = "file not found";
@@ -51,10 +51,11 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
     ModuleFile *New = new ModuleFile(Type, Generation);
     New->FileName = FileName.str();
     New->File = Entry;
+    New->ImportLoc = ImportLoc;
     Chain.push_back(New);
     NewModule = true;
     ModuleEntry = New;
-    
+
     // Load the contents of the module
     if (llvm::MemoryBuffer *Buffer = lookupBuffer(FileName)) {
       // The buffer was already provided for us.
@@ -82,6 +83,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
     ModuleEntry->ImportedBy.insert(ImportedBy);
     ImportedBy->Imports.insert(ModuleEntry);
   } else {
+    if (!ModuleEntry->DirectlyImported)
+      ModuleEntry->ImportLoc = ImportLoc;
+    
     ModuleEntry->DirectlyImported = true;
   }