diff options
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 //----------------------------------------------------------------------------// |