From 0093b3c7bf201f6d426bc1c39fddc2e29b388b2c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 5 Dec 2011 16:33:54 +0000 Subject: 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). llvm-svn: 145808 --- clang/lib/Lex/ModuleMap.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 84f7bec..b20ccd1 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/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 //----------------------------------------------------------------------------// -- cgit v1.1