diff options
| author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-12-17 23:39:55 +0000 |
|---|---|---|
| committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-12-17 23:39:55 +0000 |
| commit | 394ec984f2048b85abf3ab5eaddc3dd08d2c4d2d (patch) | |
| tree | cae91413aa8cd77fab6abb1df94a4034ba5eee3d /clang/lib/AST/Decl.cpp | |
| parent | 63ff81c4e1fe13a2f8db43bc6350f354772aa112 (diff) | |
| download | bcm5719-llvm-394ec984f2048b85abf3ab5eaddc3dd08d2c4d2d.tar.gz bcm5719-llvm-394ec984f2048b85abf3ab5eaddc3dd08d2c4d2d.zip | |
fix leakage of var's initializers
llvm-svn: 61171
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index dcefaa915b7..be8cbe7344d 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -14,6 +14,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Stmt.h" +#include "clang/AST/Expr.h" #include "clang/Basic/IdentifierTable.h" using namespace clang; @@ -48,15 +49,6 @@ ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC, return new (Mem) ImplicitParamDecl(ImplicitParam, DC, L, Id, T, PrevDecl); } -VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, - IdentifierInfo *Id, QualType T, - StorageClass S, ScopedDecl *PrevDecl, - SourceLocation TypeSpecStartLoc) { - void *Mem = C.getAllocator().Allocate<VarDecl>(); - return new (Mem) VarDecl(Var, DC, L, Id, T, S, PrevDecl, TypeSpecStartLoc); -} - ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S, @@ -166,6 +158,28 @@ ScopedDecl::~ScopedDecl() { } //===----------------------------------------------------------------------===// +// VarDecl Implementation +//===----------------------------------------------------------------------===// + +VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, + IdentifierInfo *Id, QualType T, + StorageClass S, ScopedDecl *PrevDecl, + SourceLocation TypeSpecStartLoc) { + void *Mem = C.getAllocator().Allocate<VarDecl>(); + return new (Mem) VarDecl(Var, DC, L, Id, T, S, PrevDecl, TypeSpecStartLoc); +} + +void VarDecl::Destroy(ASTContext& C) { + this->~VarDecl(); + C.getAllocator().Deallocate((void *)this); +} + +VarDecl::~VarDecl() { + delete getInit(); +} + +//===----------------------------------------------------------------------===// // FunctionDecl Implementation //===----------------------------------------------------------------------===// |

