<div dir="ltr">Hello,<div><br></div><div>We are having issues with modifying the Clang AST while it is being built, and we suspect they are due to it being code generated before it is fully populated, and <b>we were wondering if it was possible to require the Sema to be fully finished before doing any CodeGen?</b></div><div><br></div><div>An example would be when we process custom pragma:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>int my_global;</div><div><br></div><div>int my_function() {</div><div>    my_global = 1;</div><div>}</div><div><br></div><div>int main() {</div>#pragma FOO SOMETHING var=my_global<div>    my_function();</div><div>    return 0;</div><div>}</div></blockquote><div><br></div><div>Here the way I process the pragma is that it attach to the AST node for my_global, an attribute node. So that once I code-generate that global variable I can "do something" based on that attribute. Unfortunately, today Clang might codegen that global as soon as it deem it necessary (typically, when code-generating my_function as it uses it). And the pragma has not yet been semantically parsed yet.</div><div><br></div><div>If I were to use -ast-print and dump the result into a file, then the attribute would be there, and if I parse that file again I would get the correct codegen. But I assume it is unsafe to rely on being able to parse -ast-print and/or it's AST to be the same.</div><div><br></div><div>Any input on that issue?</div><div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div></div></div>