Tracking pointer assignment tracking with Clang


I’m very new to the LLVM and Clang.
Be aware that my question might be very basic or not making sense.

Is it possible to track whether the pointer variable has been assigned to other pointer?
such as alias pointer.

More detail,
I want to inspect the code that whether there exist a array of pointer in the code or
assigning a pointer to the array value.

Such as under C,

int ** ptr_array = (int **)malloc(sizeof(int*)*2);
int * ptr = (int *)malloc(sizeof(int) *4);

ptr_array[0] = ptr;  <- what i want to track

Also, i wan to track whether the “ptr_arrary” has been passed to the other function as an argument.

Thanks for your patients and understandings.


You may wish to look at the TypeBasedAliasAnalysis pass and the TBAA metadata it consumes.

By reading the post, the motivation is not entirely clear to me. I think the next step would be to clarify the context and why you want to do. After that we have a better chance of suggesting solutions.
Maybe, in addition to the motivation, a few more short examples could underpin the motivation.