]> granicus.if.org Git - clang/commitdiff
Minor tweaking with hierarchy of NonLValue objects: SymbolValue is
authorTed Kremenek <kremenek@apple.com>
Mon, 28 Jan 2008 22:25:21 +0000 (22:25 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 28 Jan 2008 22:25:21 +0000 (22:25 +0000)
now SymbolicNonLValue.

Cleaned up some casts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46467 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRConstants.cpp

index 1b2545a3fd3a3bf683be0c712b513331ce38cecc..d28140287b175a138e3a54499c74f85b95589cd9 100644 (file)
@@ -48,7 +48,7 @@ using llvm::APSInt;
 //===----------------------------------------------------------------------===//
 namespace {
 
-typedef uintptr_t SymbolID;
+typedef unsigned SymbolID;
   
 class VISIBILITY_HIDDEN ValueKey {
   uintptr_t Raw;  
@@ -70,7 +70,7 @@ public:
   
   inline SymbolID getSymbolID() const {
     assert (getKind() == IsSymbol);
-    return Raw >> 2;
+    return (SymbolID) (Raw >> 2);
   }
   
   ValueKey(const ValueDecl* VD)
@@ -94,7 +94,7 @@ public:
     ID.AddInteger(isSymbol() ? 1 : 0);
 
     if (isSymbol())
-      ID.AddInteger((uint64_t) getSymbolID());
+      ID.AddInteger(getSymbolID());
     else    
       ID.AddPointer(getPtr());
   }
@@ -204,32 +204,24 @@ namespace {
 class VISIBILITY_HIDDEN RValue {
 public:
   enum BaseKind { InvalidKind=0x0, LValueKind=0x1, NonLValueKind=0x2,
-                  SymbolKind=0x3, BaseFlags = 0x3 };
+                  BaseFlags = 0x3 };
     
 private:
-  uintptr_t Data;
+  void* Data;
   unsigned Kind;
     
 protected:
   RValue(const void* d, bool isLValue, unsigned ValKind)
-    : Data(reinterpret_cast<uintptr_t>(const_cast<void*>(d))),
+    : Data(const_cast<void*>(d)),
       Kind((isLValue ? LValueKind : NonLValueKind) | (ValKind << 2)) {}
   
   explicit RValue()
     : Data(0), Kind(InvalidKind) {}
-  
-  explicit RValue(unsigned SymID)
-    : Data(SymID), Kind(SymbolKind) {}
-    
+
   void* getRawPtr() const {
-    assert (getBaseKind() != InvalidKind && getBaseKind() != SymbolKind);
     return reinterpret_cast<void*>(Data);
   }
   
-  uintptr_t getRawData() const {
-    return Data;
-  }
-  
 public:
   ~RValue() {};
 
@@ -267,19 +259,6 @@ public:
   }  
 };
 
-class VISIBILITY_HIDDEN SymbolValue : public RValue {
-public:
-  SymbolValue(unsigned SymID) : RValue(SymID) {}
-  
-  unsigned getID() const {
-    return (unsigned) getRawData();
-  }
-  
-  static inline bool classof(const RValue* V) {
-    return V->getBaseKind() == SymbolKind;
-  }  
-};
-
 class VISIBILITY_HIDDEN LValue : public RValue {
 protected:
   LValue(unsigned SubKind, void* D) : RValue(D, true, SubKind) {}
@@ -347,7 +326,23 @@ public:
 
 namespace {
   
-enum { ConcreteIntKind, ConstrainedIntegerKind, NumNonLValueKind };
+enum { SymbolicNonLValueKind, ConcreteIntKind, ConstrainedIntegerKind,
+       NumNonLValueKind };
+
+class VISIBILITY_HIDDEN SymbolicNonLValue : public NonLValue {
+public:
+  SymbolicNonLValue(unsigned SymID)
+    : NonLValue(SymbolicNonLValueKind,
+                reinterpret_cast<void*>((uintptr_t) SymID)) {}
+  
+  SymbolID getSymbolID() const {
+    return (SymbolID) reinterpret_cast<uintptr_t>(getRawPtr());
+  }
+  
+  static inline bool classof(const RValue* V) {
+    return V->getSubKind() == SymbolicNonLValueKind;
+  }  
+};
   
 class VISIBILITY_HIDDEN ConcreteInt : public NonLValue {
 public: