Hi all,
I want to annotate malloc(sizeof(X)) calls with the type in the sizeof
so that I can use the information in the IR later on (in a
transformation plugin). My current approach is to do a somewhat hacky
source transformation, replacing the call with:
malloc(({ ty * volatile ptr = NULL; (size_t)(ptr + 1); }))
so that I can take the pointer type and replace the size back with a
constant in the IR.
If someone can think of a better way to do this inside a clang frontend
plugin, I'm open to that, but currently I'm having issues just getting
this to work. I have a working plugin that finds the sizeof expressions
and a Rewriter instance that replaces them. However, I don't know how
to apply the changes to the input file so that the input with be parsed
again before being passed on to the codegen. There is a Reparse
function in ASTUnit, but I cannot find (in the docs or online) how this
is supposed to be used.
Does anyone know how to correctly use this?
Cheers,
Taddeüs
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users