blob: 27f7e8bf75ecf15cd8f79203abdc3d0b3f755bff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11
// RUN: FileCheck -input-file=%t.cpp %s
// XFAIL: *
struct MyArray {
unsigned size();
};
template <typename T>
struct MyContainer {
};
int *begin(const MyArray &Arr);
int *end(const MyArray &Arr);
template <typename T>
T *begin(const MyContainer<T> &C);
template <typename T>
T *end(const MyContainer<T> &C);
// The Loop Convert Transform doesn't detect free functions begin()/end() and
// so fails to transform these cases which it should.
void f() {
MyArray Arr;
for (unsigned i = 0, e = Arr.size(); i < e; ++i) {}
// CHECK: for (auto & elem : Arr) {}
MyContainer<int> C;
for (int *I = begin(C), *E = end(C); I != E; ++I) {}
// CHECK: for (auto & elem : C) {}
}
|