Revert "[Modules] Include error diagnostics to the module hash"

This reverts commit 99730af5fb3c765e39cbc85123a2374269daf163.

This broke the bots:
https://ci.swift.org/job/oss-swift-4.0-incremental-RA-linux-ubuntu-16_04/345/
diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index 78a0a20..d2b4827 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -153,7 +153,6 @@
 BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically importing modules as needed when performing error recovery")
 BENIGN_LANGOPT(ImplicitModules, 1, 1, "building modules that are not specified via -fmodule-file")
 COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility")
-COMPATIBLE_LANGOPT(ModulesHashErrorDiags, 1, 0, "hash out diagnostic errors as part of the module hash")
 COMPATIBLE_LANGOPT(Optimize          , 1, 0, "__OPTIMIZE__ predefined macro")
 COMPATIBLE_LANGOPT(OptimizeSize      , 1, 0, "__OPTIMIZE_SIZE__ predefined macro")
 COMPATIBLE_LANGOPT(Static            , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)")
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 6c36410..40eadaf 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -432,8 +432,6 @@
 def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
   HelpText<"Select the container format for clang modules and PCH. "
            "Supported options are 'raw' and 'obj'.">;
-def fmodules_hash_error_diagnostics : Flag<["-"], "fmodules-hash-error-diagnostics">,
-  HelpText<"Make all diagnostics that produce errors to be part of the module hash">;
 def ftest_module_file_extension_EQ :
   Joined<["-"], "ftest-module-file-extension=">,
   HelpText<"introduce a module file extension for testing purposes. "
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index 872cdc2..239991d 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -174,7 +174,7 @@
   
   /// \brief Retrieve a module hash string that is suitable for uniquely 
   /// identifying the conditions under which the module was built.
-  std::string getModuleHash(DiagnosticsEngine &Diags) const;
+  std::string getModuleHash() const;
   
   /// @}
   /// @name Option Subgroups
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index a4b72e0..42f855f 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -472,7 +472,7 @@
   SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath);
   if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
     llvm::sys::path::append(SpecificModuleCache,
-                            getInvocation().getModuleHash(getDiagnostics()));
+                            getInvocation().getModuleHash());
   return SpecificModuleCache.str();
 }
 
@@ -1111,11 +1111,9 @@
   PPOpts.RetainRemappedFileBuffers = true;
     
   Invocation->getDiagnosticOpts().VerifyDiagnostics = 0;
-  assert(ImportingInstance.getInvocation().getModuleHash(
-             ImportingInstance.getDiagnostics()) ==
-             Invocation->getModuleHash(ImportingInstance.getDiagnostics()) &&
-         "Module hash mismatch!");
-
+  assert(ImportingInstance.getInvocation().getModuleHash() ==
+         Invocation->getModuleHash() && "Module hash mismatch!");
+  
   // Construct a compiler instance that will be used to actually create the
   // module.  Since we're sharing a PCMCache,
   // CompilerInstance::CompilerInstance is responsible for finalizing the
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index fc7178a..a63a0d9 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1967,7 +1967,6 @@
       Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
   Opts.ModulesLocalVisibility =
       Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
-  Opts.ModulesHashErrorDiags = Args.hasArg(OPT_fmodules_hash_error_diagnostics);
   Opts.ModulesSearchAll = Opts.Modules &&
     !Args.hasArg(OPT_fno_modules_search_all) &&
     Args.hasArg(OPT_fmodules_search_all);
@@ -2536,14 +2535,7 @@
   return Success;
 }
 
-static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags) {
-  diag::Severity Ext = Diags.getExtensionHandlingBehavior();
-  if (Ext == diag::Severity::Warning && Diags.getWarningsAsErrors())
-    return true;
-  return Ext >= diag::Severity::Error;
-}
-
-std::string CompilerInvocation::getModuleHash(DiagnosticsEngine &Diags) const {
+std::string CompilerInvocation::getModuleHash() const {
   // Note: For QoI reasons, the things we use as a hash here should all be
   // dumped via the -module-info flag.
   using llvm::hash_code;
@@ -2650,30 +2642,6 @@
     }
   }
 
-  // Check for a couple things (see checkDiagnosticMappings in ASTReader.cpp):
-  //  -Werror: consider all warnings into the hash
-  //  -Werror=something: consider only the specified into the hash
-  //  -Weverything
-  //  -Wsystem-headers
-  //  -pedantic-error
-  if (getLangOpts()->ModulesHashErrorDiags) {
-    bool ConsiderAllWarningsAsErrors = Diags.getWarningsAsErrors();
-    code = hash_combine(code, ConsiderAllWarningsAsErrors);
-    code = hash_combine(code, Diags.getEnableAllWarnings());
-    code = hash_combine(code, Diags.getSuppressSystemWarnings());
-    code = hash_combine(code, isExtHandlingFromDiagsError(Diags));
-
-    for (auto DiagIDMappingPair : Diags.getDiagnosticMappings()) {
-      diag::kind DiagID = DiagIDMappingPair.first;
-      auto CurLevel = Diags.getDiagnosticLevel(DiagID, SourceLocation());
-      if (CurLevel < DiagnosticsEngine::Error && !ConsiderAllWarningsAsErrors)
-        continue; // not significant
-      code = hash_combine(
-          code,
-          Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str());
-    }
-  }
-
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }