Clang Rewrite: Locate top of a call expression

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Clang Rewrite: Locate top of a call expression

mustakimur
This post has NOT been accepted by the mailing list yet.
I am working on some clang rewrite in source. I want to insert one line before a statement. Like if I have a call from inside an if statement like following:

if (cmp(a,b) > 0 && cmp(c,d) < 0){
//do something
}
I want to rewrite a comment before that if statement, like following:

//there are call inside
if (cmp(a,b) > 0 && cmp(c,d) < 0){
//do something
}
What I could do till now is, I could detect the call with VisitCallExpr(). But how could I find out the location before that if statement to write the comment. N.B. The if statement here could be for too, like following:

for (int a = 0; a < range(s); a++){
//do something
}
Can anyone help me to find out a way to do this.
Loading...