diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-07 06:08:38 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-07 06:08:38 +0000 |
commit | 42602bb40aefcc2751d4078ba88aacf4d965c9bd (patch) | |
tree | f06466787a5ac3936997adfcedd9fcd3d711a30f /include | |
parent | ef888a4d7f0fa1596807f702d09df88044dcaf41 (diff) |
Separate Stmt::Destroy into the entrypoint for destroying a statement
or expression (Destroy) from the virtual function used to actually
destroy a given expression (DoDestroy).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78375 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Expr.h | 20 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 22 | ||||
-rw-r--r-- | include/clang/AST/Stmt.h | 13 | ||||
-rw-r--r-- | include/clang/AST/StmtCXX.h | 5 |
4 files changed, 39 insertions, 21 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 3cec4e8aaf..e65a842d3f 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -564,6 +564,10 @@ class StringLiteral : public Expr { SourceLocation TokLocs[1]; StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty) {} + +protected: + virtual void DoDestroy(ASTContext &C); + public: /// This is the "fully general" constructor that allows representation of /// strings formed from multiple concatenated tokens. @@ -582,7 +586,6 @@ public: static StringLiteral *CreateEmpty(ASTContext &C, unsigned NumStrs); StringLiteral* Clone(ASTContext &C) const; - void Destroy(ASTContext &C); const char *getStrData() const { return StrData; } unsigned getByteLength() const { return ByteLength; } @@ -780,6 +783,10 @@ class SizeOfAlignOfExpr : public Expr { Stmt *Ex; } Argument; SourceLocation OpLoc, RParenLoc; + +protected: + virtual void DoDestroy(ASTContext& C); + public: SizeOfAlignOfExpr(bool issizeof, QualType T, QualType resultType, SourceLocation op, @@ -807,8 +814,6 @@ public: explicit SizeOfAlignOfExpr(EmptyShell Empty) : Expr(SizeOfAlignOfExprClass, Empty) { } - virtual void Destroy(ASTContext& C); - bool isSizeOf() const { return isSizeof; } void setSizeof(bool S) { isSizeof = S; } @@ -950,6 +955,8 @@ protected: // This version of the constructor is for derived classes. CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs, QualType t, SourceLocation rparenloc); + + virtual void DoDestroy(ASTContext& C); public: CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t, @@ -960,8 +967,6 @@ public: ~CallExpr() {} - void Destroy(ASTContext& C); - const Expr *getCallee() const { return cast<Expr>(SubExprs[FN]); } Expr *getCallee() { return cast<Expr>(SubExprs[FN]); } void setCallee(Expr *F) { SubExprs[FN] = F; } @@ -2113,6 +2118,9 @@ private: : Expr(DesignatedInitExprClass, EmptyShell()), NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { } +protected: + virtual void DoDestroy(ASTContext &C); + public: /// A field designator, e.g., ".x". struct FieldDesignator { @@ -2332,8 +2340,6 @@ public: virtual SourceRange getSourceRange() const; - virtual void Destroy(ASTContext &C); - static bool classof(const Stmt *T) { return T->getStmtClass() == DesignatedInitExprClass; } diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index bee9b29896..008e6af2b7 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -431,7 +431,8 @@ class CXXTemporary { public: static CXXTemporary *Create(ASTContext &C, const CXXDestructorDecl *Destructor); - void Destroy(ASTContext &C); + + void Destroy(ASTContext &Ctx); const CXXDestructorDecl *getDestructor() const { return Destructor; } }; @@ -448,10 +449,12 @@ class CXXBindTemporaryExpr : public Expr { subexpr->getType()), Temp(temp), SubExpr(subexpr) { } ~CXXBindTemporaryExpr() { } +protected: + virtual void DoDestroy(ASTContext &C); + public: static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, Expr* SubExpr); - void Destroy(ASTContext &C); CXXTemporary *getTemporary() { return Temp; } const CXXTemporary *getTemporary() const { return Temp; } @@ -489,12 +492,13 @@ protected: Expr **args, unsigned numargs); ~CXXConstructExpr() { } + virtual void DoDestroy(ASTContext &C); + public: static CXXConstructExpr *Create(ASTContext &C, QualType T, CXXConstructorDecl *D, bool Elidable, Expr **Args, unsigned NumArgs); - void Destroy(ASTContext &C); CXXConstructorDecl* getConstructor() const { return Constructor; } @@ -653,8 +657,6 @@ public: /*FIXME:integral constant?*/ var->getType()->isDependentType()) {} - virtual void Destroy(ASTContext& Ctx); - SourceLocation getStartLoc() const { return getLocation(); } VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } @@ -1072,6 +1074,8 @@ class TemplateIdRefExpr : public Expr { unsigned NumTemplateArgs, SourceLocation RAngleLoc); + virtual void DoDestroy(ASTContext &Context); + public: static TemplateIdRefExpr * Create(ASTContext &Context, QualType T, @@ -1080,8 +1084,6 @@ public: SourceLocation LAngleLoc, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, SourceLocation RAngleLoc); - void Destroy(ASTContext &Context); - /// \brief Retrieve the nested name specifier used to qualify the name of /// this template-id, e.g., the "std::sort" in @c std::sort<int>, or NULL /// if this template-id was an unqualified-id. @@ -1143,12 +1145,14 @@ class CXXExprWithTemporaries : public Expr { CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, unsigned NumTemps, bool ShouldDestroyTemps); ~CXXExprWithTemporaries(); - + +protected: + virtual void DoDestroy(ASTContext &C); + public: static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps, unsigned NumTemps, bool ShouldDestroyTemporaries); - void Destroy(ASTContext &C); unsigned getNumTemporaries() const { return NumTemps; } CXXTemporary *getTemporary(unsigned i) { diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index e841f25d76..239c6b5f43 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -155,13 +155,21 @@ protected: if (Stmt::CollectingStats()) Stmt::addStmtClass(SC); } + /// \brief Virtual method that performs the actual destruction of + /// this statement. + /// + /// Subclasses should override this method (not Destroy()) to + /// provide class-specific destruction. + virtual void DoDestroy(ASTContext &Ctx); + public: Stmt(StmtClass SC) : sClass(SC) { if (Stmt::CollectingStats()) Stmt::addStmtClass(SC); } virtual ~Stmt() {} - virtual void Destroy(ASTContext &Ctx); + /// \brief Destroy the current statement and its children. + void Destroy(ASTContext &Ctx) { DoDestroy(Ctx); } StmtClass getStmtClass() const { return sClass; } const char *getStmtClassName() const; @@ -256,6 +264,7 @@ public: class DeclStmt : public Stmt { DeclGroupRef DG; SourceLocation StartLoc, EndLoc; + public: DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg), @@ -264,8 +273,6 @@ public: /// \brief Build an empty declaration statement. explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { } - virtual void Destroy(ASTContext& Ctx); - /// isSingleDecl - This method returns true if this DeclStmt refers /// to a single Decl. bool isSingleDecl() const { diff --git a/include/clang/AST/StmtCXX.h b/include/clang/AST/StmtCXX.h index 2338f1457a..28fe348c45 100644 --- a/include/clang/AST/StmtCXX.h +++ b/include/clang/AST/StmtCXX.h @@ -29,13 +29,14 @@ class CXXCatchStmt : public Stmt { /// The handler block. Stmt *HandlerBlock; +protected: + virtual void DoDestroy(ASTContext& Ctx); + public: CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock) : Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl), HandlerBlock(handlerBlock) {} - virtual void Destroy(ASTContext& Ctx); - virtual SourceRange getSourceRange() const { return SourceRange(CatchLoc, HandlerBlock->getLocEnd()); } |