gcc-plugins

Modification of the AST-tree of the GCC compiler

可紊 提交于 2020-07-17 22:26:10
问题 It is needed to gather the necessary information about the translation unit using the plugin for GCC and to modify AST on its base. I've already understood how to gather information. But I haven't understand yet how to modify AST before it's passed into CRT. Very little information is available on this subject. Tell me plese what should I read on this subject? Share thoughts, links. Thank's. P.S. I've already read everything on these links: http://en.wikibooks.org/wiki/GNU_C_Compiler

Use gcc plugins to modify the order of variable declarations

家住魔仙堡 提交于 2019-12-24 03:23:26
问题 I know this is very hard to do, and that I should avoid that, but I have my reasons for this. I want to modify the order of some field declarations in compilation time, for example : class A { char c; int i; } must turn to : class A { int i; char c; } if I chose to swap the order of i and c , I want to know how to change the location of a field declaration having its tree Anyone know how can I do this ?? thanks ! I use the g++ 4.9.2 version of plugins 回答1: If I was going to try this, I would

Use gcc plugins to modify the order of variable declarations

烂漫一生 提交于 2019-12-24 03:23:19
问题 I know this is very hard to do, and that I should avoid that, but I have my reasons for this. I want to modify the order of some field declarations in compilation time, for example : class A { char c; int i; } must turn to : class A { int i; char c; } if I chose to swap the order of i and c , I want to know how to change the location of a field declaration having its tree Anyone know how can I do this ?? thanks ! I use the g++ 4.9.2 version of plugins 回答1: If I was going to try this, I would

Insert global variable declaration with a gcc plugin

我的未来我决定 提交于 2019-12-22 08:16:12
问题 I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code: test.c: int main(void) { return 0; } and I want to transform it into: int fake_var; int main(void) { return 0; } Is that possible? If it's possible, in which pass and how can I do it? 回答1: I think you'll want to take a look at varpool_add_new_variable() in varpool.c. You should be able to pass a declaration built with type VAR_DECL to it. Similarly, take a

How to add a builtin function in a GCC plugin?

家住魔仙堡 提交于 2019-12-03 10:29:32
问题 It is possible for a GCC plugin to add a new builtin function? If so, how to do it properly? GCC version is 5.3 (or newer). The code being compiled and processed by the plugin is written in C. It is mentioned in the rationale for GCC plugins at gcc-melt.org that this is doable but I cannot see how. As far as I can see in the sources of GCC, the builtins are created using add_builtin_function() from gcc/langhooks.c: tree add_builtin_function (const char *name, tree type, int function_code,