From c3a94151d12e3821f760e1e342f719ddeebeea19 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 24 Aug 2009 22:41:15 +0000 Subject: [PATCH] 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 --- include/clang/Analysis/PathSensitive/SVals.h | 21 +++++++++++++++----- 1 file 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 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(D), true, SubKind) {} + : DefinedSVal(const_cast(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 support. -- 2.40.0