Find the level of pointers


How can I find the level of the pointer variable? I need to differentiate between **i32 and ***i32. Is there any way to do this? getType() will return pointer type. But if I wanted to get 2 from **i32 and 3 from ***i32, is there a way?

LLVM is in the midst of converting to opaque pointers, where all pointers become a single opaque pointer type that does not indicate what the type the pointer is pointing to. Writing any new code that relies on the types that pointers point to will shortly (on the order of months) fail to work entirely.

If you’re dead-set on writing code that will work at best temporarily, you can compute the pointer level by iterating T = T->getPointerElementType() and counting how many times before you arrive at a non-pointer type.