[cfe-dev] How to extract a symbol stored in LazyCompoundVal?

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 25 14:06:43 PDT 2019


The "0x4aa1c58" part of "lazyCompoundVal{0x4aa1c58,pos1}" is a Store 
object. You can access it with getStore() and then read it with the help 
of a StoreManager.

Hmm, we seem to already have a convenient API for that, you can do 
StoreManager::getDefaultBinding(nonloc::LazyCompoundVal) directly if all 
you need is a default-bound conjured symbol. But if you want to lookup, 
say, specific fields in the structure (X and Y separately), you'll need 
to do getBinding() on manually constructed FieldRegions (in your case it 
doesn't look very useful because the whole structure is conjured anyway).

I guess at this point you might like the chapter 5 of my old workbook 
(https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf), 
as for now it seems to be the only place where different kinds of values 
are explained.


On 6/25/19 2:35 AM, Torry Chen via cfe-dev wrote:
> My project has a struct type as follows and I'm writing a checker for 
> some functions that take the struct value as an argument. In the 
> checkPreCall function I see the argument is an LazyCompoundVal, not a 
> symbol as it would be for a primitive type. I tried a few ways to 
> extract the symbol from the LazyCompountVal with no luck. Hope to get 
> some help here.
>
> struct XY {
>   uint64_t X;
>   uint64_t Y;
> };
>
> ...
> // checkBind: pos1 -> conj_$3{struct XY, LC1, S63346, #1}
> struct XY pos1 = next_pos(...);
>
> // checkPreCall: Arg0: lazyCompoundVal{0x4aa1c58,pos1}
> move_to_pos(pos1);
>
> _______________________________________________
> 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/20190625/c10728b7/attachment.html>


More information about the cfe-dev mailing list