]> granicus.if.org Git - clang/commitdiff
Utilize PackedVector, introduced with llvm commit r132325.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 31 May 2011 03:56:09 +0000 (03:56 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 31 May 2011 03:56:09 +0000 (03:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132326 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValues.cpp

index fc0b904c83cd3b57b037341df869b9eb8155f87b..e80e282813af61f78e16e303f0c2683b757a79c6 100644 (file)
@@ -14,7 +14,7 @@
 #include <utility>
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/PackedVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "clang/AST/Decl.h"
 #include "clang/Analysis/CFG.h"
@@ -93,39 +93,8 @@ static bool isAlwaysUninit(const Value v) {
 }
 
 namespace {
-class ValueVector {
-  llvm::BitVector vec;
-public:
-  ValueVector() {}
-  ValueVector(unsigned size) : vec(size << 1) {}
-  void resize(unsigned n) { vec.resize(n << 1); }
-  void merge(const ValueVector &rhs) { vec |= rhs.vec; }
-  bool operator!=(const ValueVector &rhs) const { return vec != rhs.vec; }
-  void reset() { vec.reset(); }
-  
-  class reference {
-    ValueVector &vv;
-    const unsigned idx;
-
-    reference();  // Undefined    
-  public:
-    reference(ValueVector &vv, unsigned idx) : vv(vv), idx(idx) {}    
-    ~reference() {}
-    
-    reference &operator=(Value v) {
-      vv.vec[idx << 1] = (((unsigned) v) & 0x1) ? true : false;
-      vv.vec[(idx << 1) | 1] = (((unsigned) v) & 0x2) ? true : false;
-      return *this;
-    }
-    operator Value() {
-      unsigned x = (vv.vec[idx << 1] ? 1 : 0) | (vv.vec[(idx << 1) | 1] ? 2 :0);
-      return (Value) x;      
-    }
-  };
-    
-  reference operator[](unsigned idx) { return reference(*this, idx); }
-};
 
+typedef llvm::PackedVector<Value, 2> ValueVector;
 typedef std::pair<ValueVector *, ValueVector *> BVPair;
 
 class CFGBlockValues {
@@ -259,7 +228,7 @@ void CFGBlockValues::mergeIntoScratch(ValueVector const &source,
   if (isFirst)
     scratch = source;
   else
-    scratch.merge(source);
+    scratch |= source;
 }
 #if 0
 static void printVector(const CFGBlock *block, ValueVector &bv,