diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-05 16:33:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-05 16:33:54 +0000 |
commit | 55988680ece66b8e505ee136b35e74fcb1173aee (patch) | |
tree | 98b942dc721f88d21eeda306df4a7af70a04db12 /lib/Lex/ModuleMap.cpp | |
parent | 5460ff35ab748860f05aeea4685cd195153dca66 (diff) |
When writing a module file, keep track of the set of (sub)modules that
it imports, establishing dependencies at the (sub)module
granularity. This is not a user-visible change (yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/ModuleMap.cpp')
-rw-r--r-- | lib/Lex/ModuleMap.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index 84f7bec919..b20ccd122f 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -238,6 +238,26 @@ bool ModuleMap::resolveExports(Module *Mod, bool Complain) { return HadError; } +Module *ModuleMap::inferModuleFromLocation(FullSourceLoc Loc) { + if (Loc.isInvalid()) + return 0; + + // Use the expansion location to determine which module we're in. + FullSourceLoc ExpansionLoc = Loc.getExpansionLoc(); + if (!ExpansionLoc.isFileID()) + return 0; + + + const SourceManager &SrcMgr = Loc.getManager(); + FileID ExpansionFileID = ExpansionLoc.getFileID(); + const FileEntry *ExpansionFile = SrcMgr.getFileEntryForID(ExpansionFileID); + if (!ExpansionFile) + return 0; + + // Find the module that owns this header. + return findModuleForHeader(ExpansionFile); +} + //----------------------------------------------------------------------------// // Module map file parser //----------------------------------------------------------------------------// |