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.
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; }
Stmt *Ex;
} Argument;
SourceLocation OpLoc, RParenLoc;
+
+protected:
+ virtual void DoDestroy(ASTContext& C);
+
public:
SizeOfAlignOfExpr(bool issizeof, QualType T,
QualType resultType, SourceLocation op,
explicit SizeOfAlignOfExpr(EmptyShell Empty)
: Expr(SizeOfAlignOfExprClass, Empty) { }
- virtual void Destroy(ASTContext& C);
-
bool isSizeOf() const { return isSizeof; }
void setSizeof(bool S) { isSizeof = S; }
// 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,
~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; }
: Expr(DesignatedInitExprClass, EmptyShell()),
NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { }
+protected:
+ virtual void DoDestroy(ASTContext &C);
+
public:
/// A field designator, e.g., ".x".
struct FieldDesignator {
virtual SourceRange getSourceRange() const;
- virtual void Destroy(ASTContext &C);
-
static bool classof(const Stmt *T) {
return T->getStmtClass() == DesignatedInitExprClass;
}
public:
static CXXTemporary *Create(ASTContext &C,
const CXXDestructorDecl *Destructor);
- void Destroy(ASTContext &C);
+
+ void Destroy(ASTContext &Ctx);
const CXXDestructorDecl *getDestructor() const { return Destructor; }
};
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; }
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; }
/*FIXME:integral constant?*/
var->getType()->isDependentType()) {}
- virtual void Destroy(ASTContext& Ctx);
-
SourceLocation getStartLoc() const { return getLocation(); }
VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); }
unsigned NumTemplateArgs,
SourceLocation RAngleLoc);
+ virtual void DoDestroy(ASTContext &Context);
+
public:
static TemplateIdRefExpr *
Create(ASTContext &Context, QualType T,
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.
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) {
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;
class DeclStmt : public Stmt {
DeclGroupRef DG;
SourceLocation StartLoc, EndLoc;
+
public:
DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
/// \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 {
/// 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());
}
TokLocs, NumConcatenated);
}
-void StringLiteral::Destroy(ASTContext &C) {
+void StringLiteral::DoDestroy(ASTContext &C) {
C.Deallocate(const_cast<char*>(StrData));
- this->~StringLiteral();
- C.Deallocate(this);
+ Expr::DoDestroy(C);
}
void StringLiteral::setStrData(ASTContext &C, const char *Str, unsigned Len) {
SubExprs = new (C) Stmt*[1];
}
-void CallExpr::Destroy(ASTContext& C) {
+void CallExpr::DoDestroy(ASTContext& C) {
DestroyChildren(C);
if (SubExprs) C.Deallocate(SubExprs);
this->~CallExpr();
memcpy(SubExprs, Exprs, sizeof(Expr *) * NumExprs);
}
-void SizeOfAlignOfExpr::Destroy(ASTContext& C) {
+void SizeOfAlignOfExpr::DoDestroy(ASTContext& C) {
// Override default behavior of traversing children. If this has a type
// operand and the type is a variable-length array, the child iteration
// will iterate over the size expression. However, this expression belongs
C.Deallocate(this);
}
else
- Expr::Destroy(C);
+ Expr::DoDestroy(C);
}
//===----------------------------------------------------------------------===//
NumDesignators = NumDesignators - 1 + NumNewDesignators;
}
-void DesignatedInitExpr::Destroy(ASTContext &C) {
+void DesignatedInitExpr::DoDestroy(ASTContext &C) {
delete [] Designators;
- Expr::Destroy(C);
+ Expr::DoDestroy(C);
}
ImplicitValueInitExpr *ImplicitValueInitExpr::Clone(ASTContext &C) const {
#include "clang/AST/ExprCXX.h"
using namespace clang;
-void CXXConditionDeclExpr::Destroy(ASTContext& C) {
- // FIXME: Cannot destroy the decl here, because it is linked into the
- // DeclContext's chain.
- //getVarDecl()->Destroy(C);
- this->~CXXConditionDeclExpr();
- C.Deallocate(this);
-}
-
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
NumTemplateArgs, RAngleLoc);
}
-void TemplateIdRefExpr::Destroy(ASTContext &Context) {
+void TemplateIdRefExpr::DoDestroy(ASTContext &Context) {
const TemplateArgument *TemplateArgs = getTemplateArgs();
for (unsigned I = 0; I != NumTemplateArgs; ++I)
if (Expr *E = TemplateArgs[I].getAsExpr())
E->Destroy(Context);
+ this->~TemplateIdRefExpr();
+ Context.Deallocate(this);
}
Stmt::child_iterator TemplateIdRefExpr::child_begin() {
return new (C) CXXTemporary(Destructor);
}
-void CXXTemporary::Destroy(ASTContext &C) {
+void CXXTemporary::Destroy(ASTContext &Ctx) {
this->~CXXTemporary();
- C.Deallocate(this);
+ Ctx.Deallocate(this);
}
CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
}
-void CXXBindTemporaryExpr::Destroy(ASTContext &C) {
+void CXXBindTemporaryExpr::DoDestroy(ASTContext &C) {
Temp->Destroy(C);
this->~CXXBindTemporaryExpr();
C.Deallocate(this);
}
}
-void CXXConstructExpr::Destroy(ASTContext &C) {
+void CXXConstructExpr::DoDestroy(ASTContext &C) {
DestroyChildren(C);
if (Args)
C.Deallocate(Args);
ShouldDestroyTemps);
}
-void CXXExprWithTemporaries::Destroy(ASTContext &C) {
+void CXXExprWithTemporaries::DoDestroy(ASTContext &C) {
DestroyChildren(C);
this->~CXXExprWithTemporaries();
C.Deallocate(this);
if (Stmt* Child = *I++) Child->Destroy(C);
}
-void Stmt::Destroy(ASTContext &C) {
+void Stmt::DoDestroy(ASTContext &C) {
DestroyChildren(C);
- // FIXME: Eventually all Stmts should be allocated with the allocator
- // in ASTContext, just like with Decls.
this->~Stmt();
C.Deallocate((void *)this);
}
-void DeclStmt::Destroy(ASTContext &C) {
- this->~DeclStmt();
- C.Deallocate((void *)this);
-}
-
void Stmt::PrintStats() {
// Ensure the table is primed.
getStmtInfoTableEntry(Stmt::NullStmtClass);
return QualType();
}
-void CXXCatchStmt::Destroy(ASTContext& C) {
+void CXXCatchStmt::DoDestroy(ASTContext& C) {
if (ExceptionDecl)
ExceptionDecl->Destroy(C);
- Stmt::Destroy(C);
+ Stmt::DoDestroy(C);
}
// CXXTryStmt