<html>
<head></head>
<body>
<p><span style="font-size: 13.6000003814697px;">Thank you for answering the question. I implemented an ad-hoc solution for this case, got the </span><span style="font-size: 13.6000003814697px;">DeclRefExpr node and obtain the ValueDecl from it. The result was "kapplication" instead of "kapp".</span></p>
<p><span style="font-size: 13.6000003814697px;">#define kapp KApplication::kApplication()</span></p>
<p>In any case, as I commented in my message, I need a general solution for this. What if that expression is not a cast of a <span style="font-size: 13.6000003814697px;">DeclRefExpr node? Maybe it is a cast of the returning element of the calling to a method. In this sense, w</span><span style="font-size: 13.6000003814697px;">hat’s the reason why I cannot simply retrieve the expression </span><span style="font-size: 13.6000003814697px;">in parentheses </span><span style="font-size: 13.6000003814697px;">as it is explicitly written in the code?</span></p>
<br/>
<p>Thanks again.</p>
<div><em>El día 02 feb 2015 05:46, Nikola Smiljanic <popizdeh@gmail.com> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr">I'm pretty sure you need to get the actual DeclRefExpr node and obtain the ValueDecl from it.</div><div class="gmail_extra"><br /><div class="gmail_quote">On Tue, Jan 27, 2015 at 10:52 PM, Pedro Delgado Perez <span dir="ltr"><<a href="mailto:pedro.delgadoperez@mail.uca.es" target="_blank">pedro.delgadoperez@mail.uca.es</a>></span> wrote:<br /><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div><p>Hi, I've been trying lots of things to solve this problem, but I have not found the solution yet.<br /><span lang="en"><span>Nobody</span> <span>has</span> <span>encountered this problem</span> <span>before?</span></span></p>
<p>------------------------------------------------------------------------------------------<br />In the program I am developing, I search for "ExplicitCastExpr" because I need to print the elements which are being casted. If the program retrieves this expression:</p>
<p style="padding-left: 30px;">static_cast<KWriteApp *>(kapp);</p>
<p>what I want to print is "kapp".</p>
<p>However, I have found a problem in that situation:<br />- kapp is defined as:<br />#define kapp KApplication::kApplication()</p>
<p>- This is the AST of that expression:</p>
<p style="padding-left: 30px;"><span style="font-size: 8pt;">-CXXStaticCastExpr 0x4fcc118 <col:10, col:39> 'class KWriteApp *' static_cast<class KWriteApp *> <BaseToDerived (KApplication)></span><br /><span style="font-size: 8pt;">|       `-CallExpr 0x4fcc0e0 </usr/include/KDE/../kapplication.h:56:14, col:41> 'class KApplication *'</span><br /><span style="font-size: 8pt;">|         `-ImplicitCastExpr 0x4fcc0c8 <col:14, col:28> 'class KApplication *(*)(void)' <FunctionToPointerDecay></span><br /><span style="font-size: 8pt;">|           `-DeclRefExpr 0x4fcc068 <col:14, col:28> 'class KApplication *(void)' lvalue CXXMethod 0x7f4c9d3c2fe0 'kApplication' 'class KApplication *(void)'</span></p>
<p>As you can observe, "kapp" does not appear explicitly in the tree.<br />When in my program I invoke "getSubExpr()" (from the object containing the "ExplicitCastExpr") to obtain and print "kapp":</p>
<p><span style="font-size: 8pt;">      SourceRange r = SourceRange(</span><br /><span style="font-size: 8pt;">                                        FS2->getSubExpr()->getSourceRange().getBegin(),</span><br /><span style="font-size: 8pt;">                                        FS2->getSubExpr()->getSourceRange().getEnd()</span><br /><span style="font-size: 8pt;">                                );</span><br /><span style="font-size: 8pt;">      string element_casted = Rewrite.getRewrittenText(r);</span></p>
<p>However, the range of the expression is empty. I have also tried with "getSubExprAsWritten()" but it makes no difference. This is the first time I have found a problem with the solution that I had implemented.</p>
<p>The question is:<br />How could I simply obtain what is being casted as it is written in the code? I do not refer only to this specific case, but a way to achieve my goal in general because I cannot understand this situation.</p>
<p>Thanks in advance.</p>
</div><br/>
<p>_______________________________________________<br/>
cfe-dev mailing list<br/>
cfe-dev@cs.uiuc.edu</p>
</blockquote></div></div><p><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></p>
</blockquote>
</body>
</html>