[cfe-commits] r61171 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp
Nuno Lopes
nunoplopes at sapo.pt
Wed Dec 17 15:39:56 PST 2008
Author: nlopes
Date: Wed Dec 17 17:39:55 2008
New Revision: 61171
URL: http://llvm.org/viewvc/llvm-project?rev=61171&view=rev
Log:
fix leakage of var's initializers
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=61171&r1=61170&r2=61171&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Dec 17 17:39:55 2008
@@ -344,7 +344,10 @@
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S, ScopedDecl *PrevDecl,
SourceLocation TypeSpecStartLoc = SourceLocation());
-
+
+ virtual ~VarDecl();
+ virtual void Destroy(ASTContext& C);
+
StorageClass getStorageClass() const { return (StorageClass)SClass; }
SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=61171&r1=61170&r2=61171&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Dec 17 17:39:55 2008
@@ -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 @@
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 @@
}
//===----------------------------------------------------------------------===//
+// 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
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list