This is the mail archive of the
mailing list for the GCC project.
C++ mangling, function name to mangled name (or tree)
- From: Pierre Vittet <piervit at pvittet dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 06 Jul 2011 18:00:06 +0200
- Subject: C++ mangling, function name to mangled name (or tree)
I am working on a plugin which permits simple static analysis. I would
like my plugin to work with C++ but I have to take in account the C++
I would like user of the plugin to give in arguments the name of the
functions on which he would like a test to be run. That means that I
must convert the string containing a function name (like
"myclass::init") and get either the mangled name or the tree
corresponding to the function. I know that there might be several
results (functions with the same name and different arguments), a good
policy for me would be to recover every concerned functions (at least
for the moment).
I guess what I want to do is possible, because there are already some
tools doing it (like gdb).
Also, when I use fdump-ipa-all, I get something interesting in the
int Application::test(int)/1 @0xb6cff6b4 (asm: _ZN11Application4testEi)
availability:available analyzed reachable body externally_visible finalized
called by: int main()/2 (1.00 per call) (can throw external)
calls: int printf(const char*, ...)/4 (1.00 per call) (can throw
We get both the "real name" and the mangled one
(_ZN11Application4testEi). But I don't know where I can find such
I have looked at cp/mangle.c, which has some interesting function, for
exemple giving the mangle named from the corresponding tree, but in this
case, how can I get the tree?
If you have any idea, thanks!