-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
I'm looking for a way to add a prefix to function names and then pretty print it -ast-print but I'm not sure how to do it, at first it seems that I would use ASTRewriter to do it, I would expect that I'll only need to change the FunctionDefinitionAST::declarator and then everywhere it's used will have the prefix.
#include <stdio.h>
#include <stdlib.h>
int i1(int n);
int i1(int n)
{
if (n < 2) return 1;
return i1(n-2) + i1(n-1);
}
int main(int argc, char **argv)
{
int xt = 32;
if(argc > 1)
{
xt = atoi(argv[1]);
}
int result = i1(xt);
printf("Result of %d = %d\n", xt, result);
return 0;
}
I would like to add a prefix fn_ to function names and have this output:
...
int fn_i1(int n);
int fn_i1(int n)
{
if (n < 2) return 1;
return fn_i1(n-2) + fn_i1(n-1);
}
int main(int argc, char **argv)
{
int xt = 32;
if(argc > 1)
{
xt = atoi(argv[1]);
}
int result = fn_i1(xt);
printf("Result of %d = %d\n", xt, result);
return 0;
}
How could I achieve it ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels