[cfe-commits] r130886 - /cfe/trunk/lib/Frontend/ASTUnit.cpp
Ted Kremenek
kremenek at apple.com
Wed May 4 16:27:12 PDT 2011
Author: kremenek
Date: Wed May 4 18:27:12 2011
New Revision: 130886
URL: http://llvm.org/viewvc/llvm-project?rev=130886&view=rev
Log:
ASTUnit::LoadFromASTFile(): recover the resources from an ASTReader if it crashes during PCH validation.
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=130886&r1=130885&r2=130886&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed May 4 18:27:12 2011
@@ -579,6 +579,11 @@
Reader.reset(new ASTReader(AST->getSourceManager(), AST->getFileManager(),
AST->getDiagnostics()));
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<ASTReader>
+ ReaderCleanup(Reader.get());
+
Reader->setListener(new ASTInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
@@ -633,6 +638,11 @@
// AST file as needed.
ASTReader *ReaderPtr = Reader.get();
llvm::OwningPtr<ExternalASTSource> Source(Reader.take());
+
+ // Unregister the cleanup for ASTReader. It will get cleaned up
+ // by the ASTUnit cleanup.
+ ReaderCleanup.unregister();
+
Context.setExternalSource(Source);
// Create an AST consumer, even though it isn't used.
More information about the cfe-commits
mailing list