Rename the -cc1 option "-generate-module-index" to
"-fmodules-global-index" and expand its behavior to include both the
use and generation of the global module index.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173404 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 4b642b3..05064fb 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -382,10 +382,9 @@
   else ExecuteAction();
 
   // If we are supposed to rebuild the global module index, do so now unless
-  // an error occurred.
-  if (CI.getBuildGlobalModuleIndex() && CI.hasFileManager() &&
-      CI.hasPreprocessor() &&
-      (!CI.hasDiagnostics() || !CI.getDiagnostics().hasErrorOccurred())) {
+  // there were any module-build failures.
+  if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
+      CI.hasPreprocessor()) {
     GlobalModuleIndex::writeIndex(
       CI.getFileManager(),
       CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath());