<div>If I have the FieldDecl from a MemberExpression, is there anyway to extract the VarDecl of that FieldDecl for that MemberExpr? Or is there no VarDecl in such case? I basically want to extract the Address of that FieldDecl as like I can for VarDecl using <font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback""><span style="color:rgb(121, 94, 38)">GetAddrOfLocalVar.</span></font></div><br><div>Basically, this is the AST<span data-emoji-typing="true">:</span></div><div><span data-emoji-typing="true">CStyleCastExpr 0x55d2681bcf68 'MathFuncNoArg':'double (*)(void)' <BitCast></span></div><div><span data-emoji-typing="true">`-ImplicitCastExpr 0x55d2681bcf50 'MathFunc':'double (*)(...)' <LValueToRValue></span></div><div><span data-emoji-typing="true">  `-MemberExpr 0x55d2681bcf08 'MathFunc':'double (*)(...)' lvalue .f 0x55d26800bec0</span></div><div><span data-emoji-typing="true">    `-MemberExpr 0x55d2681bced0 'struct (anonymous struct at omnet_include/cpar.h:277:8)':'struct cPar::(anonymous at omnet_include/cpar.h:277:8)' lvalue .func 0x55d26800c188</span></div><div><span data-emoji-typing="true">      `-MemberExpr 0x55d2681bce80 'union cPar::(anonymous at omnet_include/cpar.h:272:5)' lvalue -> 0x55d268013d58</span></div><div><span data-emoji-typing="true">        `-CXXThisExpr 0x55d2681bce68 'class cPar *' this</span></div><br><div>and in the source:</div><div><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"">((MathFuncNoArg)func.f)()</font></div><div class="gmail_quote_attribution">On Sep 14 2018, at 8:54 am, Mustakimur Rahman Khandaker (Mustakim) <mustakcsecuet@gmail.com> wrote:</div><blockquote><br><div><div>I actually try to instrument before those indirect call to extract the memory address of callee (in above case: func.f). I know I can extract that using <font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback""><span style="color:rgb(121, 94, 38)">GetAddrOfLocalVar</span></font> if I know the Decl of the callee. But, the point I reached to createCall for indirect call, I don't have that information anymore for these cases. I don't know if there could be an alternative design possible to achieve it.</div><br><div>On Sep 13 2018, at 6:29 pm, Friedman, Eli <efriedma@codeaurora.org> wrote:</div><blockquote><br><div><br><div><div>On 9/13/2018 2:26 PM, Mustakimur Rahman Khandaker (Mustakim) via cfe-dev wrote:</div></div><blockquote><div>Now, in the <em>CGCalleeInfo, </em><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"">compiler set the Decl for the Callee.</font> What I have discovered is that <em><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"">Decl *Expr::getReferencedDeclOfCallee()</font></em><em> </em>returns nullptr and for that call callee set to Decl as Null from <font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"">CGCallee </font><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback""><span style="color:rgb(121, 94, 38)">CodeGenFunction::EmitCallee</span></font><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"">(</font><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback""><span style="color:rgb(0, 0, 255)">const</span></font><font style="font-family:"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback""> Expr *E)</font>. I beleive this is not an expected behavior because it is declared as MathFunc and it should be set as that.</div><br><div>I would like to understand why it kept like this?</div></blockquote><br><div>It mostly doesn't matter because the callers of getReferencedDeclOfCallee/getCalleeDecl generally don't care about declarations that aren't a FunctionDecl, and code generally doesn't call explicit casts of function pointers.</div><br><div>What are you trying to do?</div><br><div>-Eli</div><code><pre style="background-color:rgba(0,0,0,0.05);padding:0.2em 1em"><div><code>-- </code></div><div><code>Employee of Qualcomm Innovation Center, Inc.</code></div><div><code>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</code></div></pre></code></div></blockquote></div></blockquote>