[cfe-dev] Dissect and rewrite of function calls in expressions
Marcel Schaible via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 8 10:27:18 PDT 2017
I would think (in fact, I _KNOW_) that the compiler already does the
transformation to temp1 = foo(42) and temp2 = foo(temp1) already. So
it'd just be a case, at the LLVM-IR level at least, to insert some code
to inspect temp1 and temp2.
>
Good hint. I'll check that.
> Of course, it may be a slightly more interesting challenge to find
> your "interesting functions" (particularly if interesting functions
> aren't a well defined set of functions) when looking at the LLVM-IR -
> including the fact that for example member functions gets mangled
> during compilation.
>
"Interesting functions" are marked by the developer.
> Also interesting/challenging is function pointers:
>
> pf = foo;
> var = 42 + pf(pf(42));
>
> Consider where pf is passed into the function you're currently looking
> at, or comes from a table of function pointers, with a non-constant
> determining the index into the table.
> A similar problem is of course virtual function calls - they are just
> function pointer tables after all [but the table itself is the
> variable part there, rather than the index, unless we're talking
> virtual member function pointers, which isn't a common creature by any
> means]
At the first shot I'll attack the trivial cases. So function pointer are
on my list but come at a later point in time. Because the target are
embedded devices, which in my case are programmed exclusively in plain "C"
I'll ignore for the moment vtables.
Anyway I would like to implement the dissecting of the expression my
self with the clang frontend. Any hints on that?
--
Marcel
More information about the cfe-dev
mailing list