[cfe-dev] [analyzer] Binding address-of globals

Rafael·Stahl via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 7 01:52:49 PDT 2018


Hi,

continuing my effort to make the analyzer understand more constants, I 
did take a look at the following case:


struct SubS {
     int *p;
};

struct S {
     struct SubS *sub;
};

struct SubS const gsubs = {
     .p = 0x80008000
};
struct S const gs = {
     .sub = &gsubs
};

int main() {
     struct SubS subs = {
         .p = 0x80008000
     };
     struct S s = {
         .sub = &subs
     };

     *s.sub->p;
     *gs.sub->p;
}

Here, the analyzer recognizes the dereference via s, but not gs. This 
seems to be the case because region information will be stored for subs, 
but not for gsubs.

I'm not sure how to solve this issue. Could we retroactively create the 
region information whenever we encounter constants like this? Or rather 
add something to the getBinding functions that manually resolves this 
case? For the latter it seems like the analyzer should already 
understand what is happening without many additions, but it's unclear to 
me how it connects.

Best regards
Rafael


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5449 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180607/72e8e846/attachment.bin>


More information about the cfe-dev mailing list