[thrift] move cleanup in 3187352 and c149279 'upstream' to generator