<html><body bgcolor="#FFFFFF"><div><span class="Apple-style-span" style="-webkit-composition-fill-color: rgba(175, 192, 227, 0.231373); -webkit-composition-frame-color: rgba(77, 128, 180, 0.231373); ">On Nov 13, 2008, at 3:27 PM, Zhongxing Xu <<a href="mailto:xuzhongxing@gmail.com">xuzhongxing@gmail.com</a>> wrote:</span><br></div><div><br></div><div></div><blockquote type="cite"><div><br><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 11:03 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com"><a href="mailto:kremenek@apple.com">kremenek@apple.com</a></a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div></div><div class="Wj3C7c"><br><div><div>On Nov 13, 2008, at 1:15 AM, Zhongxing Xu wrote:</div><br><blockquote type="cite"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Author: zhongxingxu<br>
Date: Thu Nov 13 03:15:14 2008<br>New Revision: 59238<br><br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=59238&view=rev" target="_blank"><a href="http://llvm.org/viewvc/llvm-project?rev=59238&view=rev">http://llvm.org/viewvc/llvm-project?rev=59238&view=rev</a></a><br>
Log:<br>Array index might be unsigned. We have to generate a temporary signed value for<br>it to be evaluated by APSInt::operators.<br><br>Modified:<br>   cfe/trunk/lib/Analysis/RegionStore.cpp<br><br>Modified: cfe/trunk/lib/Analysis/RegionStore.cpp<br>
URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59238&r1=59237&r2=59238&view=diff" target="_blank"><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59238&r1=59237&r2=59238&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59238&r1=59237&r2=59238&view=diff</a></a><br>
<br>==============================================================================<br>--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)<br>+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Nov 13 03:15:14 2008<br>@@ -197,6 +197,18 @@<br>
  // Only handle integer indices for now.<br>  if ((CI1 = dyn_cast<nonloc::ConcreteInt>(&Idx)) &&<br>      (CI2 = dyn_cast<nonloc::ConcreteInt>(&Offset))) {<br>+<br>+    // Temporary SVal to hold a potential signed APSInt.<br>
+    SVal SignedInt;<br>+<br>+    // Index might be unsigned. We have to convert it to signed.<br>+    if (CI2->getValue().isUnsigned()) {<br>+      llvm::APSInt SI = CI2->getValue();<br>+      SI.setIsSigned(true);<br>
+      SignedInt = nonloc::ConcreteInt(getBasicVals().getValue(SI));<br>+      CI2 = cast<nonloc::ConcreteInt>(&SignedInt);<br>+    }<br>+</span></blockquote><br></div></div></div><div>Hi Zhongxing,</div><div><br>
</div><div>I'm not saying this isn't needed, but is there a particular justification for the signed -> unsigned conversion?  (I actually don't know by just looking at your patch).  It seems like things like this should go in GRExprEngine, not the Store.</div>
<div></div></div></blockquote><div><br>Consistent signedness is required by llvm::APSInt. So we should find a place to handle this. May be we should ensure all ConcreteInt be signed in GRExprEngine? <br></div></div></div></blockquote><br><div>One question I have is whether or not this conversion is specified in the C standard.  I would like to have a clean way of handling pointer arithmetic and integer overflow (which affects array indexing) and that probably should be handled in GRExprEngine.  GRExprEngine of course could delegate specific micro-operations to Store/ConstraintManager/etc as we already do now for various things.</div></body></html>