summaryrefslogtreecommitdiff
path: root/include/experimental
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-25 03:31:48 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-25 03:31:48 +0000
commit0fbaa11dd3b95c9798e3e5bc2b20c4f40640e6d6 (patch)
tree172130cf8ae8d15bdc8db16105f586401c15740f /include/experimental
parent88dfb6d532a5ef6216a1d90c30dcea026c49615e (diff)
downloadlibcxx-0fbaa11dd3b95c9798e3e5bc2b20c4f40640e6d6.tar.gz
Ensure path::iterator and PathParser share the same enumeration values.
To avoid exposing implementation details, path::iterator and PathParser both implicitly used the same set of values to represent the state, but they were defined twice. This could have lead to a mismatch occuring. This patch moves all of the parser state values into the filesystem header and changes PathParser to use those value to avoid this. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337883 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/experimental')
-rw-r--r--include/experimental/filesystem27
1 files changed, 18 insertions, 9 deletions
diff --git a/include/experimental/filesystem b/include/experimental/filesystem
index 9699699c7..1f6d1ab4d 100644
--- a/include/experimental/filesystem
+++ b/include/experimental/filesystem
@@ -1037,7 +1037,7 @@ public:
_LIBCPP_INLINE_VISIBILITY path extension() const { return string_type(__extension()); }
// query
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT { return __pn_.empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); }
@@ -1170,6 +1170,17 @@ u8path(_InputIt __f, _InputIt __l) {
class _LIBCPP_TYPE_VIS path::iterator
{
public:
+ enum _ParserState : unsigned char {
+ _Singular,
+ _BeforeBegin,
+ _InRootName,
+ _InRootDir,
+ _InFilenames,
+ _InTrailingSep,
+ _AtEnd
+ };
+
+public:
typedef bidirectional_iterator_tag iterator_category;
typedef path value_type;
@@ -1178,10 +1189,11 @@ public:
typedef const path& reference;
typedef void __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator
+
public:
_LIBCPP_INLINE_VISIBILITY
iterator() : __stashed_elem_(), __path_ptr_(nullptr),
- __entry_(), __state_(__singular) {}
+ __entry_(), __state_(_Singular) {}
iterator(const iterator&) = default;
~iterator() = default;
@@ -1200,9 +1212,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator& operator++() {
- _LIBCPP_ASSERT(__state_ != __singular,
+ _LIBCPP_ASSERT(__state_ != _Singular,
"attempting to increment a singular iterator");
- _LIBCPP_ASSERT(__state_ != __at_end,
+ _LIBCPP_ASSERT(__state_ != _AtEnd,
"attempting to increment the end iterator");
return __increment();
}
@@ -1216,7 +1228,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator& operator--() {
- _LIBCPP_ASSERT(__state_ != __singular,
+ _LIBCPP_ASSERT(__state_ != _Singular,
"attempting to decrement a singular iterator");
_LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
"attempting to decrement the begin iterator");
@@ -1233,9 +1245,6 @@ public:
private:
friend class path;
- static constexpr unsigned char __singular = 0;
- static constexpr unsigned char __at_end = 6;
-
inline _LIBCPP_INLINE_VISIBILITY
friend bool operator==(const iterator&, const iterator&);
@@ -1245,7 +1254,7 @@ private:
path __stashed_elem_;
const path* __path_ptr_;
path::__string_view __entry_;
- unsigned char __state_;
+ _ParserState __state_;
};
inline _LIBCPP_INLINE_VISIBILITY