<div dir="ltr">Hi Michael,<div><br></div><div>Thanks for the help, it seems like you said its not going to be easy. But I will have a try at this, thank you for the link to LibTooling.</div><div><br></div><div>Best</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, May 21, 2018 at 6:26 PM Dean Michael Berris <<a href="mailto:dean.berris@gmail.com">dean.berris@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On 21 May 2018, at 18:38, Ridwan Shariffdeen via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi,<br>
> <br>
> I want to retrieve the variable names used in a statement, I tried the following snippet, <br>
> but it only gives me the variable named in llvm bitcode. I need the variable name in source code. <br>
> <br>
> for (auto op = I.op_begin(); op != I.op_end(); op++) {<br>
> Value* v = op->get();<br>
> StringRef name = v->getName();<br>
> }<br>
> <br>
> Is there specific documentation I can refer to implement this?<br>
> <br>
<br>
If the source language is something clang knows about, you may have to implement that on top of libTooling, part of clang. Unfortunately it’s not quite straight-forward to get to the source from the LLVM — you’re going to have to rely on a reverse-mapping from the LLVM IR to the higher-level source location, which *might* be doable if there’s debug information associated with the LLVM IR.<br>
<br>
<a href="https://clang.llvm.org/docs/LibTooling.html" rel="noreferrer" target="_blank">https://clang.llvm.org/docs/LibTooling.html</a><br>
<br>
Cheers<br>
<br>
-- Dean<br>
<br>
</blockquote></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b style="color:rgb(100,100,100);font-family:arial,sans-serif;font-size:14px">Ridwan Shariffdeen</b><br style="color:rgb(100,100,100);font-family:arial,sans-serif;font-size:14px"><span style="color:rgb(100,100,100);font-family:garamond,serif;font-size:small"><span class="inbox-inbox-inbox-inbox-gr_ inbox-inbox-inbox-inbox-gr_131 inbox-inbox-inbox-inbox-gr-alert inbox-inbox-inbox-inbox-gr_spell inbox-inbox-inbox-inbox-gr_inline_cards inbox-inbox-inbox-inbox-gr_run_anim inbox-inbox-inbox-inbox-ContextualSpelling inbox-inbox-inbox-inbox-ins-del inbox-inbox-inbox-inbox-multiReplace" id="inbox-inbox-inbox-inbox-131" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">Graduate</span> Student | National University of Singapore</span><br></div></div>