[cfe-dev] Get the type of pointer

Jacob Carlborg doob at me.com
Tue Oct 16 23:47:44 PDT 2012


On 2012-10-16 23:02, Manuel Klimek wrote:
> +cfe-dev :)
>
> On Tue, Oct 16, 2012 at 10:10 PM, sunil rathee <ratheesuniljec at gmail.com
> <mailto:ratheesuniljec at gmail.com>> wrote:
>
>     Type of the pointer means if it points to integer then it is Integer
>     pointer.
>     I am writing a pass in which I want to find all those pointers which
>     are pointing to pointers. Also I want to find the type of pointer
>     which I defined above.
>
>
> I'm still unsure of the exact context you have, but others who know more
> about writing passes might be able to help.

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.

-- 
/Jacob Carlborg




More information about the cfe-dev mailing list