diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-28 09:06:06 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-28 09:06:06 +0000 |
| commit | 43b205796f4ab57d6175e858f4508f15ee4fcba2 (patch) | |
| tree | a16ebcaa61ddf49cebfe0dcfbbecf727211f9301 /clang/lib/Serialization/ASTReaderStmt.cpp | |
| parent | 1177ff17404eb88809d8b396922b3b4a7832a6d7 (diff) | |
| download | bcm5719-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/Serialization/ASTReaderStmt.cpp')
| -rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index ff2d39e6ec7..ec227e2836d 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -409,12 +409,12 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { VisitExpr(E); E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); - E->setValue(Reader.ReadAPInt(Record, Idx)); + E->setValue(*Reader.getContext(), Reader.ReadAPInt(Record, Idx)); } void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { VisitExpr(E); - E->setValue(Reader.ReadAPFloat(Record, Idx)); + E->setValue(*Reader.getContext(), Reader.ReadAPFloat(Record, Idx)); E->setExact(Record[Idx++]); E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); } @@ -1401,11 +1401,11 @@ Stmt *ASTReader::ReadStmtFromStream(llvm::BitstreamCursor &Cursor) { break; case EXPR_INTEGER_LITERAL: - S = new (Context) IntegerLiteral(Empty); + S = IntegerLiteral::Create(*Context, Empty); break; case EXPR_FLOATING_LITERAL: - S = new (Context) FloatingLiteral(Empty); + S = FloatingLiteral::Create(*Context, Empty); break; case EXPR_IMAGINARY_LITERAL: |

