[cfe-commits] r169027 - in /cfe/trunk: include/clang/Serialization/ModuleManager.h lib/Serialization/ASTReader.cpp lib/Serialization/ModuleManager.cpp
Douglas Gregor
dgregor at apple.com
Fri Nov 30 11:28:06 PST 2012
Author: dgregor
Date: Fri Nov 30 13:28:05 2012
New Revision: 169027
URL: http://llvm.org/viewvc/llvm-project?rev=169027&view=rev
Log:
Actually keep track of the source locations at which particular module
files are loaded.
Modified:
cfe/trunk/include/clang/Serialization/ModuleManager.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
Modified: cfe/trunk/include/clang/Serialization/ModuleManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=169027&r1=169026&r2=169027&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ModuleManager.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleManager.h Fri Nov 30 13:28:05 2012
@@ -92,6 +92,8 @@
///
/// \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 @@
/// \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);
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=169027&r1=169026&r2=169027&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Nov 30 13:28:05 2012
@@ -2818,8 +2818,9 @@
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.
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=169027&r1=169026&r2=169027&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Fri Nov 30 13:28:05 2012
@@ -34,9 +34,9 @@
}
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 @@
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 @@
ModuleEntry->ImportedBy.insert(ImportedBy);
ImportedBy->Imports.insert(ModuleEntry);
} else {
+ if (!ModuleEntry->DirectlyImported)
+ ModuleEntry->ImportLoc = ImportLoc;
+
ModuleEntry->DirectlyImported = true;
}
More information about the cfe-commits
mailing list