@@ -336,7 +336,8 @@ class FatPointer extends TFatPointer {
336336}
337337
338338/**
339- * A table with headers (start pointer, end pointer, source offset, sink offset, length).
339+ * A table with headers (start pointer, end pointer, source offset, sink offset, accumulated
340+ * offset up to now, length).
340341 *
341342 * Consider the following code:
342343 * ``` C++
@@ -366,8 +367,16 @@ class FatPointer extends TFatPointer {
366367 *
367368 * The predicate also implements the following equations:
368369 *
369- * - currentOffset_0 = srcOffset + sinkOffset if src is an ArrayAllocation
370- * - currentOffset_{n} = currentOffset_{n-1} + sinkOffset if src is a PointerFormation
370+ * - currentOffset_0 = srcOffset_0 + sinkOffset_0 if src is an ArrayAllocation
371+ * - currentOffset_n = currentOffset_{n-1} + sinkOffset_n if src is a PointerFormation
372+ *
373+ * Note that for n-dimensional stack-initialized arrays, the length information is created for each
374+ * initialization level. For example, the below 2-dimensional array produces two `def. of buf` with
375+ * length 2 and length 3, respectively.
376+ *
377+ * ``` C++
378+ * int buf[2][3] = {{1, 2, 3}, {4, 5, 6}}
379+ * ```
371380 */
372381predicate srcSinkLengthMap (
373382 FatPointer start , FatPointer end , int srcOffset , int sinkOffset , int currentOffset , int length
@@ -383,7 +392,7 @@ predicate srcSinkLengthMap(
383392 /* Implement the equation that computes the current offset. */
384393 (
385394 /* Base case: The object is allocated and a fat pointer created. */
386- length = start .asAllocated ( ) .getLength ( src .getNode ( ) ) and
395+ length = start .asAllocated ( ) .getLength ( src .getNode ( ) ) and // Get the length at the given indirection level.
387396 currentOffset = srcOffset + sinkOffset
388397 or
389398 /* Recursive case: A fat pointer is derived from a fat pointer. */
0 commit comments