<div dir="ltr">Is this OK?<br><br>Index: lib/Analysis/GRExprEngine.cpp<br>===================================================================<br>--- lib/Analysis/GRExprEngine.cpp       (revision 57240)<br>+++ lib/Analysis/GRExprEngine.cpp       (working copy)<br>
@@ -1132,9 +1132,9 @@<br>           case 5:<br>             if (!memcmp(s, "panic", 5)) Builder->BuildSinks = true;<br>             else if (!memcmp(s, "error", 5)) {<br>-              Expr* Arg = *CE->arg_begin();<br>
-              if (IntegerLiteral* IL = dyn_cast<IntegerLiteral>(Arg))<br>-                if (IL->getValue() != 0)<br>+              RVal X = GetRVal(St, *CE->arg_begin());<br>+              if (nonlval::ConcreteInt* CI = dyn_cast<nonlval::ConcreteInt>(&X))<br>
+                if (CI->getValue() != 0)<br>                   Builder->BuildSinks = true;<br>             }<br>             break;<br><br><br><div class="gmail_quote">On Wed, Oct 8, 2008 at 12:49 AM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</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 class="Ih2E3d"><br>
On Oct 7, 2008, at 3:06 AM, Zhongxing Xu wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
            if (!memcmp(s, "panic", 5)) Builder->BuildSinks = true;<br>
+            else if (!memcmp(s, "error", 5)) {<br>
+              Expr* Arg = *CE->arg_begin();<br>
+              if (IntegerLiteral* IL = dyn_cast<IntegerLiteral>(Arg))<br>
+                if (IL->getValue() != 0)<br>
+                  Builder->BuildSinks = true;<br>
+            }<br>
            break;<br>
</blockquote>
<br>
<br></div>
Hi Zhongxing,<br>
<br>
I think this code will crash if error() isn't passed any arguments.  It should check to see if error() has the number of arguments that you expect.<br>
<br>
Also, is there a reason you check the AST node for an IntegerLiteral instead of just consulting the value of 'CE' that is in the state?  You'll get far more accurate information by looking at the semantics of the argument instead of its syntax.<br>

<br>
For example, checking for an integer literal will miss the following cases:<br>
<br>
  error(1 - 1);<br>
<br>
  error((1));  // note the '()'<br>
<br>
  x = 1;<br>
  error(x);<br>
<br>
I think just doing GetRVal(St, CE) should do the trick.<br><font color="#888888">
<br>
Ted<br>
<br>
</font></blockquote></div><br></div>