Stat system dependencies when using -verify-pch

We don't stat the system headers to check for stalenes during regular
PCH loading for performance reasons.  When explicitly saying
-verify-pch, we want to check all the dependencies - user or system.

llvm-svn: 200979
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index d8381a8..d121180 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -292,14 +292,12 @@
 void CompilerInstance::createPCHExternalASTSource(StringRef Path,
                                                   bool DisablePCHValidation,
                                                 bool AllowPCHWithCompilerErrors,
-                                                bool AllowConfigurationMismatch,
                                                  void *DeserializationListener){
   OwningPtr<ExternalASTSource> Source;
   bool Preamble = getPreprocessorOpts().PrecompiledPreambleBytes.first != 0;
   Source.reset(createPCHExternalASTSource(Path, getHeaderSearchOpts().Sysroot,
                                           DisablePCHValidation,
                                           AllowPCHWithCompilerErrors,
-                                          AllowConfigurationMismatch,
                                           getPreprocessor(), getASTContext(),
                                           DeserializationListener,
                                           Preamble,
@@ -313,7 +311,6 @@
                                              const std::string &Sysroot,
                                              bool DisablePCHValidation,
                                              bool AllowPCHWithCompilerErrors,
-                                             bool AllowConfigurationMismatch,
                                              Preprocessor &PP,
                                              ASTContext &Context,
                                              void *DeserializationListener,
@@ -324,7 +321,8 @@
                              Sysroot.empty() ? "" : Sysroot.c_str(),
                              DisablePCHValidation,
                              AllowPCHWithCompilerErrors,
-                             AllowConfigurationMismatch,
+                             /*AllowConfigurationMismatch*/false,
+                             /*ValidateSystemInputs*/false,
                              UseGlobalModuleIndex));
 
   Reader->setDeserializationListener(
@@ -333,9 +331,7 @@
                           Preamble ? serialization::MK_Preamble
                                    : serialization::MK_PCH,
                           SourceLocation(),
-                          AllowConfigurationMismatch
-                            ? ASTReader::ARR_ConfigurationMismatch
-                            : ASTReader::ARR_None)) {
+                          ASTReader::ARR_None)) {
   case ASTReader::Success:
     // Set the predefines buffer as suggested by the PCH reader. Typically, the
     // predefines buffer will be empty.
@@ -1165,6 +1161,7 @@
                                     PPOpts.DisablePCHValidation,
                                     /*AllowASTWithCompilerErrors=*/false,
                                     /*AllowConfigurationMismatch=*/false,
+                                    /*ValidateSystemInputs=*/false,
                                     getFrontendOpts().UseGlobalModuleIndex);
       if (hasASTConsumer()) {
         ModuleManager->setDeserializationListener(
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 13a0787..0baf3e5 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -314,7 +314,6 @@
                                 CI.getPreprocessorOpts().ImplicitPCHInclude,
                                 CI.getPreprocessorOpts().DisablePCHValidation,
                             CI.getPreprocessorOpts().AllowPCHWithCompilerErrors,
-                            /*AllowConfigurationMismatch*/false,
                                 DeserialListener);
       if (!CI.getASTContext().getExternalSource())
         goto failure;
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 8b17460..27124ca 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -326,11 +326,22 @@
 }
 
 void VerifyPCHAction::ExecuteAction() {
-  getCompilerInstance().
-    createPCHExternalASTSource(getCurrentFile(), /*DisablePCHValidation*/false,
-                               /*AllowPCHWithCompilerErrors*/false,
-                               /*AllowConfigurationMismatch*/true,
-                               /*DeserializationListener*/0);
+  CompilerInstance &CI = getCompilerInstance();
+  bool Preamble = CI.getPreprocessorOpts().PrecompiledPreambleBytes.first != 0;
+  const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
+  OwningPtr<ASTReader> Reader(new ASTReader(
+    CI.getPreprocessor(), CI.getASTContext(),
+    Sysroot.empty() ? "" : Sysroot.c_str(),
+    /*DisableValidation*/false,
+    /*AllowPCHWithCompilerErrors*/false,
+    /*AllowConfigurationMismatch*/true,
+    /*ValidateSystemInputs*/true));
+
+  Reader->ReadAST(getCurrentFile(),
+                  Preamble ? serialization::MK_Preamble
+                           : serialization::MK_PCH,
+                  SourceLocation(),
+                  ASTReader::ARR_ConfigurationMismatch);
 }
 
 namespace {