[cfe-commits] r46624 - /cfe/trunk/Analysis/RValues.h
Ted Kremenek
kremenek at apple.com
Thu Jan 31 14:17:04 PST 2008
Author: kremenek
Date: Thu Jan 31 16:17:03 2008
New Revision: 46624
URL: http://llvm.org/viewvc/llvm-project?rev=46624&view=rev
Log:
Added skeleton for new LValue class ConcereteIntLValue.
Modified:
cfe/trunk/Analysis/RValues.h
Modified: cfe/trunk/Analysis/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.h?rev=46624&r1=46623&r2=46624&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.h (original)
+++ cfe/trunk/Analysis/RValues.h Thu Jan 31 16:17:03 2008
@@ -217,7 +217,8 @@
class LValue : public RValue {
protected:
- LValue(unsigned SubKind, void* D) : RValue(D, true, SubKind) {}
+ LValue(unsigned SubKind, const void* D) : RValue(const_cast<void*>(D),
+ true, SubKind) {}
public:
void print(std::ostream& Out) const;
@@ -231,49 +232,6 @@
return V->getBaseKind() == LValueKind;
}
};
-
-//==------------------------------------------------------------------------==//
-// Subclasses of LValue.
-//==------------------------------------------------------------------------==//
-
-enum LValueKind { SymbolicLValueKind, LValueDeclKind, NumLValueKind };
-
-class SymbolicLValue : public LValue {
-public:
- SymbolicLValue(unsigned SymID)
- : LValue(SymbolicLValueKind, 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() == SymbolicLValueKind;
- }
-};
-
-class LValueDecl : public LValue {
-public:
- LValueDecl(const ValueDecl* vd)
- : LValue(LValueDeclKind,const_cast<ValueDecl*>(vd)) {}
-
- ValueDecl* getDecl() const {
- return static_cast<ValueDecl*>(getRawPtr());
- }
-
- inline bool operator==(const LValueDecl& R) const {
- return getDecl() == R.getDecl();
- }
-
- inline bool operator!=(const LValueDecl& R) const {
- return getDecl() != R.getDecl();
- }
-
- // Implement isa<T> support.
- static inline bool classof(const RValue* V) {
- return V->getSubKind() == LValueDeclKind;
- }
-};
//==------------------------------------------------------------------------==//
// Subclasses of NonLValue.
@@ -363,6 +321,87 @@
return V->getSubKind() == ConcreteIntKind;
}
};
+
+//==------------------------------------------------------------------------==//
+// Subclasses of LValue.
+//==------------------------------------------------------------------------==//
+
+enum LValueKind { SymbolicLValueKind, LValueDeclKind,
+ConcreteIntLValueKind, NumLValueKind };
+
+class SymbolicLValue : public LValue {
+public:
+ SymbolicLValue(unsigned SymID)
+ : LValue(SymbolicLValueKind, 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() == SymbolicLValueKind;
+ }
+};
+
+class LValueDecl : public LValue {
+public:
+ LValueDecl(const ValueDecl* vd) : LValue(LValueDeclKind,vd) {}
+
+ ValueDecl* getDecl() const {
+ return static_cast<ValueDecl*>(getRawPtr());
+ }
+
+ inline bool operator==(const LValueDecl& R) const {
+ return getDecl() == R.getDecl();
+ }
+
+ inline bool operator!=(const LValueDecl& R) const {
+ return getDecl() != R.getDecl();
+ }
+
+ // Implement isa<T> support.
+ static inline bool classof(const RValue* V) {
+ return V->getSubKind() == LValueDeclKind;
+ }
+};
+
+class ConcreteIntLValue : public LValue {
+public:
+ ConcreteIntLValue(const llvm::APSInt& V) : LValue(ConcreteIntLValueKind, &V) {}
+
+ const llvm::APSInt& getValue() const {
+ return *static_cast<llvm::APSInt*>(getRawPtr());
+ }
+
+ // Arithmetic operators.
+
+ ConcreteIntLValue Add(ValueManager& ValMgr, const ConcreteInt& V) const {
+ return ValMgr.getValue(getValue() + V.getValue());
+ }
+
+ ConcreteIntLValue Sub(ValueManager& ValMgr, const ConcreteInt& V) const {
+ return ValMgr.getValue(getValue() - V.getValue());
+ }
+
+ // Equality operators.
+
+ ConcreteInt EQ(ValueManager& ValMgr, const ConcreteIntLValue& V) const {
+ const llvm::APSInt& Val = getValue();
+ return ValMgr.getValue(Val == V.getValue() ? 1U : 0U,
+ Val.getBitWidth(), Val.isUnsigned());
+ }
+
+ ConcreteInt NE(ValueManager& ValMgr, const ConcreteIntLValue& V) const {
+ const llvm::APSInt& Val = getValue();
+ return ValMgr.getValue(Val != V.getValue() ? 1U : 0U,
+ Val.getBitWidth(), Val.isUnsigned());
+ }
+
+ // Implement isa<T> support.
+ static inline bool classof(const RValue* V) {
+ return V->getSubKind() == ConcreteIntLValueKind;
+ }
+};
} // end clang namespace
More information about the cfe-commits
mailing list