I'm writing a checker for clang-tidy, which checks cast between int and pointer.
for example, for code:
int val = 0xbaddeef;
char* ptr = (char*)val;
I want to fix it to:
char* ptr = (char*)(uintptr_t)val;
But if a
is already uintptr_t
, I don't fix it.
typedef uintptr_t myType;
myType val = 0xbaddeef;
char* ptr = (char*)val;
My question is that I matched the CStyleCastExpr
and get the match result, but I can't get the source type of the cast, I use CStyleCastExpr.getSubExpr().getType().getXXXXType()
, I get the type of val
is myType
or long/int
, but not uintptr_t
.
how can I know val
is a type of uintptr_t
?