[cfe-commits] r46814 - in /cfe/trunk/Analysis: GRConstants.cpp RValues.cpp RValues.h
Ted Kremenek
kremenek at apple.com
Wed Feb 6 09:32:18 PST 2008
Author: kremenek
Date: Wed Feb 6 11:32:17 2008
New Revision: 46814
URL: http://llvm.org/viewvc/llvm-project?rev=46814&view=rev
Log:
Added assumption logic for symbolic non-lvalues when used in conditions such as
"if(x)". On the true branch we know the value is != 0, and on the false branch
we know it is 0.
Modified:
cfe/trunk/Analysis/GRConstants.cpp
cfe/trunk/Analysis/RValues.cpp
cfe/trunk/Analysis/RValues.h
Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46814&r1=46813&r2=46814&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Feb 6 11:32:17 2008
@@ -898,6 +898,19 @@
assert (false && "'Assume' not implemented for this NonLValue.");
return St;
+
+ case nonlval::SymbolValKind: {
+ lval::SymbolVal& SV = cast<lval::SymbolVal>(Cond);
+ SymbolID sym = SV.getSymbol();
+
+ if (Assumption)
+ return AssumeSymNE(St, sym, ValMgr.getValue(0, SymMgr.getType(sym)),
+ isFeasible);
+ else
+ return AssumeSymEQ(St, sym, ValMgr.getValue(0, SymMgr.getType(sym)),
+ isFeasible);
+ }
+
case nonlval::SymIntConstraintValKind:
return
AssumeSymInt(St, Assumption,
Modified: cfe/trunk/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.cpp?rev=46814&r1=46813&r2=46814&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.cpp (original)
+++ cfe/trunk/Analysis/RValues.cpp Wed Feb 6 11:32:17 2008
@@ -34,6 +34,16 @@
return X;
}
+QualType SymbolData::getType() const {
+ switch (getKind()) {
+ default:
+ assert (false && "getType() not implemented for this symbol.");
+
+ case ParmKind:
+ return static_cast<ParmVarDecl*>(getPtr())->getType();
+ }
+}
+
SymbolManager::SymbolManager() {}
SymbolManager::~SymbolManager() {}
Modified: cfe/trunk/Analysis/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.h?rev=46814&r1=46813&r2=46814&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.h (original)
+++ cfe/trunk/Analysis/RValues.h Wed Feb 6 11:32:17 2008
@@ -71,7 +71,9 @@
inline Kind getKind() const { return (Kind) (Data & Mask); }
inline void* getPtr() const { return reinterpret_cast<void*>(Data & ~Mask); }
- inline bool operator==(const SymbolData& R) const { return Data == R.Data; }
+ inline bool operator==(const SymbolData& R) const { return Data == R.Data; }
+
+ QualType getType() const;
};
@@ -114,12 +116,16 @@
SymbolManager();
~SymbolManager();
- SymbolData getSymbolData(SymbolID id) const {
- assert (id < SymbolToData.size());
- return SymbolToData[id];
+ SymbolID getSymbol(ParmVarDecl* D);
+
+ inline SymbolData getSymbolData(SymbolID ID) const {
+ assert (ID < SymbolToData.size());
+ return SymbolToData[ID];
}
- SymbolID getSymbol(ParmVarDecl* D);
+ inline QualType getType(SymbolID ID) const {
+ return getSymbolData(ID).getType();
+ }
};
More information about the cfe-commits
mailing list