aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-06 17:56:00 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-06 17:56:00 +0000
commitc60f0f79c962e1e91538546173d7f5ede1f5a89c (patch)
tree1b2cf80183aec3962286e3dd4cdf3488a889be14
parentfeb01f6962d393da70185cb7dbcf5f7d021c1097 (diff)
Added main transfer function support for unary operator "!".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46815 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Analysis/GRConstants.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp
index a9371ee4e6..2b44bf7df6 100644
--- a/Analysis/GRConstants.cpp
+++ b/Analysis/GRConstants.cpp
@@ -626,6 +626,28 @@ void GRConstants::VisitUnaryOperator(UnaryOperator* U,
break;
}
+ case UnaryOperator::LNot: {
+ // C99 6.5.3.3: "The expression !E is equivalent to (0==E)."
+ //
+ // Note: technically we do "E == 0", but this is the same in the
+ // transfer functions as "0 == E".
+
+ RValue V1 = GetValue(St, U->getSubExpr());
+
+ if (isa<LValue>(V1)) {
+ lval::ConcreteInt V2(ValMgr.getValue(0, U->getSubExpr()->getType()));
+ Nodify(Dst, U, N1, SetValue(St, U,
+ cast<LValue>(V1).EQ(ValMgr, V2)));
+ }
+ else {
+ nonlval::ConcreteInt V2(ValMgr.getZeroWithPtrWidth());
+ Nodify(Dst, U, N1, SetValue(St, U,
+ cast<NonLValue>(V1).EQ(ValMgr, V2)));
+ }
+
+ break;
+ }
+
case UnaryOperator::AddrOf: {
const LValue& L1 = GetLValue(St, U->getSubExpr());
Nodify(Dst, U, N1, SetValue(St, U, L1));