[cfe-dev] Delay Clang CodeGen until AST is fully populated
Alexandre Isoard via cfe-dev
cfe-dev at lists.llvm.org
Tue Jun 25 19:18:45 PDT 2019
Hello,
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 *we were wondering if it was possible to require the Sema to
be fully finished before doing any CodeGen?*
An example would be when we process custom pragma:
int my_global;
int my_function() {
my_global = 1;
}
int main() {
#pragma FOO SOMETHING var=my_global
my_function();
return 0;
}
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.
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.
Any input on that issue?
--
*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190625/694947e7/attachment.html>
More information about the cfe-dev
mailing list