Use "const auto &" in range based for loops

This previous code added in r216842 most likely created unnecessary copies.

Reported-by: Duncan P. N. Exon Smith  <dexonsmith@apple.com>