[llvm] r234963 - Change range-based for-loops to be	-Wrange-loop-analysis clean.
    Pete Cooper 
    peter_cooper at apple.com
       
    Tue Apr 14 22:14:05 PDT 2015
    
    
  
Sent from my iPhone
On Apr 14, 2015, at 8:21 PM, Richard Trieu <rtrieu at google.com> wrote:
>> > -    for (const auto &MapEntry : VMap) {
>> > +    for (const auto MapEntry : VMap) {
>> 
>> What's the deal with this change? Is the type small & trivially
>> copyable & we're suggesting using values instead of references?
> VMap does not return a reference, so remove the reference type to indicate a copy is always made.
Are there any cases where you'll change something from ref to a value because it's 'small and trivially copyable'?
If so, my worry is what happens if I change the type to be a bit larger or less trivial to copy. How will I be able to spot the range based for loop uses (which now do a copy) and change them back to refs? The problem is that changing them back in that way could result in false positives because perhaps in some uses I wanted the copy and in others I didn't.
So basically, are we able to reliably detect when to do the reverse transformation at a later date, and if not, should we do a transform now that is potentially difficult to undo later?
Cheers
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150414/54489125/attachment.html>
    
    
More information about the llvm-commits
mailing list