[cfe-dev] Where are the methods, which handle the Element Region’s index, in Clang Static Analyzer?

Arthur Yoo phjy007 at gmail.com
Tue Oct 29 19:31:49 PDT 2013


Hi all,


ElementRegion has a field named *Index (NoLoc) *to record the index of that
Array Element. We can also use pointer offset operation to calculate a new
index and get the corresponding array element. For example:

1 void func() {

2    int arr[10];

3     int *ptr, *ptr2;

4     ptr = arr;

5     ptr = ptr + 3;

6     *ptr = 9;

7     ptr2 = ptr + 1;

8     *ptr2 = 10;

9 }


Line 5 shows the pointer offset operation. I dumped the information of the
pointee MemRegion referenced by ptr, the Static Analyzer gave me such
result: element{arr,3 S32b,int}. That means after the pointer offset
operation by line 5, the ptr’s pointee MemRegion became an ElementRegion of
arr[], which index was *3 S32b*. The line 7’s effect is same, it showed me
element{arr,4 S32b,int}. Obviously, after the pointer offset operation, the
ElementRegion’s Index will be changed. I want to know where are the methods
that handle the Element Region’s index in pointer offset operation. Cause I
want to find these methods and add some codes into them.

Thanks a lot.

-- 
Best regards,
Arthur Yoo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131030/42a50fef/attachment.html>


More information about the cfe-dev mailing list