]> granicus.if.org Git - clang/commitdiff
Introduce 'DefinedSVal', an intermediate parent class between Loc/NonLoc and
authorTed Kremenek <kremenek@apple.com>
Mon, 24 Aug 2009 22:41:15 +0000 (22:41 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 24 Aug 2009 22:41:15 +0000 (22:41 +0000)
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

index dce2600865dc164e397dcfd1ff1602b13490f661..4371e31fadaa1a0c4c2ed0e38d2a3a02f38f2ce7 100644 (file)
@@ -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.