diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-24 22:41:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-24 22:41:15 +0000 |
commit | c3a94151d12e3821f760e1e342f719ddeebeea19 (patch) | |
tree | 67aa576c5e6be480ba37920faf6cea3cbd830c62 | |
parent | 55a1846bf4b2f83423ce832d30718e20e48dcc12 (diff) |
Introduce 'DefinedSVal', an intermediate parent class between Loc/NonLoc and
SVal. This allows us to use the C++ type system to distinguish between SVals
that are potentially unknown/undefined and those that are not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79951 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/PathSensitive/SVals.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h index dce2600865..4371e31fad 100644 --- a/include/clang/Analysis/PathSensitive/SVals.h +++ b/include/clang/Analysis/PathSensitive/SVals.h @@ -172,10 +172,21 @@ public: void* getData() const { return Data; } }; + +class DefinedSVal : public SVal { +protected: + DefinedSVal(const void* d, bool isLoc, unsigned ValKind) + : SVal(d, isLoc, ValKind) {} + + // Implement isa<T> support. + static inline bool classof(const SVal *V) { + return !V->isUnknownOrUndef(); + } +}; -class NonLoc : public SVal { +class NonLoc : public DefinedSVal { protected: - NonLoc(unsigned SubKind, const void* d) : SVal(d, false, SubKind) {} + NonLoc(unsigned SubKind, const void* d) : DefinedSVal(d, false, SubKind) {} public: void dumpToStream(llvm::raw_ostream& Out) const; @@ -186,15 +197,15 @@ public: } }; -class Loc : public SVal { +class Loc : public DefinedSVal { protected: Loc(unsigned SubKind, const void* D) - : SVal(const_cast<void*>(D), true, SubKind) {} + : DefinedSVal(const_cast<void*>(D), true, SubKind) {} public: void dumpToStream(llvm::raw_ostream& Out) const; - Loc(const Loc& X) : SVal(X.Data, true, X.getSubKind()) {} + Loc(const Loc& X) : DefinedSVal(X.Data, true, X.getSubKind()) {} Loc& operator=(const Loc& X) { memcpy(this, &X, sizeof(Loc)); return *this; } // Implement isa<T> support. |