<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
> Is this possible to achieve with ProgramState::BindExpr or
ProgramState::bindLoc<br>
<br>
Yes, ProgramState::bindLoc does literally what you want. Take the
parameter region and bind the true value into that. Also if it's
really a bool you can ProgramState::assume it to be true (but you
can't do anything more specific that way).<br>
<br>
> How do I get the SVal for the memory pointed to by
CallEvent::getArgSVal(0)?<br>
<br>
ProgramState::getSVal (the overload that accepts the
location/region).<br>
<br>
> I thought of "synthesizing" a UnaryOperator expression using
UO_Deref on CallEvent::getArgExpr(0) and passing that to
ProgramState::BindExpr<br>
<br>
Apart from "don't do this", another thing you should know about
C/C++ is that operator * (aka UO_Deref) does not dereference a
pointer! - it simply converts the rvalue of the pointer into an
lvalue it points to. From the perspective of the actual behavior of
the program (or, for that matter, the static analyzer) operator * is
a no-op as both values are simply "the address of the object". In
order to actually perform a dereference you have to perform an
implicit lvalue-to-rvalue conversion on that lvalue. The same
applies to operator & that is the opposite of operator *.<br>
<br>
In any case, even if you could synthesize ASTs, i wouldn't recommend
that unless you've already been developing Sema for many years.<br>
<br>
Also BindExpr does nothing unless it's the expression that you're
currently evaluating.<br>
<br>
Generally i recommend checking out a few links at the bottom of
<a class="moz-txt-link-freetext" href="http://clang-analyzer.llvm.org/checker_dev_manual.html">http://clang-analyzer.llvm.org/checker_dev_manual.html</a><br>
<br>
<div class="moz-cite-prefix">14.06.2020 12:05 AM, via cfe-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHbXgc3Tq+j5p9CBFUUTEvSPjLdjb-GVczfoESH_Rnua6D5iqw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi list,</div>
<div><br>
</div>
<div>I am writing a static analyzer checker and trying to model
a function of the following type in check::PostCall:</div>
<div><br>
</div>
<div>void func(bool* outParam) {</div>
<div> assert(outParam);<br>
</div>
<div> *outParam = true;</div>
<div>}<br>
</div>
<div><br>
</div>
<div>(in real life there are some other inputs that determine
the value stored in the out parameter, and a return value
indicating whether there was an error, but let's use this for
the sake of a simple example)</div>
<div><br>
</div>
<div>Suppose I want my PostCall callback to store "true" in
*outParam. Is this possible to achieve with
ProgramState::BindExpr or ProgramState::bindLoc? How do I get
the SVal for the memory pointed to by
CallEvent::getArgSVal(0)?</div>
<div><br>
</div>
<div>I thought of "synthesizing" a UnaryOperator expression
using UO_Deref on CallEvent::getArgExpr(0) and passing that to
ProgramState::BindExpr, but it seems that getArgExpr returns a
const Expr* and a non-const one is required to construct a
UnaryOperator expression.</div>
<div><br>
</div>
<div>Best regards,<br>
</div>
<div>-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">Philip</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>