aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2008-12-17 23:39:55 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2008-12-17 23:39:55 +0000
commit99f06ba988922ea721035a89e6d3c66ba100ba8a (patch)
treeca5dcbec1cea889ef20203b31f2db2d93e2b5526 /lib/AST/Decl.cpp
parent30a12ec2a7f331d9e08acabe7cda853aaa7ba54b (diff)
fix leakage of var's initializers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index dcefaa915b..be8cbe7344 100644
--- a/lib/AST/Decl.cpp
+++ b/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
//===----------------------------------------------------------------------===//