Node tryFoldEmptyDo ( Node n ) { checkArgument ( n . isDo ( ) ) ; Node body = NodeUtil . getLoopCodeBlock ( n ) ; if ( body . isBlock ( ) && ! body . hasChildren ( ) ) { Node cond = NodeUtil . getConditionExpression ( n ) ; Node forNode = IR . forNode ( IR . empty ( ) . srcref ( n ) , cond . detach ( ) , IR . empty ( ) . srcref ( n ) , body . detach ( ) ) ; n . replaceWith ( forNode ) ; reportChangeToEnclosingScope ( forNode ) ; return forNode ; } return n ; }
Removes DOs that have empty bodies into FORs which are much easier for the CFA to analyze .