chapel-lang/chapel — pull request #639 by noakesmichael (2014-10-15 00:36:06+00:00)
Title: Cfor fixes

Three simple changes that enable a more correct implementation of BasicBlocks for C-For loops

1) Only add the test condition to the head of a Loop body. Previously the entire "loop expression" was
being added to the body for a C-For loop

2) When a C-For loop is used in an iterator, the iterator needs to capture the variables used in the init-expression in the iterator fields. Previously only variables that are live at the yields were being captured.

3) DeadCodeElimination might result in a degenerate C-For loop that would then break codegen for LLVM.
Add a pre-codegen cleanup function to remove these from the AST

Compiled on Mac clang, Linux gnu STD and LLVM.
Tested on full test suite with "--verify" and then "--verify --llvm"