From afb10c4bda2ac2c268fa7e6c11141584f57de119 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 15 Mar 2011 04:57:29 +0000 Subject: [PATCH] UninitializedValues: wrap BitVector references in a new class ValueVector. No functionality change. This defines the minimum interface that ValueVector needs to support when we no longer base it strictly on a direct interpretation of BitVector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127664 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/UninitializedValues.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 5dd4c236aa..ecd9d494f9 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -74,7 +74,22 @@ llvm::Optional DeclToIndex::getValueIndex(const VarDecl *d) { // CFGBlockValues: dataflow values for CFG blocks. //====------------------------------------------------------------------------// -typedef llvm::BitVector ValueVector; +static const bool Initialized = false; +static const bool Uninitialized = true; + +class ValueVector { + llvm::BitVector vec; +public: + ValueVector() {} + ValueVector(unsigned size) : vec(size) {} + typedef llvm::BitVector::reference reference; + void resize(unsigned n) { vec.resize(n); } + void merge(const ValueVector &rhs) { vec |= rhs.vec; } + bool operator!=(const ValueVector &rhs) const { return vec != rhs.vec; } + reference operator[](unsigned idx) { return vec[idx]; } + void reset() { vec.reset(); } +}; + typedef std::pair BVPair; namespace { @@ -189,7 +204,7 @@ void CFGBlockValues::mergeIntoScratch(ValueVector const &source, if (isFirst) scratch = source; else - scratch |= source; + scratch.merge(source); } #if 0 static void printVector(const CFGBlock *block, ValueVector &bv, @@ -286,9 +301,6 @@ const CFGBlock *DataflowWorklist::dequeue() { // Transfer function for uninitialized values analysis. //====------------------------------------------------------------------------// -static const bool Initialized = false; -static const bool Uninitialized = true; - namespace { class FindVarResult { const VarDecl *vd; -- 2.40.0