Diego, sorry about that. actually insertStmtBefore did the correct thing in this case, but that is not obvious!!! in fact, these insertStmt functions give everybody a horrible time and they will be gone in the next version. but here is the fix. there are two insertStmt functions: libSage++.h: inline void insertStmtBefore(SgStatement &s); libSage++.h: inline void insertStmtBefore(SgStatement &s, SgStatement &cp); you want to use the second one. the second parameter is the control parent of the list upon which you want your item inserted. let cp = for_stmt->control_parent(); then do for_stmt->insertStmtBefore(*synch, cp); that should put it in the right place. d.