From: Argyrios Kyrtzidis Date: Tue, 31 May 2011 03:56:09 +0000 (+0000) Subject: Utilize PackedVector, introduced with llvm commit r132325. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=049f6d0239e242dc338be6ac6f6c5175803d2163;p=clang Utilize PackedVector, introduced with llvm commit r132325. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index fc0b904c83..e80e282813 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -14,7 +14,7 @@ #include #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 ValueVector; typedef std::pair 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,