From 0c6c783d89b0d82ab0e5b0f7c5f7034669578f4e Mon Sep 17 00:00:00 2001
From: Argyrios Kyrtzidis <akyrtzi@gmail.com>
Date: Sat, 17 May 2014 04:35:12 +0000
Subject: [PATCH] [objcmt] Don't wrap a PCH generation action with a
 ObjCMigrateAction one, it messes up the PCH file.

rdar://16941811

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209059 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/FrontendTool/ExecuteCompilerInvocation.cpp |  3 ++-
 test/ARCMT/migrate-on-pch-and-module.m         | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 test/ARCMT/migrate-on-pch-and-module.m

diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 3d7a83d4b38..0d3bd7edac0 100644
--- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -144,7 +144,8 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
 #endif
   
 #ifdef CLANG_ENABLE_ARCMT
-  if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource) {
+  if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource &&
+      CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) {
     // Potentially wrap the base FE action in an ARC Migrate Tool action.
     switch (FEOpts.ARCMTAction) {
     case FrontendOptions::ARCMT_None:
diff --git a/test/ARCMT/migrate-on-pch-and-module.m b/test/ARCMT/migrate-on-pch-and-module.m
new file mode 100644
index 00000000000..59cae3c03a6
--- /dev/null
+++ b/test/ARCMT/migrate-on-pch-and-module.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t-mcp
+// RUN: %clang_cc1 -objcmt-migrate-subscripting -emit-pch -o %t.pch %s -isysroot %S/../Modules/Inputs/System -triple x86_64-apple-darwin10 -F %S/../Modules/Inputs -fmodules -fmodules-cache-path=%t-mcp -w
+// RUN: %clang_cc1 -objcmt-migrate-subscripting -include-pch %t.pch %s -migrate -o %t.remap -isysroot %S/../Modules/Inputs/System -triple x86_64-apple-darwin10 -F %S/../Modules/Inputs -fmodules -fmodules-cache-path=%t-mcp
+
+#ifndef HEADER
+#define HEADER
+
+@import Module;
+
+#else
+
+#endif
-- 
GitLab