summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-05-09 20:03:52 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-05-09 20:03:52 +0000
commitb40bf83eab6049a06159ad69b6422de9d6f3e2ee (patch)
treea4c738b98c180ed312244584d116ced204879387 /clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp
parentacbb1a5db5791f8c4b6beb1a673d474589d9a9a5 (diff)
downloadbcm5719-llvm-b40bf83eab6049a06159ad69b6422de9d6f3e2ee.tar.gz
bcm5719-llvm-b40bf83eab6049a06159ad69b6422de9d6f3e2ee.zip
Transform for loops over pseudo-arrays only if begin/end members exist
For loops using pseudo-arrays, classes that can be used like arrays from the Loop Convert Transform's point of view, should only get transformed if the pseudo-array class has begin()/end() members for the range-based for-loop to call. Free versions of begin()/end() should also be allowed but this is an enhancement for another revision. llvm-svn: 181539
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp')
-rw-r--r--clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp
index 37105f9e0b4..5aeaf79fc9f 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp
@@ -1,5 +1,5 @@
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs
+// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11
// RUN: FileCheck -input-file=%t.cpp %s
#include "structures.h"
@@ -64,3 +64,42 @@ void noContainer() {
for (auto i = 0; i < v.size(); ++i) ;
// CHECK: for (auto & elem : v) ;
}
+
+struct NoBeginEnd {
+ unsigned size() const;
+};
+
+struct NoConstBeginEnd {
+ NoConstBeginEnd();
+ unsigned size() const;
+ unsigned begin();
+ unsigned end();
+};
+
+struct ConstBeginEnd {
+ ConstBeginEnd();
+ unsigned size() const;
+ unsigned begin() const;
+ unsigned end() const;
+};
+
+// Shouldn't transform pseudo-array uses if the container doesn't provide
+// begin() and end() of the right const-ness.
+void NoBeginEndTest() {
+ NoBeginEnd NBE;
+ for (unsigned i = 0, e = NBE.size(); i < e; ++i) {}
+ // CHECK: for (unsigned i = 0, e = NBE.size(); i < e; ++i) {}
+
+ const NoConstBeginEnd const_NCBE;
+ for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {}
+ // CHECK: for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {}
+
+ ConstBeginEnd CBE;
+ for (unsigned i = 0, e = CBE.size(); i < e; ++i) {}
+ // CHECK: for (auto & elem : CBE) {}
+
+ const ConstBeginEnd const_CBE;
+ for (unsigned i = 0, e = const_CBE.size(); i < e; ++i) {}
+ // CHECK: for (auto & elem : const_CBE) {}
+}
+
OpenPOWER on IntegriCloud