Cydox wrote:

Also see these comments in the main function of the same test file:
```C
int main ()
{
  struct annotated *p, *q;
  p = alloc_buf_more (10);
  q = alloc_buf_less (10);

  /* When checking the access p->array, we only have info on the counted-by
    value.  */ 
  EXPECT(__builtin_dynamic_object_size(p->array, 0), p->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(p->array, 1), p->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(p->array, 2), p->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(p->array, 3), p->foo * sizeof(char));
  /* When checking the pointer p, we have no observed allocation nor observed
    access, therefore, we cannot determine the size info here.  */
  EXPECT(__builtin_dynamic_object_size(p, 0), -1);
  EXPECT(__builtin_dynamic_object_size(p, 1), -1);
  EXPECT(__builtin_dynamic_object_size(p, 2), 0);
  EXPECT(__builtin_dynamic_object_size(p, 3), 0);

  /* When checking the access p->array, we only have info on the counted-by
    value.  */ 
  EXPECT(__builtin_dynamic_object_size(q->array, 0), q->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(q->array, 1), q->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(q->array, 2), q->foo * sizeof(char));
  EXPECT(__builtin_dynamic_object_size(q->array, 3), q->foo * sizeof(char));
  /* When checking the pointer p, we have no observed allocation nor observed
    access, therefore, we cannot determine the size info here.  */
  EXPECT(__builtin_dynamic_object_size(q, 0), -1);
  EXPECT(__builtin_dynamic_object_size(q, 1), -1);
  EXPECT(__builtin_dynamic_object_size(q, 2), 0);
  EXPECT(__builtin_dynamic_object_size(q, 3), 0);

  DONE ();
}
```

https://github.com/llvm/llvm-project/pull/111015
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to