the g++ compiler has a flag that produces macro-expanded code (-E), so I am wondering if there is a way to view the program coude after template instantiation before the actual compilation takes place?
Well, the closer you can get is to read the AST/ABT generated by the compiler:
The former represents the view of the syntax as the compiler understands it and the latter is similar after resolution of the bindings (ie, that the a
here is actually the variable that was declared 3 lines before or that the foo
correspdonds to the function defined in that header...).
Clang allows to dump its AST... which is in fact the ABT, actually, it's being improved at this very moment; sneak developer preview:
int Test __attribute__((visibility("default")));
int main(int argc, char** argv) {
int x __attribute__((aligned(4))) = 5;
int y = 2;
for (;;)
if (x != y++)
break;
return (x * y);
}
Normally you should see how the template was instantiated there.
Note: to get it you need the -ast-dump
pass to the clang front-end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With