[llvm-commits] [llvm] r52390 - /llvm/trunk/lib/Analysis/ValueTracking.cpp

Matthijs Kooijman matthijs at stdin.nl
Tue Jun 17 01:24:39 PDT 2008


Author: matthijs
Date: Tue Jun 17 03:24:37 2008
New Revision: 52390

URL: http://llvm.org/viewvc/llvm-project?rev=52390&view=rev
Log:
Use a SmallVector instead of an array, since auto_ptr doesn't handle arrays
properly.

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=52390&r1=52389&r2=52390&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Jun 17 03:24:37 2008
@@ -908,24 +908,21 @@
     // 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<unsigned> newptr(new_begin);
-    // Start inserting at the beginning
-    unsigned *new_end = new_begin;
+    SmallVector<unsigned, 5> 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





More information about the llvm-commits mailing list