aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/Support/ExprDeclBitVector.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-13 16:55:07 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-13 16:55:07 +0000
commit7cb15939e08ea31f0fadcd24c974dbc9e4b61c01 (patch)
tree5d8f5dc89c52ac85afeb1bc35d98b70313074149 /include/clang/Analysis/Support/ExprDeclBitVector.h
parent043a0b50a2a7a29c78a1ffb774f6fca8baf464a0 (diff)
The LiveVariables analysis no longer requires a FunctionDecl&; this allows it
to be run on other declarations of blocks of code (e.g., Objective-C methods.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/Support/ExprDeclBitVector.h')
-rw-r--r--include/clang/Analysis/Support/ExprDeclBitVector.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/include/clang/Analysis/Support/ExprDeclBitVector.h b/include/clang/Analysis/Support/ExprDeclBitVector.h
index dc634df5ed..558331e32e 100644
--- a/include/clang/Analysis/Support/ExprDeclBitVector.h
+++ b/include/clang/Analysis/Support/ExprDeclBitVector.h
@@ -28,6 +28,21 @@ namespace clang {
struct DeclBitVector_Types {
+ class Idx {
+ unsigned I;
+ public:
+ Idx(unsigned i) : I(i) {}
+ explicit Idx() : I(~0U) {}
+
+ bool isValid() const {
+ return I != ~0U;
+ }
+ operator unsigned() const {
+ assert (isValid());
+ return I;
+ }
+ };
+
//===--------------------------------------------------------------------===//
// AnalysisDataTy - Whole-function meta data.
//===--------------------------------------------------------------------===//
@@ -48,10 +63,9 @@ struct DeclBitVector_Types {
bool isTracked(const ScopedDecl* SD) { return DMap.find(SD) != DMap.end(); }
- unsigned getIdx(const ScopedDecl* SD) const {
+ Idx getIdx(const ScopedDecl* SD) const {
DMapTy::const_iterator I = DMap.find(SD);
- assert (I != DMap.end());
- return I->second;
+ return I == DMap.end() ? Idx() : Idx(I->second);
}
unsigned getNumDecls() const { return NDecls; }
@@ -84,13 +98,21 @@ struct DeclBitVector_Types {
void copyValues(const ValTy& RHS) { DeclBV = RHS.DeclBV; }
+ llvm::BitVector::reference getBit(unsigned i) {
+ return DeclBV[i];
+ }
+
+ const bool getBit(unsigned i) const {
+ return DeclBV[i];
+ }
+
llvm::BitVector::reference
operator()(const ScopedDecl* SD, const AnalysisDataTy& AD) {
- return DeclBV[AD.getIdx(SD)];
+ return getBit(AD.getIdx(SD));
}
- const llvm::BitVector::reference
- operator()(const ScopedDecl* SD, const AnalysisDataTy& AD) const {
- return const_cast<ValTy&>(*this)(SD,AD);
+
+ bool operator()(const ScopedDecl* SD, const AnalysisDataTy& AD) const {
+ return getBit(AD.getIdx(SD));
}
llvm::BitVector::reference getDeclBit(unsigned i) { return DeclBV[i]; }