[cfe-commits] r79951 - /cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h

Ted Kremenek kremenek at apple.com
Mon Aug 24 15:41:15 PDT 2009


Author: kremenek
Date: Mon Aug 24 17:41:15 2009
New Revision: 79951

URL: http://llvm.org/viewvc/llvm-project?rev=79951&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=79951&r1=79950&r2=79951&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Mon Aug 24 17:41:15 2009
@@ -172,10 +172,21 @@
   
   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 @@
   }
 };
 
-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.





More information about the cfe-commits mailing list