Plug some PATypeHolder memory leaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2007-03-20 01:13:00 +00:00
parent dc42f48ea9
commit 2c9df214c7

View File

@@ -513,9 +513,16 @@ static BasicBlock *defineBBVal(const ValID &ID) {
CurFun.CurrentFunction->getBasicBlockList().remove(BB); CurFun.CurrentFunction->getBasicBlockList().remove(BB);
CurFun.CurrentFunction->getBasicBlockList().push_back(BB); CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
// We're about to erase the entry, save the key so we can clean it up.
ValID Tmp = BBI->first;
// Erase the forward ref from the map as its no longer "forward" // Erase the forward ref from the map as its no longer "forward"
CurFun.BBForwardRefs.erase(ID); CurFun.BBForwardRefs.erase(ID);
// The key has been removed from the map but so we don't want to leave
// strdup'd memory around so destroy it too.
Tmp.destroy();
// If its a numbered definition, bump the number and set the BB value. // If its a numbered definition, bump the number and set the BB value.
if (ID.Type == ValID::LocalID) { if (ID.Type == ValID::LocalID) {
assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
@@ -1294,8 +1301,10 @@ Types
std::vector<FunctionType::ParameterAttributes> Attrs; std::vector<FunctionType::ParameterAttributes> Attrs;
Attrs.push_back($5); Attrs.push_back($5);
for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) {
Params.push_back(I->Ty->get()); const Type *Ty = I->Ty->get();
if (I->Ty->get() != Type::VoidTy) delete I->Ty; I->Ty = 0;
Params.push_back(Ty);
if (Ty != Type::VoidTy)
Attrs.push_back(I->Attrs); Attrs.push_back(I->Attrs);
} }
bool isVarArg = Params.size() && Params.back() == Type::VoidTy; bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
@@ -1312,8 +1321,10 @@ Types
std::vector<FunctionType::ParameterAttributes> Attrs; std::vector<FunctionType::ParameterAttributes> Attrs;
Attrs.push_back($5); Attrs.push_back($5);
for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) {
Params.push_back(I->Ty->get()); const Type* Ty = I->Ty->get();
if (I->Ty->get() != Type::VoidTy) delete I->Ty; I->Ty = 0;
Params.push_back(Ty);
if (Ty != Type::VoidTy)
Attrs.push_back(I->Attrs); Attrs.push_back(I->Attrs);
} }
bool isVarArg = Params.size() && Params.back() == Type::VoidTy; bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
@@ -1429,11 +1440,13 @@ ArgTypeListI
// //
TypeListI : Types { TypeListI : Types {
$$ = new std::list<PATypeHolder>(); $$ = new std::list<PATypeHolder>();
$$->push_back(*$1); delete $1; $$->push_back(*$1);
delete $1;
CHECK_FOR_ERROR CHECK_FOR_ERROR
} }
| TypeListI ',' Types { | TypeListI ',' Types {
($$=$1)->push_back(*$3); delete $3; ($$=$1)->push_back(*$3);
delete $3;
CHECK_FOR_ERROR CHECK_FOR_ERROR
}; };
@@ -2479,6 +2492,8 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
PFTy = PointerType::get(Ty); PFTy = PointerType::get(Ty);
} }
delete $3;
Value *V = getVal(PFTy, $4); // Get the function we're calling... Value *V = getVal(PFTy, $4); // Get the function we're calling...
CHECK_FOR_ERROR CHECK_FOR_ERROR
BasicBlock *Normal = getBBVal($11); BasicBlock *Normal = getBBVal($11);
@@ -2595,6 +2610,7 @@ ValueRefList : Types ValueRef OptParamAttrs {
$$ = new ValueRefList(); $$ = new ValueRefList();
ValueRefListEntry E; E.Attrs = $3; E.Val = getVal($1->get(), $2); ValueRefListEntry E; E.Attrs = $3; E.Val = getVal($1->get(), $2);
$$->push_back(E); $$->push_back(E);
delete $1;
} }
| ValueRefList ',' Types ValueRef OptParamAttrs { | ValueRefList ',' Types ValueRef OptParamAttrs {
if (!UpRefs.empty()) if (!UpRefs.empty())
@@ -2602,6 +2618,7 @@ ValueRefList : Types ValueRef OptParamAttrs {
$$ = $1; $$ = $1;
ValueRefListEntry E; E.Attrs = $5; E.Val = getVal($3->get(), $4); ValueRefListEntry E; E.Attrs = $5; E.Val = getVal($3->get(), $4);
$$->push_back(E); $$->push_back(E);
delete $3;
CHECK_FOR_ERROR CHECK_FOR_ERROR
} }
| /*empty*/ { $$ = new ValueRefList(); }; | /*empty*/ { $$ = new ValueRefList(); };
@@ -2674,6 +2691,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
$$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
if ($$ == 0) if ($$ == 0)
GEN_ERROR("icmp operator returned null"); GEN_ERROR("icmp operator returned null");
delete $3;
} }
| FCMP FPredicates Types ValueRef ',' ValueRef { | FCMP FPredicates Types ValueRef ',' ValueRef {
if (!UpRefs.empty()) if (!UpRefs.empty())
@@ -2687,6 +2705,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
$$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
if ($$ == 0) if ($$ == 0)
GEN_ERROR("fcmp operator returned null"); GEN_ERROR("fcmp operator returned null");
delete $3;
} }
| CastOps ResolvedVal TO Types { | CastOps ResolvedVal TO Types {
if (!UpRefs.empty()) if (!UpRefs.empty())