[cfe-commits] r90261 - in /cfe/trunk: include/clang/Frontend/PCHReader.h include/clang/Sema/ExternalSemaSource.h include/clang/Sema/SemaConsumer.h lib/Sema/ParseAST.cpp
Daniel Dunbar
daniel at zuster.org
Tue Dec 1 13:57:20 PST 2009
Author: ddunbar
Date: Tue Dec 1 15:57:20 2009
New Revision: 90261
URL: http://llvm.org/viewvc/llvm-project?rev=90261&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/include/clang/Sema/ExternalSemaSource.h
cfe/trunk/include/clang/Sema/SemaConsumer.h
cfe/trunk/lib/Sema/ParseAST.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=90261&r1=90260&r2=90261&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Tue Dec 1 15:57:20 2009
@@ -625,6 +625,9 @@
/// 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
Modified: cfe/trunk/include/clang/Sema/ExternalSemaSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ExternalSemaSource.h?rev=90261&r1=90260&r2=90261&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ExternalSemaSource.h (original)
+++ cfe/trunk/include/clang/Sema/ExternalSemaSource.h Tue Dec 1 15:57:20 2009
@@ -34,6 +34,9 @@
/// 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.
///
Modified: cfe/trunk/include/clang/Sema/SemaConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaConsumer.h?rev=90261&r1=90260&r2=90261&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/SemaConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/SemaConsumer.h Tue Dec 1 15:57:20 2009
@@ -34,6 +34,9 @@
/// 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;
Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=90261&r1=90260&r2=90261&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Tue Dec 1 15:57:20 2009
@@ -75,7 +75,7 @@
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 @@
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();
More information about the cfe-commits
mailing list