I have a list of Value* and some of them I know are PHINode*.
I could do dynamic_cast<PHINode*>(value)
and check if it casted to see if it's a PHINode* but I vaguely recall there's a better way.
I have a list of Value* and some of them I know are PHINode*.
I could do dynamic_cast<PHINode*>(value)
and check if it casted to see if it's a PHINode* but I vaguely recall there's a better way.
After a lot of looking around, these two questions indirectly answered my question
llvm apparently has a built in type checking system. There's a reference page here. It works like this
if(isa<PHINode>(value)){
PHINode* phi = cast<PHINode>(value);
}
if(PHINode* phi = dyn_cast<PHINode>(value)){//alternatively
...
}
And it does appear that you don't need to specify that it's a pointer, so it's not isa<PHINode*>
Finally, as it turns out, dynamic_cast will NOT work since they implement their own RTTI
The LLVM source-base makes extensive use of a custom form of RTTI. These templates have many similarities to the C++ dynamic_cast<> operator, but they don’t have some drawbacks (primarily stemming from the fact that dynamic_cast<> only works on classes that have a v-table).