Hi, everyone.
Is it possible to parse some code containing a typedef, then modify that typedef in the AST? For example, the input code contains typedef int blah
and I want to change it to typedef float blah
.
I found some example code for traversing the AST, which I modified to visit each typedef declaration:
bool VisitDecl(Decl *d) {
d->dump();printf("\n");
if (TypedefDecl::classof(d)) {
TypedefDecl *td = static_cast<TypedefDecl *>(d);
td->getTypeForDecl()->dump(); // prints “NULL TYPE”
// Type *t = ???;
// td->setTypeForDecl(t); ???
}
return true;
}
But I wasn’t sure where to go next. Any hints?