<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 24, 2014 at 2:25 PM, Frime <span dir="ltr"><<a href="mailto:friedie04@gmx.de" target="_blank">friedie04@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi folks!<br>
<br>
I'm using libclang for parsing C++ Code. The goal is to cut out the<br>
implementation of functions which i need for roundtrip engineering in a Code<br>
Generator. My code works perfectly for functions that are not overwritten by<br>
subclasses. But if i derive Interfaces, the decl->hasBody() function returns<br>
false. So how do i get the implementaion of overwritten functions?<br>
<br>
So here is my current code:<br>
<br>
// overwritten function in a Subclass of RecursiveASTVisitor<br>
bool FindNamedClassVisitor::VisitDecl(Decl *decl)<br>
{<br>
if(const CXXMethodDecl* method = dyn_cast<CXXMethodDecl>(decl))<br>
{<br>
FullSourceLoc FullLocation = Context->getFullLoc(method->getLocStart());<br>
if (FullLocation.isValid()&& !FullLocation.isInSystemHeader())<br>
{<br>
QString name =<br>
QString::fromStdString(method->getParent()->getNameAsString()) + "::" +<br>
QString::fromStdString(method->getNameAsString());<br>
if(decl->hasBody())<br>
{<br>
QString impl =<br>
QString::fromStdString(decl2str(decl->getSourceRange()));<br>
<br>
hash.insert(name, impl);<br>
qDebug()<<name;<br>
}<br>
else<br>
{<br>
qDebug()<<"NO BODY: "<<name;<br>
}<br>
}<br>
}<br>
<br>
<br>
the clang seems to ignore the redeclaration in the derived classes.. The<br>
result is that for this functions my code prints "NO BODY:..."<br>
<br>
I also tried method = method->getMostRecentDecl(); without success..<br>
<br>
Any suggestions or code snippets?<br></blockquote><div><br></div><div>Can you give an example of code you're trying to run it over?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thank you very much!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Get-function-body-of-overwritten-functions-while-traversing-AST-tp4038044.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Get-function-body-of-overwritten-functions-while-traversing-AST-tp4038044.html</a><br>
Sent from the Clang Developers mailing list archive at Nabble.com.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>