From 3faf9df08ff389028050bfbccbef571061bf7cc1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 17 Jun 2008 08:24:37 +0000 Subject: [PATCH] Use a SmallVector instead of an array, since auto_ptr doesn't handle arrays properly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52390 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index e9c3badb6d1..7b87cb62da0 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -908,24 +908,21 @@ Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin, // Calculate the number of indices required unsigned size = I->getNumIndices() + (idx_end - idx_begin); // Allocate some space to put the new indices in - unsigned *new_begin = new unsigned[size]; - // Auto cleanup this array - std::auto_ptr newptr(new_begin); - // Start inserting at the beginning - unsigned *new_end = new_begin; + SmallVector Idxs; + Idxs.reserve(size); // Add indices from the extract value instruction for (const unsigned *i = I->idx_begin(), *e = I->idx_end(); - i != e; ++i, ++new_end) - *new_end = *i; + i != e; ++i) + Idxs.push_back(*i); // Add requested indices - for (const unsigned *i = idx_begin, *e = idx_end; i != e; ++i, ++new_end) - *new_end = *i; + for (const unsigned *i = idx_begin, *e = idx_end; i != e; ++i) + Idxs.push_back(*i); - assert((unsigned)(new_end - new_begin) == size + assert(Idxs.size() == size && "Number of indices added not correct?"); - return FindInsertedValue(I->getAggregateOperand(), new_begin, new_end, + return FindInsertedValue(I->getAggregateOperand(), Idxs.begin(), Idxs.end(), InsertBefore); } // Otherwise, we don't know (such as, extracting from a function return value -- 2.34.1