[cfe-commits] r46815 - /cfe/trunk/Analysis/GRConstants.cpp

Ted Kremenek kremenek at apple.com
Wed Feb 6 09:56:00 PST 2008


Author: kremenek
Date: Wed Feb  6 11:56:00 2008
New Revision: 46815

URL: http://llvm.org/viewvc/llvm-project?rev=46815&view=rev
Log:
Added main transfer function support for unary operator "!".

Modified:
    cfe/trunk/Analysis/GRConstants.cpp

Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46815&r1=46814&r2=46815&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Feb  6 11:56:00 2008
@@ -626,6 +626,28 @@
         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));





More information about the cfe-commits mailing list