[cfe-dev] [analyzer] Modeling a function with an out parameter pointer in check::PostCall

via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 15 17:56:54 PDT 2020


On Sun, Jun 14, 2020 at 2:05 AM Artem Dergachev <noqnoqneo at gmail.com> wrote:

> > How do I get the SVal for the memory pointed to by
> CallEvent::getArgSVal(0)?
>
> ProgramState::getSVal (the overload that accepts the location/region).
>

Thanks, that was it. I would never have thought that SVal ->
SVal::getAsRegion() -> ProgramState::getSVal() would have ended up with
anything but the original SVal, but there it is!

Generally i recommend checking out a few links at the bottom of
> http://clang-analyzer.llvm.org/checker_dev_manual.html
>

Speaking of that... would you be interested in merging my PR
https://github.com/haoNoQ/clang-analyzer-guide/pull/5 and some of the other
open PRs on the handbook, and releasing a new version? Depending on how
much of a hassle it is, I might be interested to make it publish as HTML to
GitHub Pages automatically so you wouldn't have to release PDFs...

14.06.2020 12:05 AM, via cfe-dev wrote:
>
> Hi list,
>
> I am writing a static analyzer checker and trying to model a function of
> the following type in check::PostCall:
>
> void func(bool* outParam) {
>     assert(outParam);
>     *outParam = true;
> }
>
> (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)
>
> 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)?
>
> 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.
>
> Best regards,
> --
> Philip
>
> _______________________________________________
> cfe-dev mailing listcfe-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
>
Regards,
-- 
Philip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200615/c5f00c9b/attachment.html>


More information about the cfe-dev mailing list