<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,<br>
</p>
<p>I want to retrieve in my RecursiveAstVisitor inside a
VisitCallExpr method the open brace of the corresponding function
declaration.</p>
<p>The code below does not find anything..</p>
<p>Any idea what I am doing wrong and is there a more elegant way to
generate a variable declaration with a Rewriter?</p>
<p>Thanx</p>
<p>Marcel<br>
</p>
<p><font face="Courier New, Courier, monospace">bool
VisitCallExpr(CallExpr *CallExpression) {<br>
...<br>
if (CallExpression != NULL) {<br>
const auto& parents =
TheContext->getParents(CallExpression);<br>
<br>
if (parents.empty()) {<br>
llvm::errs() << "**** Can not find
parent\n";<br>
return false;<br>
}<br>
<br>
auto parent = parents[0].get<DeclStmt>();<br>
<br>
if (parent != NULL) {<br>
llvm::errs() << "**** FOUND DECL STATEMENT
****\n";<br>
SourceLocation l1 = parent->getLocStart();<br>
TheRewriter.InsertText(l1, "/** found decl**/");<br>
} <br>
else<br>
llvm::errs() << "**** DECL STATEMENT NOT
FOUND ****\n";</font></p>
<p><font face="Courier New, Courier, monospace">...</font></p>
<p><font face="Courier New, Courier, monospace">}</font><br>
</p>
</body>
</html>