summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-04-13 02:54:13 +0000
committerEric Fiselier <eric@efcs.ca>2017-04-13 02:54:13 +0000
commite02ed1c255d717827268fd0789148a06df5d0970 (patch)
treed1aa283264c503cc2f9c5a66435c5e9700287db7 /libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
parentd3d084a0a55740ad1f48e498e61820f390e34b18 (diff)
downloadbcm5719-llvm-e02ed1c255d717827268fd0789148a06df5d0970.tar.gz
bcm5719-llvm-e02ed1c255d717827268fd0789148a06df5d0970.zip
Diagnose when reverse_iterator is used on path::iterator.
path::iterator isn't a strictly conforming iterator. Specifically it stashes the current element inside the iterator. This leads to UB when used with reverse_iterator since it requires the element to outlive the lifetime of the iterator. This patch adds a static_assert inside reverse_iterator to disallow "stashing iterator types", and it tags path::iterator as such a type. Additionally this patch removes all uses of reverse_iterator<path::iterator> within the tests. llvm-svn: 300164
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
index 4c83481aaf2..078e006663e 100644
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
@@ -54,12 +54,6 @@
#include "count_new.hpp"
#include "filesystem_test_helper.hpp"
-template <class It>
-std::reverse_iterator<It> mkRev(It it) {
- return std::reverse_iterator<It>(it);
-}
-
-
namespace fs = std::experimental::filesystem;
struct PathDecomposeTestcase
{
@@ -147,7 +141,11 @@ void decompPathTest()
assert(checkCollectionsEqual(p.begin(), p.end(),
TC.elements.begin(), TC.elements.end()));
// check backwards
- assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()),
+
+ std::vector<fs::path> Parts;
+ for (auto it = p.end(); it != p.begin(); )
+ Parts.push_back(*--it);
+ assert(checkCollectionsEqual(Parts.begin(), Parts.end(),
TC.elements.rbegin(), TC.elements.rend()));
}
}
OpenPOWER on IntegriCloud