]> granicus.if.org Git - clang/commitdiff
Revert "Remove redundant local variable (use newly created instance data).", the
authorDaniel Dunbar <daniel@zuster.org>
Thu, 3 Sep 2009 05:59:35 +0000 (05:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 3 Sep 2009 05:59:35 +0000 (05:59 +0000)
previous commit this depends on is breaking x86_64-apple-darwin10 and Linux tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80895 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp

index 3fce817c0d2383327967193f26ea9e3a5b450160..38452ed9d4442965b14ed5e9807ee5bfe9eecce1 100644 (file)
@@ -104,13 +104,15 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
   std::string Predefines;
   unsigned Counter;
 
+  llvm::OwningPtr<PCHReader>        Reader;
   llvm::OwningPtr<ExternalASTSource> Source;
 
-  AST->Reader.reset(new PCHReader(SourceMgr, FileMgr, Diags));
-  AST->Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, 
-                                                TargetTriple, Predefines, 
-                                                Counter));
-  switch (AST->Reader->ReadPCH(Filename)) {
+  Reader.reset(new PCHReader(SourceMgr, FileMgr, Diags));
+  AST->Reader.reset(Reader.get());
+  Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, TargetTriple,
+                                           Predefines, Counter));
+
+  switch (Reader->ReadPCH(Filename)) {
   case PCHReader::Success:
     break;
     
@@ -131,7 +133,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
 
   PP.setPredefines(Predefines);
   PP.setCounterValue(Counter);
-  AST->Reader->setPreprocessor(PP);
+  Reader->setPreprocessor(PP);
   
   // Create and initialize the ASTContext.
 
@@ -145,12 +147,12 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
                                 /* size_reserve = */0));
   ASTContext &Context = *AST->Ctx.get();
   
-  AST->Reader->InitializeContext(Context);
+  Reader->InitializeContext(Context);
   
   // Attach the PCH reader to the AST context as an external AST
   // source, so that declarations will be deserialized from the
   // PCH file as needed.
-  Source.reset(AST->Reader.get());
+  Source.reset(Reader.take());
   Context.setExternalSource(Source);
 
   return AST.take();