[cfe-commits] r59238 - /cfe/trunk/lib/Analysis/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Thu Nov 13 01:15:14 PST 2008


Author: zhongxingxu
Date: Thu Nov 13 03:15:14 2008
New Revision: 59238

URL: http://llvm.org/viewvc/llvm-project?rev=59238&view=rev
Log:
Array index might be unsigned. We have to generate a temporary signed value for
it to be evaluated by APSInt::operators.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59238&r1=59237&r2=59238&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Nov 13 03:15:14 2008
@@ -197,6 +197,18 @@
   // Only handle integer indices for now.
   if ((CI1 = dyn_cast<nonloc::ConcreteInt>(&Idx)) &&
       (CI2 = dyn_cast<nonloc::ConcreteInt>(&Offset))) {
+
+    // Temporary SVal to hold a potential signed APSInt.
+    SVal SignedInt;
+
+    // Index might be unsigned. We have to convert it to signed.
+    if (CI2->getValue().isUnsigned()) {
+      llvm::APSInt SI = CI2->getValue();
+      SI.setIsSigned(true);
+      SignedInt = nonloc::ConcreteInt(getBasicVals().getValue(SI));
+      CI2 = cast<nonloc::ConcreteInt>(&SignedInt);
+    }
+
     SVal NewIdx = CI1->EvalBinOp(StateMgr.getBasicVals(), BinaryOperator::Add,
                                  *CI2);
     return loc::MemRegionVal(MRMgr.getElementRegion(NewIdx, 





More information about the cfe-commits mailing list