<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font size="-1">Hi Dan,<br>
<br>
</font>
<div class="moz-cite-prefix">Le 03/04/2013 15:21, dan.sanduleac a
écrit :<br>
</div>
<blockquote cite="mid:1364995305084-4031281.post@n3.nabble.com"
type="cite">
<pre wrap="">Hi Béatrice,
This is really helpful, but I got stuck somewhere.
I tried to create a similar setup, getting ahold of the Sema in my
ASTFrontendAction, and then trying to transform function bodies.
My VisitFunctionDecl runs TransformStmt (ultimately TransformCompoundStmt)
on the function's body, but it crashes because at this point
Sema::FunctionScopes is an empty vector, and the first thing
Sema::TransformCompoundStmt tries to do (via
Sema::ActOnStartOfCompoundStmt() -> Sema::PushCompoundScope()) is to push
the new CompoundScope onto the current FunctionScope .. which of course
doesn't exist since FunctionScopes is empty.
</pre>
</blockquote>
<br>
I haven't tried to modify whole function bodies yet, just variable
declarations and inner loop bodies, so I may not be very helpful. Is
your ASTConsumer a SemaConsumer?<br>
<blockquote cite="mid:1364995305084-4031281.post@n3.nabble.com"
type="cite">
<pre wrap="">
When exactly do you start traversing with the RecursiveASTVisitor? Is it
after semantic analysis, after the Parser had already populated the entire
AST, or somehow during?</pre>
</blockquote>
It is fully done by clang machinery, so I don't know exactly when it
is performed, after semantic analysis I guess. In my sub-class of
ASTFrontEndAction I redefine CreateASTConsumer to create an object
that derives from SemaConsumer, so I expect that when the
HandleTopLevelDecl of my sub-class of SemaConsumer is called, then
the Sema is correctly initialized.<br>
<br>
Regards,<br>
<br>
Béatrice.<br>
<br>
<pre class="moz-signature" cols="72">--
Béatrice Creusillet
SILKAN - <a class="moz-txt-link-abbreviated" href="http://www.silkan.com">www.silkan.com</a></pre>
</body>
</html>