Adding nodes to Clang's AST

爷,独闯天下 提交于 2019-12-06 05:38:19

问题


I need to insert new nodes to AST. for instance, adding a namespace to a function: Turning this -

void foo();

into this -

namespace bar {
    void foo();
}

I read How to clone or create an AST Stmt node of clang? but I prefer not using source-to-source compilation

Tnx


回答1:


The answer can be found here http://clang-developers.42468.n3.nabble.com/Adding-nodes-to-Clang-s-AST-td4054800.html

However, the nodes are added to the compiled AST - for instance, in case one wants to inject a namespace to the code, he can't use the namespace directly via the code because the lexer don't know about it.



来源:https://stackoverflow.com/questions/41550891/adding-nodes-to-clangs-ast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!