[cfe-dev] How can I get the MemRegion representing an index of an array in Clang Static Analyzer?

Jordan Rose jordan_rose at apple.com
Wed May 7 21:05:15 PDT 2014


Hi, Arthur. I don't understand what you mean about the MemRegion for 'a'. 'a' is an integer variable, and when it's used in line 5 (not 3) you'll just get its value back, which will be 2. The expression "arr[a][1]" should give you an ElementRegion for "&arr[2][1]", but at that point 'a' isn't involved any more. Once a value is loaded from a variable (by an LValueToRValue implicit conversion), the variable isn't really interesting anymore. What are you actually trying to do?

Jordan

On May 7, 2014, at 5:09 , Arthur Yoo <phjy007 at gmail.com> wrote:

> Hi all,
> 
> I want to get the MemRegion representing an index of an array in my checker. For example:
> 
> 1 void func() {
> 
> 2     int a, b, arr[10][10];
> 
> 3     a = 2;
> 
> 4     b = 3;
> 
> 3    arr[a][1] = 3;
> 
> 4 }
> 
>  
> In the CheckLocation() method for checking the store operation at line 3 ‘arr[a][1] = 3;’, I want to get the MemRegion and SVal of variable a, which is the index of the array. Is there any way to get the corresponding MemRegion and SVal of variable a.
> 
> My previous mail post on a related problem is http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036205.html. Unfortunately, there was no reply or solution. In fact, this problem has trapped me for several weeks. So I really need help.
> 
> Any help would be greatly appreciated.
> 
> 
> -- 
> Best regards,
> Arthur Yoo
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

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


More information about the cfe-dev mailing list