add actions for deleting expr/stmt nodes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41635 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp
index f783302..1a01270 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -38,6 +38,13 @@
   KnownFunctionIDs[ id_vprintf ] = &IT.get("vprintf");
 }
 
+void Sema::DeleteExpr(ExprTy *E) {
+  delete static_cast<Expr*>(E);
+}
+void Sema::DeleteStmt(StmtTy *S) {
+  delete static_cast<Stmt*>(S);
+}
+
 //===----------------------------------------------------------------------===//
 // Helper functions.
 //===----------------------------------------------------------------------===//
diff --git a/Sema/Sema.h b/Sema/Sema.h
index fbf4f53..046305e 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -120,6 +120,9 @@
             const std::string &Msg1, const std::string &Msg2, 
             SourceRange R1, SourceRange R2);
 
+  virtual void DeleteExpr(ExprTy *E);
+  virtual void DeleteStmt(StmtTy *S);
+
   //===--------------------------------------------------------------------===//
   // Type Analysis / Processing: SemaType.cpp.
   //
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index cb1acf5..bc23b81 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -78,6 +78,12 @@
   typedef ActionResult<1> StmtResult;
   typedef ActionResult<2> TypeResult;
   
+  /// Deletion callbacks - Since the parser doesn't know the concrete types of
+  /// the AST nodes being generated, it must do callbacks to delete objects when
+  /// recovering from errors.
+  virtual void DeleteExpr(ExprTy *E) {}
+  virtual void DeleteStmt(StmtTy *E) {}
+  
   //===--------------------------------------------------------------------===//
   // Declaration Tracking Callbacks.
   //===--------------------------------------------------------------------===//