diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-30 04:26:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-30 04:26:53 +0000 |
commit | b514c792821a8f053027d88444e13bfaa8efef76 (patch) | |
tree | 123cd461e4098e78e066dcef4281686d30674fa5 /lib/Frontend/CompilerInstance.cpp | |
parent | 49009ec701feb3009450e57e40c656e2ad7c1f41 (diff) |
Teach the preprocessor how to handle module import declarations that
involve submodules (e.g., importing std.vector), rather than always
importing the top-level module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index dfc98e8bfb..66b381e522 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -1070,6 +1070,12 @@ static void compileModule(CompilerInstance &ImportingInstance, ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, ModuleIdPath Path) { + // If we've already handled this import, just return the cached result. + // This one-element cache is important to eliminate redundant diagnostics + // when both the preprocessor and parser see the same import declaration. + if (!ImportLoc.isInvalid() && LastModuleImportLoc == ImportLoc) + return LastModuleImportResult.getOpaqueValue(); + // Determine what file we're searching from. SourceManager &SourceMgr = getSourceManager(); SourceLocation ExpandedImportLoc = SourceMgr.getExpansionLoc(ImportLoc); @@ -1241,6 +1247,8 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, // FIXME: The module file's FileEntry makes a poor key indeed! Once we // eliminate the need for FileEntry here, the module itself will become the // key (which does make sense). + LastModuleImportLoc = ImportLoc; + LastModuleImportResult = Known; return Known.getOpaqueValue(); } |