[llvm-dev] How to know the sub-class of a Value class?

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 11 23:03:12 PDT 2017


Try value->dump() assuming you're using a debug build.

~Craig

On Sun, Jun 11, 2017 at 10:54 PM, Dipanjan Das via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

>
> As a concrete question, I understand 'Value' class is the parent of many
> concrete sub-classes. Let's say I retrieve a Value* value =
> store_inst->getValueOperand(). Unless I know what the sub-type is, how can
> I further use this object? I tried something like this:
>
> =================================================
>
>          Value* value = store_inst->getValueOperand()
>          errs() << value->getValueID; // Which ID corresponds to which
> sub-class?
>          errs() << value->getValueName(); // Prints numeric memory
> addresses
>          errs() << *value->getValueName(); // Doesn't compile
>
> =================================================
>
> I have mentioned the issues in each of the cases above. I am not sure if
> the approach is correct or not. Please help me out.
>
> --
>
> Thanks & Regards,
> Dipanjan
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170611/c944d8bd/attachment.html>


More information about the llvm-dev mailing list