From 0e92081b040a13dc8f00dac182e327af56bf7838 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 4 Nov 2008 14:42:19 +0000 Subject: [PATCH] fix leakage of APFloats in getExistingVal() llvm-svn: 58696 --- llvm/lib/AsmParser/ParserInternals.h | 2 ++ llvm/lib/AsmParser/llvmAsmParser.y | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/lib/AsmParser/ParserInternals.h b/llvm/lib/AsmParser/ParserInternals.h index 168d9baa3a02..8af27c77c33a 100644 --- a/llvm/lib/AsmParser/ParserInternals.h +++ b/llvm/lib/AsmParser/ParserInternals.h @@ -152,6 +152,8 @@ struct ValID { delete IAD; else if (Type == ConstAPInt) delete ConstPoolInt; + else if (Type == ConstFPVal) + delete ConstPoolFP; } inline ValID copy() const { diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index d76994a431a0..36b827d6b726 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -437,7 +437,11 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) { D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &ignored); } - return ConstantFP::get(*D.ConstPoolFP); + { + ConstantFP *tmp = ConstantFP::get(*D.ConstPoolFP); + D.destroy(); + return tmp; + } case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) {