If we already have a definition for a top-level module that we deserialized from a module file, don't bother parsing a new definition

llvm-svn: 147574
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 42257f5..6c13938 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -790,6 +790,19 @@
   
   // Determine whether this (sub)module has already been defined.
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
+    if (Existing->DefinitionLoc.isInvalid() && !ActiveModule) {
+      // Skip the module definition.
+      skipUntil(MMToken::RBrace);
+      if (Tok.is(MMToken::RBrace))
+        consumeToken();
+      else {
+        Diags.Report(Tok.getLocation(), diag::err_mmap_expected_rbrace);
+        Diags.Report(LBraceLoc, diag::note_mmap_lbrace_match);
+        HadError = true;        
+      }
+      return;
+    }
+    
     Diags.Report(ModuleNameLoc, diag::err_mmap_module_redefinition)
       << ModuleName;
     Diags.Report(Existing->DefinitionLoc, diag::note_mmap_prev_definition);