How to detect all free() calls

Thanks. isFreeCall() works well but for
%call2 = call i32 bitcast (i32 (…)* @free to i32 (i8*))(i8 %call1) nounwind, !dbg !16
So I tried to figure out when the above instruction occurred.
When <stdlib.h> is included, free(buf2R1); turn into call void @free(i8* %call1) nounwind, !dbg !16
when I forget to include <stdlib.h>, free(buf2R1); turn into %call2 = call i32 bitcast (i32 (…)* @free to i32 (i8*))(i8 %call1) nounwind, !dbg !16

I don’t understand why this is happen. Could you explain it for me?

------------------ Original ------------------

if you don't include stdlib.h, where free() is declared, you'll simply
get a default C function signature:

int free(...);

Hi Jane,

On your bitcast case: you can easily strip them using:

Function* callee = dyn_cast(call->getCalledValue()->stripPointerCasts());

  • D.

2013/3/11 Xi Wang <>