From: Ted Kremenek Date: Fri, 22 Feb 2008 00:54:56 +0000 (+0000) Subject: Added "assumption" logic for lval::FuncVal and lval::GotoLabel, and simplified X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc3936b0557ce7377905b387d3c69bc8fa484b9c;p=clang Added "assumption" logic for lval::FuncVal and lval::GotoLabel, and simplified assumption logic for lval::DeclVal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47466 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 6635b0b6a6..2931d2aa6d 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -1155,6 +1155,8 @@ GRExprEngine::StateTy GRExprEngine::Assume(StateTy St, LVal Cond, case lval::DeclValKind: + case lval::FuncValKind: + case lval::GotoLabelKind: isFeasible = Assumption; return St; diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp index 02df7a5b64..775d099ab7 100644 --- a/Analysis/GRSimpleVals.cpp +++ b/Analysis/GRSimpleVals.cpp @@ -233,13 +233,9 @@ RVal GRSimpleVals::EvalEQ(ValueManager& ValMgr, LVal L, LVal R) { } case lval::DeclValKind: - - if (isa(R)) { - bool b = cast(L) == cast(R); - return NonLVal::MakeIntTruthVal(ValMgr, b); - } - - break; + case lval::FuncValKind: + case lval::GotoLabelKind: + return NonLVal::MakeIntTruthVal(ValMgr, L == R); } return NonLVal::MakeIntTruthVal(ValMgr, false); @@ -288,12 +284,9 @@ RVal GRSimpleVals::EvalNE(ValueManager& ValMgr, LVal L, LVal R) { } case lval::DeclValKind: - if (isa(R)) { - bool b = cast(L) == cast(R); - return NonLVal::MakeIntTruthVal(ValMgr, b); - } - - break; + case lval::FuncValKind: + case lval::GotoLabelKind: + return NonLVal::MakeIntTruthVal(ValMgr, L != R); } return NonLVal::MakeIntTruthVal(ValMgr, true); diff --git a/include/clang/Analysis/PathSensitive/RValues.h b/include/clang/Analysis/PathSensitive/RValues.h index df23431e4b..f6403949c0 100644 --- a/include/clang/Analysis/PathSensitive/RValues.h +++ b/include/clang/Analysis/PathSensitive/RValues.h @@ -60,6 +60,11 @@ public: return getRawKind() == R.getRawKind() && Data == R.Data; } + + inline bool operator!=(const RVal& R) const { + return !(*this == R); + } + static RVal GetSymbolValue(SymbolManager& SymMgr, ParmVarDecl *D); inline bool isUnknown() const {