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 | 0093b3c7bf201f6d426bc1c39fddc2e29b388b2c (patch) | |
tree | 4e2b883989338602da3cd525524da11179f40d68 /clang/lib/Lex/ModuleMap.cpp | |
parent | e6efe405de108e6a3cb13b01d4919d84a082cdd3 (diff) | |
download | bcm5719-llvm-0093b3c7bf201f6d426bc1c39fddc2e29b388b2c.tar.gz bcm5719-llvm-0093b3c7bf201f6d426bc1c39fddc2e29b388b2c.zip |
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
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 84f7bec9192..b20ccd122f5 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 //----------------------------------------------------------------------------// |