fix leakage of APFloats in getExistingVal()
authorNuno Lopes <nunoplopes@sapo.pt>
Tue, 4 Nov 2008 14:42:19 +0000 (14:42 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Tue, 4 Nov 2008 14:42:19 +0000 (14:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58696 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/ParserInternals.h
lib/AsmParser/llvmAsmParser.y

index 168d9baa3a020af097b85693db1a1fbc41bf7d5d..8af27c77c33a2c9e4cb7e6ef0b9858cf15180f7d 100644 (file)
@@ -152,6 +152,8 @@ struct ValID {
       delete IAD;
     else if (Type == ConstAPInt)
       delete ConstPoolInt;
+    else if (Type == ConstFPVal)
+      delete ConstPoolFP;
   }
 
   inline ValID copy() const {
index d76994a431a0e7617f390751537465c774a58701..36b827d6b726548032f6d72f34efff7a6e00fd68 100644 (file)
@@ -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<PointerType>(Ty)) {