compiler/AST/foralls.cpp
//
// Handle the case where the leader iterator is astr_loopexpr_iter.
// Not doing so confuses ReturnByRef and lowering of ForallStmts.
//
// Tests:
//   library/packages/Collection/CollectionCounter.chpl
//   library/standard/Random/deitz/test1D2D.chpl
//   reductions/deitz/test_maxloc_reduce_wmikanik_bug2.chpl
//
Handle the case where the leader iterator is astr_loopexpr_iter.
Not doing so confuses ReturnByRef and lowering of ForallStmts.


Handle the case where the leader iterator is astr_loopexpr_iter . Not doing so confuses ReturnByRef and lowering of ForallStmts .
static void convertIteratorForLoopexpr(ForallStmt* fs) {
  if (CallExpr* iterCall = toCallExpr(fs->iteratedExpressions().head))
    if (SymExpr* calleeSE = toSymExpr(iterCall->baseExpr))
      if (FnSymbol* calleeFn = toFnSymbol(calleeSE->symbol()))
        if (isLoopExprFun(calleeFn)) {
          FnSymbol* iterator = getTheIteratorFnFromIteratorRec(calleeFn->retType);
          SET_LINENO(calleeSE);
          calleeSE->replace(new SymExpr(iterator));
          if (calleeFn->firstSymExpr() == NULL)
            calleeFn->defPoint->remove(); 
          removeOuterVarArgs(iterCall, calleeFn, iterator);
        }
}
static void convertIteratorForLoopexpr ( ForallStmt * fs ) { if ( CallExpr * iterCall = toCallExpr ( fs -> iteratedExpressions ( ) . head ) ) if ( SymExpr * calleeSE = toSymExpr ( iterCall -> baseExpr ) ) if ( FnSymbol * calleeFn = toFnSymbol ( calleeSE -> symbol ( ) ) ) if ( isLoopExprFun ( calleeFn ) ) { FnSymbol * iterator = getTheIteratorFnFromIteratorRec ( calleeFn -> retType ) ; SET_LINENO ( calleeSE ) ; calleeSE -> replace ( new SymExpr ( iterator ) ) ; if ( calleeFn -> firstSymExpr ( ) == NULL ) calleeFn -> defPoint -> remove ( ) ; removeOuterVarArgs ( iterCall , calleeFn , iterator ) ; } }
Handle the case where the leader iterator is astr_loopexpr_iter.
Handle the case where the leader iterator is astr_loopexpr_iter .
// In this case, we have a _toLeader call and no side effects. // Just use the iterator corresponding to the iterator record. // not needed any more