]> granicus.if.org Git - clang/commitdiff
Add {ExternalSemaSource,SemaConsumer}::ForgetSema callback, and update PCHReader
authorDaniel Dunbar <daniel@zuster.org>
Tue, 1 Dec 2009 21:57:20 +0000 (21:57 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 1 Dec 2009 21:57:20 +0000 (21:57 +0000)
to use it so it at least won't try to access Sema once it is gone.

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

include/clang/Frontend/PCHReader.h
include/clang/Sema/ExternalSemaSource.h
include/clang/Sema/SemaConsumer.h
lib/Sema/ParseAST.cpp

index 85861fab4a22d861b1ccd145148c538bfc153174..ae7cb14422d2a33ab4df6e24cc21b1c81f26e68d 100644 (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
index 05c56451b21884bc70e51c00cfe39fccfcf7af12..d27e29281b5a3b3ad4acb1a9e792656884fb98dc 100644 (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.
   ///
index b213daf8a39ea0f85897f00f65eaafb19d899ee3..3689a6e7a820c6a22c10a2e8b8bec2185f0300a6 100644 (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;
index 7c7df4bb61b4b9c32280e3ab4f9b0f7a871ddd49..898b3c230e873ca1a4ba26c962abf875c3462289 100644 (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();