Eliminate the -chained-pch flag and all of the frontend and libclang options associated with it. Chained PCH is the only way to build a PCH file that includes another PCH file

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138597 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index e16a21e..7c32250 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -824,18 +824,18 @@
    */
   CXTranslationUnit_CacheCompletionResults = 0x08,
   /**
-   * \brief Enable precompiled preambles in C++.
+   * \brief DEPRECATED: Enable precompiled preambles in C++.
    *
    * Note: this is a *temporary* option that is available only while
-   * we are testing C++ precompiled preamble support.
+   * we are testing C++ precompiled preamble support. It is deprecated.
    */
   CXTranslationUnit_CXXPrecompiledPreamble = 0x10,
 
   /**
-   * \brief Enabled chained precompiled preambles in C++.
+   * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
    *
    * Note: this is a *temporary* option that is available only while
-   * we are testing C++ precompiled preamble support.
+   * we are testing C++ precompiled preamble support. It is deprecated.
    */
   CXTranslationUnit_CXXChainedPCH = 0x20,
   
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 2c3bfc0..322aef4 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -412,8 +412,6 @@
 
 def relocatable_pch : Flag<"-relocatable-pch">,
   HelpText<"Whether to build a relocatable precompiled header">;
-def chained_pch : Flag<"-chained-pch">,
-  HelpText<"Whether to chain the new precompiled header to the old one.">;
 def print_stats : Flag<"-print-stats">,
   HelpText<"Print performance metrics and statistics">;
 def ftime_report : Flag<"-ftime-report">,
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 08b626f..190ab85 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -651,8 +651,6 @@
                                       bool PrecompilePreamble = false,
                                       TranslationUnitKind TUKind = TU_Complete,
                                       bool CacheCodeCompletionResults = false,
-                                      bool CXXPrecompilePreamble = false,
-                                      bool CXXChainedPCH = false,
                                       bool NestedMacroExpansions = true);
   
   /// \brief Reparse the source files using the same command-line options that
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 75e3eba..ec75b59 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -59,9 +59,6 @@
   unsigned RelocatablePCH : 1;             ///< When generating PCH files,
                                            /// instruct the AST writer to create
                                            /// relocatable PCH files.
-  unsigned ChainedPCH : 1;                 ///< When generating PCH files,
-                                           /// instruct the AST writer to create
-                                           /// chained PCH files.
   unsigned ShowHelp : 1;                   ///< Show the -help text.
   unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
                                            /// results.
@@ -135,7 +132,6 @@
     ProgramAction = frontend::ParseSyntaxOnly;
     ActionName = "";
     RelocatablePCH = 0;
-    ChainedPCH = 0;
     ShowHelp = 0;
     ShowMacrosInCodeCompletion = 0;
     ShowCodePatternsInCodeCompletion = 0;
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index e3d5636..4a5a29a 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -1354,7 +1354,6 @@
   
   // Tell the compiler invocation to generate a temporary precompiled header.
   FrontendOpts.ProgramAction = frontend::GeneratePCH;
-  FrontendOpts.ChainedPCH = true;
   // FIXME: Generate the precompiled header into memory?
   FrontendOpts.OutputFile = PreamblePCHPath;
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
@@ -1761,8 +1760,6 @@
                                       bool PrecompilePreamble,
                                       TranslationUnitKind TUKind,
                                       bool CacheCodeCompletionResults,
