summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite/RewriteObjC.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-28 09:06:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-28 09:06:06 +0000
commit43b205796f4ab57d6175e858f4508f15ee4fcba2 (patch)
treea16ebcaa61ddf49cebfe0dcfbbecf727211f9301 /clang/lib/Rewrite/RewriteObjC.cpp
parent1177ff17404eb88809d8b396922b3b4a7832a6d7 (diff)
downloadbcm5719-llvm-43b205796f4ab57d6175e858f4508f15ee4fcba2.tar.gz
bcm5719-llvm-43b205796f4ab57d6175e858f4508f15ee4fcba2.zip
Fix the memory leak of FloatingLiteral/IntegerLiteral.
For large floats/integers, APFloat/APInt will allocate memory from the heap to represent these numbers. Unfortunately, when we use a BumpPtrAllocator to allocate IntegerLiteral/FloatingLiteral nodes the memory associated with the APFloat/APInt values will never get freed. I introduce the class 'APNumericStorage' which uses ASTContext's allocator for memory allocation and is used internally by FloatingLiteral/IntegerLiteral. Fixes rdar://7637185 llvm-svn: 112361
Diffstat (limited to 'clang/lib/Rewrite/RewriteObjC.cpp')
-rw-r--r--clang/lib/Rewrite/RewriteObjC.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Rewrite/RewriteObjC.cpp b/clang/lib/Rewrite/RewriteObjC.cpp
index 80b9681a7e3..4a7de4bed0d 100644
--- a/clang/lib/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Rewrite/RewriteObjC.cpp
@@ -3029,9 +3029,10 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
// is needed to decide what to do.
unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
- IntegerLiteral *limit = new (Context) IntegerLiteral(llvm::APInt(IntSize, 8),
- Context->IntTy,
- SourceLocation());
+ IntegerLiteral *limit = IntegerLiteral::Create(*Context,
+ llvm::APInt(IntSize, 8),
+ Context->IntTy,
+ SourceLocation());
BinaryOperator *lessThanExpr = new (Context) BinaryOperator(sizeofExpr, limit,
BO_LE,
Context->IntTy,
@@ -5268,8 +5269,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
int flag = (BLOCK_HAS_COPY_DISPOSE | BLOCK_HAS_DESCRIPTOR);
unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
- Expr *FlagExp = new (Context) IntegerLiteral(llvm::APInt(IntSize, flag),
- Context->IntTy, SourceLocation());
+ Expr *FlagExp = IntegerLiteral::Create(*Context, llvm::APInt(IntSize, flag),
+ Context->IntTy, SourceLocation());
InitExprs.push_back(FlagExp);
}
NewRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0], InitExprs.size(),
OpenPOWER on IntegriCloud