[cfe-dev] Modify (and reparse) AST

JB Feldman jb.feldman at kyrus-tech.com
Thu Feb 13 12:49:42 PST 2014


Is there a way to "modify the source" and reparse the text during the AST
TreeTransform process?

I am trying to make a local change that would fix the bug:
http://llvm.org/bugs/show_bug.cgi?id=18443

The idea would be to replace the nodes that are rendered as:
UnaryExprOrTypeTraitExpr 0x10c4f18 <col:41, col:55> 'unsigned int' sizeof
`-ParenExpr 0x10c4f00 <col:47, col:55> '<dependent type>' lvalue
  `-DependentScopeDeclRefExpr 0x10c4ed8 <col:48, col:51> '<dependent type>'
lvalue
with
UnaryExprOrTypeTraitExpr 0xf64f28 <col:41, col:64> 'unsigned int' sizeof
'typename T::type'

simply by adding "typename" before the symbol, and then the parser would
handle it correctly. and generate the correct UnaryExprOrTypeTraitExpr

Solutions I would accept include:
1) Change the source and reprocess the file (a la "Fixit"), but this has a
high overhead for large files/projects
2) Ask the parser for the single Expr that would be generated from the new
text
3) A way to look up what the existing typename would be manually and create
the expr manually.
4) Other thing I'm too new to know about.

Thanks,
JB

FYI: I'm trying to do this from the context of
TransformUnaryExprOrTypeTraitExpr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140213/766fac58/attachment.html>


More information about the cfe-dev mailing list