Add {ExternalSemaSource,SemaConsumer}::ForgetSema callback, and update PCHReader

to use it so it at least won't try to access Sema once it is gone.

llvm-svn: 90261
This commit is contained in:
Daniel Dunbar 2009-12-01 21:57:20 +00:00
parent 8a8ba87ac8
commit ec5f8ae6a8
4 changed files with 17 additions and 1 deletions

View File

@ -625,6 +625,9 @@ public:
/// tree.
virtual void InitializeSema(Sema &S);
/// \brief Inform the semantic consumer that Sema is no longer available.
virtual void ForgetSema() { SemaObj = 0; }
/// \brief Retrieve the IdentifierInfo for the named identifier.
///
/// This routine builds a new IdentifierInfo for the given identifier. If any

View File

@ -34,6 +34,9 @@ public:
/// tree.
virtual void InitializeSema(Sema &S) {}
/// \brief Inform the semantic consumer that Sema is no longer available.
virtual void ForgetSema() {}
/// \brief Load the contents of the global method pool for a given
/// selector.
///

View File

@ -34,6 +34,9 @@ namespace clang {
/// tree.
virtual void InitializeSema(Sema &S) {}
/// \brief Inform the semantic consumer that Sema is no longer available.
virtual void ForgetSema() {}
// isa/cast/dyn_cast support
static bool classof(const ASTConsumer *Consumer) {
return Consumer->SemaConsumer;

View File

@ -75,7 +75,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
while ((ADecl = P.RetrievePendingObjCImpDecl()))
Consumer->HandleTopLevelDecl(ADecl.getAsVal<DeclGroupRef>());
// process any TopLevelDecls generated by #pragma weak
// Process any TopLevelDecls generated by #pragma weak.
for (llvm::SmallVector<Decl*,2>::iterator
I = S.WeakTopLevelDecls().begin(),
E = S.WeakTopLevelDecls().end(); I != E; ++I)
@ -83,6 +83,13 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
Consumer->HandleTranslationUnit(Ctx);
if (ExternalSemaSource *ESS =
dyn_cast_or_null<ExternalSemaSource>(Ctx.getExternalSource()))
ESS->ForgetSema();
if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer))
SC->ForgetSema();
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
P.getActions().PrintStats();