davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
197 stars 58 forks source link

Question: How can I get function declaration which is not in Callgraph? #151

Closed aqjune closed 5 years ago

aqjune commented 5 years ago

How can I get gcc.Function of a declared function which is not in Callgraph?

For example, in following code:

void g(int);
int f(int x, int y) {
  g(x + y);
}

gcc.get_callgraph_nodes() return f only, but not g.

Thanks

davidmalcolm commented 5 years ago

IIRC the gcc.Function represents the body of a function, and g's body isn't available: g was declared but was not defined.

You ought to be able to get at a gcc.FunctionDecl for the decl of g from the call statement.

aqjune commented 5 years ago

It works, thanks! :)