Mustakimur Khandaker
Mustakimur Khandaker

Reputation: 715

How to identify a Clang QualType is a function pointer?

I am trying to identify a function pointer connected to any expression. I am working in Clang code. Assume, I know the QualType of a value, and now want to know if the value is originally a function pointer, not any other. Like I want to distinguish between void (*)() and int *. Can anyone suggest what functionality (standard, not want to analyse the string) I can use?

Upvotes: 0

Views: 246

Answers (1)

Mustakimur Khandaker
Mustakimur Khandaker

Reputation: 715

We can use QualType->isFunctionPointerType(). The function isFunctionPointerType is actually part of Type class. QualType’s dereference operator returns a Type*, so we use -> to call the function isFunctionPointerType.

Credit: The question is originally answered by Sam McCall and Keane, Erich from cfe-dev mailing list

Thanks

Upvotes: 1

Related Questions