From 394a3fd57d2430f26dd1872cc7226437f5698e63 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 31 Aug 2007 04:53:24 +0000 Subject: [PATCH] add actions for deleting expr/stmt nodes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41635 91177308-0d34-0410-b5e6-96231b3b80d8 --- Sema/Sema.cpp | 7 +++++++ Sema/Sema.h | 3 +++ include/clang/Parse/Action.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp index f783302d55..1a01270692 100644 --- a/Sema/Sema.cpp +++ b/Sema/Sema.cpp @@ -38,6 +38,13 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector &prevInGroup) KnownFunctionIDs[ id_vprintf ] = &IT.get("vprintf"); } +void Sema::DeleteExpr(ExprTy *E) { + delete static_cast(E); +} +void Sema::DeleteStmt(StmtTy *S) { + delete static_cast(S); +} + //===----------------------------------------------------------------------===// // Helper functions. //===----------------------------------------------------------------------===// diff --git a/Sema/Sema.h b/Sema/Sema.h index fbf4f53be1..046305ef00 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -120,6 +120,9 @@ public: 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 cb1acf5afa..bc23b8121e 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -78,6 +78,12 @@ public: 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. //===--------------------------------------------------------------------===// -- 2.50.1