[cfe-commits] r47548 - /cfe/trunk/Analysis/ValueState.cpp

Ted Kremenek kremenek at apple.com
Mon Feb 25 10:34:46 PST 2008


Author: kremenek
Date: Mon Feb 25 12:34:45 2008
New Revision: 47548

URL: http://llvm.org/viewvc/llvm-project?rev=47548&view=rev
Log:
Added hack to transfer function logic to handle the case where a DeclRefExpr
wrapping an EnumConstantDecl evaluates to an integer type that has a different
signedness than the APSInt stored in the EnumConstantDecl. Will file a Bugzilla
report.

Modified:
    cfe/trunk/Analysis/ValueState.cpp

Modified: cfe/trunk/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.cpp?rev=47548&r1=47547&r2=47548&view=diff

==============================================================================
--- cfe/trunk/Analysis/ValueState.cpp (original)
+++ cfe/trunk/Analysis/ValueState.cpp Mon Feb 25 12:34:45 2008
@@ -236,7 +236,15 @@
           // already has persistent storage?  We do this because we
           // are comparing states using pointer equality.  Perhaps there is
           // a better way, since APInts are fairly lightweight.
-          return nonlval::ConcreteInt(ValMgr.getValue(ED->getInitVal()));          
+          llvm::APSInt X = ED->getInitVal();
+          
+          // FIXME: This is a hack.  The APSInt inside the EnumConstantDecl
+          //  might not match the signedness of the DeclRefExpr.  We hack
+          //  a workaround here.  Should be fixed elsewhere.
+          if (E->getType()->isUnsignedIntegerType() != X.isUnsigned())
+            X.setIsUnsigned(!X.isUnsigned());
+          
+          return nonlval::ConcreteInt(ValMgr.getValue(X));          
         }
         else if (FunctionDecl* FD = dyn_cast<FunctionDecl>(D))
           return lval::FuncVal(FD);





More information about the cfe-commits mailing list