LoopConvert isn't properly handling iterators whose dereference operator
returns by value. This test case demonstrates the failure.
See PR15437.
llvm-svn: 176437
iterator end();
};
+// Like llvm::SmallPtrSet, the iterator has a dereference operator that returns
+// by value instead of by reference.
+template <typename T>
+struct PtrSet {
+ struct iterator {
+ bool operator!=(const iterator &other) const;
+ const T operator*();
+ iterator &operator++();
+ };
+ iterator begin() const;
+ iterator end() const;
+};
+
#endif // STRUCTURES_H
--- /dev/null
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs
+// RUN: FileCheck -input-file=%t.cpp %s
+// XFAIL: *
+#include "structures.h"
+
+void f() {
+ // See PR15437 for details.
+ PtrSet<int*> int_ptrs;
+ for (PtrSet<int*>::iterator I = int_ptrs.begin(),
+ E = int_ptrs.end(); I != E; ++I) {
+ // CHECK: for (const auto & int_ptr : int_ptrs) {
+ }
+}