[cfe-dev] [analyzer] How to detect a block inside which SVal is used?

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 20 10:41:24 PDT 2020


There was a plan to handle this stuff with LocationContexts but it's 
currently stuck (https://reviews.llvm.org/D19979). I.e., when we enter a 
scope, we can put another LocationContext on the stack that'll indicate 
that we're in that scope, and when we exit the scope we remove it.

You can still figure this out syntactically by exploring parent 
statements of the current statement via ParentMap. This should work 
fairly well.

Given that nobody needed this particular functionality so far: what are 
you trying to achieve? 'Cause your high-level goal sounds extraordinary 
enough to discuss *before* discussing implementation details.


On 20.07.2020 08:28, Denis Petrov via cfe-dev wrote:
>
>  How to detect a block inside which SVal is used in a path-sensitive way?
>
>
> E.g.
>
>     void foo(int x) // Here `x` has a Symbolic representation (e.g.
>     reg_$0<int x>)
>     {
>       // block 1
>       {
>         int y = x; // Here I want to know that `x` is usedinside a
>     simple block
>       }
>
>       // block 2
>     if(){
>         int y = x; ​ // Here I want to know that `x` is usedinside
>     if-true-block
>       }
>
>       // block 3
>     while(){
>         int y = x; // Here ​I want to know that `x` is used inside
>     while-loop-body
>       }
>     }
>
> ​I'm fighting with this sereval days. Insensitive 
> way (checkASTCodeBody) is quite poor and not the case.
>
>
> ​Thanks.
>
>
>
> ------------------------------------------------------------------------
> *Denys Petrov*
> Senior С++ Developer | Kharkiv, Ukraine
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200720/b04f3706/attachment.html>


More information about the cfe-dev mailing list