How to instrument a statement just before another statement using clang

前端 未结 1 915
梦毁少年i
梦毁少年i 2021-02-09 20:29

I have to instrument certain statements in clang by adding a statement just before it. I have a pointer to an Expr object using which I need to insert another statement just bef

相关标签:
1条回答
  • 2021-02-09 20:41

    You can use getSourceRange() on the statement which returns SourceRange SourceRange Class has getBegin() which will return SourceLocation.

    you can checkout https://github.com/eschulte/clang-mutate and see an example there...

    EDIT:

    In order to extract Expr out of Stmt you can checkout this SO question How to get Stmt class object from Expr object in Clang

    0 讨论(0)
提交回复
热议问题