[cfe-dev] How to change typedef in AST
Jaymie Strecker
jstrecker at kosada.com
Sat Dec 22 20:15:02 PST 2012
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?
---
Jaymie Strecker
jstrecker at kosada.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121222/71fb7fd7/attachment.html>
More information about the cfe-dev
mailing list