-                                      bool CXXPrecompilePreamble,
-                                      bool CXXChainedPCH,
                                       bool NestedMacroExpansions) {
   if (!Diags.getPtr()) {
     // No diagnostics engine was provided, so create our own diagnostics object
@@ -1805,16 +1802,6 @@
   // Override the resources path.
   CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
 
-  // Check whether we should precompile the preamble and/or use chained PCH.
-  // FIXME: This is a temporary hack while we debug C++ chained PCH.
-  if (CI->getLangOpts().CPlusPlus) {
-    PrecompilePreamble = PrecompilePreamble && CXXPrecompilePreamble;
-    
-    if (PrecompilePreamble && !CXXChainedPCH &&
-        !CI->getPreprocessorOpts().ImplicitPCHInclude.empty())
-      PrecompilePreamble = false;
-  }
-  
   // Create the AST unit.
   llvm::OwningPtr<ASTUnit> AST;
   AST.reset(new ASTUnit(false));
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 763c8a1..aee6908 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -405,8 +405,6 @@
     Res.push_back("-disable-free");
   if (Opts.RelocatablePCH)
     Res.push_back("-relocatable-pch");
-  if (Opts.ChainedPCH)
-    Res.push_back("-chained-pch");
   if (Opts.ShowHelp)
     Res.push_back("-help");
   if (Opts.ShowMacrosInCodeCompletion)
@@ -1271,7 +1269,6 @@
   Opts.OutputFile = Args.getLastArgValue(OPT_o);
   Opts.Plugins = Args.getAllArgValues(OPT_load);
   Opts.RelocatablePCH = Args.hasArg(OPT_relocatable_pch);
-  Opts.ChainedPCH = Args.hasArg(OPT_chained_pch);
   Opts.ShowHelp = Args.hasArg(OPT_help);
   Opts.ShowMacrosInCodeCompletion = Args.hasArg(OPT_code_completion_macros);
   Opts.ShowCodePatternsInCodeCompletion
diff --git a/test/PCH/chain-decls.c b/test/PCH/chain-decls.c
index b3daa4a..f5724c4 100644
--- a/test/PCH/chain-decls.c
+++ b/test/PCH/chain-decls.c
@@ -3,7 +3,7 @@
 
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-decls1.h
-// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1
 // RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
 
diff --git a/test/PCH/chain-ext_vector.c b/test/PCH/chain-ext_vector.c
index 2635070..d99a732 100644
--- a/test/PCH/chain-ext_vector.c
+++ b/test/PCH/chain-ext_vector.c
@@ -3,7 +3,7 @@
 
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-ext_vector1.h
-// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1
 // RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
 
 int test(float4 f4) {
diff --git a/test/PCH/chain-external-defs.c b/test/PCH/chain-external-defs.c
index dd92d8e..7422294 100644
--- a/test/PCH/chain-external-defs.c
+++ b/test/PCH/chain-external-defs.c
@@ -1,6 +1,6 @@
 // Test with pch.
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t1.pch %S/Inputs/chain-external-defs1.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t2.pch %S/Inputs/chain-external-defs2.h -include-pch %t1.pch -chained-pch
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t2.pch %S/Inputs/chain-external-defs2.h -include-pch %t1.pch
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t2.pch -emit-llvm -o %t %s
 // RUN: echo FINI >> %t
 // RUN: FileCheck -input-file=%t -check-prefix=Z %s
diff --git a/test/PCH/chain-macro-override.c b/test/PCH/chain-macro-override.c
index 8e20881..2713e70 100644
--- a/test/PCH/chain-macro-override.c
+++ b/test/PCH/chain-macro-override.c
@@ -3,7 +3,7 @@
 
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h -detailed-preprocessing-record 
-// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -chained-pch -detailed-preprocessing-record 
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -detailed-preprocessing-record 
 // RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
 
 int foo() {
diff --git a/test/PCH/chain-macro.c b/test/PCH/chain-macro.c
index 68b18de..18356f7 100644
--- a/test/PCH/chain-macro.c
+++ b/test/PCH/chain-macro.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-pch -o %t1 -detailed-preprocessing-record %S/Inputs/chain-macro1.h
-// RUN: %clang_cc1 -emit-pch -o %t2 -detailed-preprocessing-record %S/Inputs/chain-macro2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -emit-pch -o %t2 -detailed-preprocessing-record %S/Inputs/chain-macro2.h -include-pch %t1
 // RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
 // RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
 
diff --git a/test/PCH/chain-predecl.m b/test/PCH/chain-predecl.m
index 2b0444e..6723b6f 100644
--- a/test/PCH/chain-predecl.m
+++ b/test/PCH/chain-predecl.m
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-pch -o %t1 %S/chain-predecl.h -x objective-c
-// RUN: %clang_cc1 -emit-pch -o %t2 %s -x objective-c -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -emit-pch -o %t2 %s -x objective-c -include-pch %t1
 
 // Test predeclarations across chained PCH.
 @interface Foo
diff --git a/test/PCH/chain-remap-types.m b/test/PCH/chain-remap-types.m
index a45a79d..7886332 100644
--- a/test/PCH/chain-remap-types.m
+++ b/test/PCH/chain-remap-types.m
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-pch -x objective-c-header -o %t1 %S/Inputs/chain-remap-types1.h
-// RUN: %clang_cc1 -emit-pch -x objective-c-header -o %t2 %S/Inputs/chain-remap-types2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -emit-pch -x objective-c-header -o %t2 %S/Inputs/chain-remap-types2.h -include-pch %t1
 // RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
 
diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m
index 3b19172..c543b71 100644
--- a/test/PCH/chain-selectors.m
+++ b/test/PCH/chain-selectors.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
 
 // RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2
 
 @implementation X
diff --git a/test/PCH/chain-trivial.c b/test/PCH/chain-trivial.c
index c78b0e4..85b1eab 100644
--- a/test/PCH/chain-trivial.c
+++ b/test/PCH/chain-trivial.c
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t1 %S/Inputs/chain-trivial1.h
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 -chained-pch %S/Inputs/chain-trivial2.h
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 %S/Inputs/chain-trivial2.h
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-print -include-pch %t2 %s | FileCheck %s
 // CHECK: struct __va_list_tag {
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 5837e04..c7e492e 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2414,9 +2414,7 @@
 
 unsigned clang_defaultEditingTranslationUnitOptions() {
   return CXTranslationUnit_PrecompiledPreamble | 
-         CXTranslationUnit_CacheCompletionResults |
-         CXTranslationUnit_CXXPrecompiledPreamble |
-         CXTranslationUnit_CXXChainedPCH;
+         CXTranslationUnit_CacheCompletionResults;
 }
   
 CXTranslationUnit
@@ -2467,10 +2465,6 @@
     = (options & CXTranslationUnit_Incomplete)? TU_Prefix : TU_Complete;
   bool CacheCodeCompetionResults
     = options & CXTranslationUnit_CacheCompletionResults;
-  bool CXXPrecompilePreamble
-    = options & CXTranslationUnit_CXXPrecompiledPreamble;
-  bool CXXChainedPCH
-    = options & CXTranslationUnit_CXXChainedPCH;
   
   // Configure the diagnostics.
   DiagnosticOptions DiagOpts;
@@ -2556,8 +2550,6 @@
                                  PrecompilePreamble,
                                  TUKind,
                                  CacheCodeCompetionResults,
-                                 CXXPrecompilePreamble,
-                                 CXXChainedPCH,
                                  NestedMacroExpansions));
 
   if (NumErrors != Diags->getClient()->getNumErrors()) {