@@ -2271,22 +2271,16 @@ class Evaluator {
2271
2271
public:
2272
2272
Evaluator (const DataLayout *DL, const TargetLibraryInfo *TLI)
2273
2273
: DL(DL), TLI(TLI) {
2274
- ValueStack.push_back (new DenseMap<Value*, Constant*>);
2274
+ ValueStack.push_back (make_unique< DenseMap<Value*, Constant*>>() );
2275
2275
}
2276
2276
2277
2277
~Evaluator () {
2278
- DeleteContainerPointers (ValueStack);
2279
- while (!AllocaTmps.empty ()) {
2280
- GlobalVariable *Tmp = AllocaTmps.back ();
2281
- AllocaTmps.pop_back ();
2282
-
2278
+ for (auto &Tmp : AllocaTmps)
2283
2279
// If there are still users of the alloca, the program is doing something
2284
2280
// silly, e.g. storing the address of the alloca somewhere and using it
2285
2281
// later. Since this is undefined, we'll just make it be null.
2286
2282
if (!Tmp->use_empty ())
2287
2283
Tmp->replaceAllUsesWith (Constant::getNullValue (Tmp->getType ()));
2288
- delete Tmp;
2289
- }
2290
2284
}
2291
2285
2292
2286
// / EvaluateFunction - Evaluate a call to function F, returning true if
@@ -2325,7 +2319,7 @@ class Evaluator {
2325
2319
// / ValueStack - As we compute SSA register values, we store their contents
2326
2320
// / here. The back of the vector contains the current function and the stack
2327
2321
// / contains the values in the calling frames.
2328
- SmallVector<DenseMap<Value*, Constant*>* , 4 > ValueStack;
2322
+ SmallVector<std::unique_ptr< DenseMap<Value*, Constant*>> , 4 > ValueStack;
2329
2323
2330
2324
// / CallStack - This is used to detect recursion. In pathological situations
2331
2325
// / we could hit exponential behavior, but at least there is nothing
@@ -2340,7 +2334,7 @@ class Evaluator {
2340
2334
// / AllocaTmps - To 'execute' an alloca, we create a temporary global variable
2341
2335
// / to represent its body. This vector is needed so we can delete the
2342
2336
// / temporary globals when we are done.
2343
- SmallVector<GlobalVariable* , 32 > AllocaTmps;
2337
+ SmallVector<std::unique_ptr< GlobalVariable> , 32 > AllocaTmps;
2344
2338
2345
2339
// / Invariants - These global variables have been marked invariant by the
2346
2340
// / static constructor.
@@ -2530,11 +2524,10 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst,
2530
2524
return false ; // Cannot handle array allocs.
2531
2525
}
2532
2526
Type *Ty = AI->getType ()->getElementType ();
2533
- AllocaTmps.push_back (new GlobalVariable (Ty, false ,
2534
- GlobalValue::InternalLinkage,
2535
- UndefValue::get (Ty),
2536
- AI->getName ()));
2537
- InstResult = AllocaTmps.back ();
2527
+ AllocaTmps.push_back (
2528
+ make_unique<GlobalVariable>(Ty, false , GlobalValue::InternalLinkage,
2529
+ UndefValue::get (Ty), AI->getName ()));
2530
+ InstResult = AllocaTmps.back ().get ();
2538
2531
DEBUG (dbgs () << " Found an alloca. Result: " << *InstResult << " \n " );
2539
2532
} else if (isa<CallInst>(CurInst) || isa<InvokeInst>(CurInst)) {
2540
2533
CallSite CS (CurInst);
@@ -2638,12 +2631,12 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst,
2638
2631
2639
2632
Constant *RetVal = 0 ;
2640
2633
// Execute the call, if successful, use the return value.
2641
- ValueStack.push_back (new DenseMap<Value*, Constant*> );
2634
+ ValueStack.push_back (make_unique< DenseMap<Value *, Constant *>>() );
2642
2635
if (!EvaluateFunction (Callee, RetVal, Formals)) {
2643
2636
DEBUG (dbgs () << " Failed to evaluate function.\n " );
2644
2637
return false ;
2645
2638
}
2646
- delete ValueStack.pop_back_val ();
2639
+ ValueStack.pop_back ();
2647
2640
InstResult = RetVal;
2648
2641
2649
2642
if (InstResult != NULL ) {
0 commit comments