By the way, what about operator* returning T&&?  This is completely crazy, 
but we should do something sane in this case -- like avoiding the 
transformation.


================
Comment at: cpp11-migrate/LoopConvert/LoopActions.cpp:771-775
@@ -769,4 +770,7 @@
 
-  QualType AutoRefType =
-      Context->getLValueReferenceType(Context->getAutoDeductType());
+  QualType AutoRefType = Context->getAutoDeductType();
+  if (DerefByValue)
+    AutoRefType = Context->getRValueReferenceType(AutoRefType);
+  else
+    AutoRefType = Context->getLValueReferenceType(AutoRefType);
 
----------------
Please add a comment here. Something like:

If iterator's operator * returns 'T&', we can bind it to 'auto&'.  If it 
returns 'T', we can bind this rvalue to 'auto&&', which will deduce 'T&&'.

================
Comment at: cpp11-migrate/LoopConvert/LoopMatchers.cpp:145-146
@@ +144,4 @@
+  internal::Matcher<VarDecl> testDerefReturnsByValue =
+      hasType(
+        recordDecl(
+          hasMethod(
----------------
What if iterator has a pointer type?


http://llvm-reviews.chandlerc.com/D500
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to