]> granicus.if.org Git - clang/commitdiff
Added hack to transfer function logic to handle the case where a DeclRefExpr
authorTed Kremenek <kremenek@apple.com>
Mon, 25 Feb 2008 18:34:45 +0000 (18:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 25 Feb 2008 18:34:45 +0000 (18:34 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47548 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/ValueState.cpp

index 7cd89fdd7e2f05be50350fbced680003d900f85e..3cbcd88d25b7ab793bdd6f235324ee1b0ce5ac40 100644 (file)
@@ -236,7 +236,15 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E, bool* hasVal) {
           // 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);