diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-05 16:37:00 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-05 16:37:00 +0000 |
commit | ed351e6bad7314664385ee948ccec22c94ed326e (patch) | |
tree | beca57e31b92a675e7b3a377ee797b156339d806 /lib/ARCMigrate | |
parent | 3ad86fd2effccf1b9337e8cb9a317e4353cec275 (diff) |
[arcmt] Make sure the objc migrators work fine when used with a PCH.
rdar://13140508
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate')
-rw-r--r-- | lib/ARCMigrate/ARCMT.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index af223a106e..62822846cd 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -18,6 +18,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Sema/SemaDiagnostic.h" +#include "clang/Serialization/ASTReader.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/MemoryBuffer.h" using namespace clang; @@ -174,8 +175,24 @@ static CompilerInvocation * createInvocationForMigration(CompilerInvocation &origCI) { OwningPtr<CompilerInvocation> CInvok; CInvok.reset(new CompilerInvocation(origCI)); - CInvok->getPreprocessorOpts().ImplicitPCHInclude = std::string(); - CInvok->getPreprocessorOpts().ImplicitPTHInclude = std::string(); + PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts(); + if (!PPOpts.ImplicitPCHInclude.empty()) { + // We can't use a PCH because it was likely built in non-ARC mode and we + // want to parse in ARC. Include the original header. + FileManager FileMgr(origCI.getFileSystemOpts()); + IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); + IntrusiveRefCntPtr<DiagnosticsEngine> Diags( + new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(), + new IgnoringDiagConsumer())); + std::string OriginalFile = + ASTReader::getOriginalSourceFile(PPOpts.ImplicitPCHInclude, + FileMgr, *Diags); + if (!OriginalFile.empty()) + PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile); + PPOpts.ImplicitPCHInclude.clear(); + } + // FIXME: Get the original header of a PTH as well. + CInvok->getPreprocessorOpts().ImplicitPTHInclude.clear(); std::string define = getARCMTMacroName(); define += '='; CInvok->getPreprocessorOpts().addMacroDef(define); |