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
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