[clang] [clang][analyzer] Preserve symbolic-offset regions across pointer casts (PR #221213)
Radovan Božić via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 06:49:04 PDT 2026
bozicrHT wrote:
> I might be just tired to see, but why is this sound (correct) to do?
With this patch, we keep the original region and add a zero-offset view of the target type.
Lets say that we have `unsigned char *q = a+i;` and `char *r = (char *)q;`, `q` is modeled as `Element{a, i, unsigned char}`. Currently, the cast cannot flatten symbolic `i`, so it becomes `UnknownVal` and may later be represented by an conjured pointer, losing its relationship with `q`. With the patch, `r` is conceptually `Element{Element{a, i, unsigned char}, 0, char}`. The zero applies only to the new cast view; the symbolic index i remains unchanged. So, `r` has the same address and nullness as `q`, but the correct target type.
https://github.com/llvm/llvm-project/pull/221213
More information about the cfe-commits
mailing list