Get the type of pointer

Hi,
Is there any solution by which we can find the type of the pointer. Means can we find is it Integer pointer or Double pointer etc.
Also can we find is it pointing to another pointer or not?

Hi,
Is there any solution by which we can find the type of the pointer. Means
can we find is it Integer pointer or Double pointer etc.
Also can we find is it pointing to another pointer or not?

Assuming you mean in the Clang AST, but I'm not sure what you mean with
"find the type of the pointer". What do you have? A pointer declaration? An
expression? A PointerType and you want to figure out more about it (if the
latter, see http://clang.llvm.org/doxygen/classclang_1_1PointerType.html)

Cheers,
/Manuel

+cfe-dev :slight_smile:

With the C interface in libclang, this is how you would do it:

CXType type = clang_getCursorType(cursor);

if (type == CXType_Pointer)
{
     CXType pointerType = clang_getPointeeType();
     // ...
}

You can have a look at how these C functions are implemented. If think they're located in the "tools" directory.

Should of course be:

CXType pointeeType = clang_getPointeeType(type);