aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/src/filesystem/path_parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/libcxx/src/filesystem/path_parser.h')
-rw-r--r--contrib/llvm-project/libcxx/src/filesystem/path_parser.h58
1 files changed, 21 insertions, 37 deletions
diff --git a/contrib/llvm-project/libcxx/src/filesystem/path_parser.h b/contrib/llvm-project/libcxx/src/filesystem/path_parser.h
index c6e63e8256ad..28a8f240e3bd 100644
--- a/contrib/llvm-project/libcxx/src/filesystem/path_parser.h
+++ b/contrib/llvm-project/libcxx/src/filesystem/path_parser.h
@@ -29,25 +29,23 @@ inline bool isSeparator(path::value_type C) {
return false;
}
-inline bool isDriveLetter(path::value_type C) {
- return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z');
-}
+inline bool isDriveLetter(path::value_type C) { return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'); }
namespace parser {
-using string_view_t = path::__string_view;
+using string_view_t = path::__string_view;
using string_view_pair = pair<string_view_t, string_view_t>;
-using PosPtr = path::value_type const*;
+using PosPtr = path::value_type const*;
struct PathParser {
enum ParserState : unsigned char {
// Zero is a special sentinel value used by default constructed iterators.
- PS_BeforeBegin = path::iterator::_BeforeBegin,
- PS_InRootName = path::iterator::_InRootName,
- PS_InRootDir = path::iterator::_InRootDir,
- PS_InFilenames = path::iterator::_InFilenames,
+ PS_BeforeBegin = path::iterator::_BeforeBegin,
+ PS_InRootName = path::iterator::_InRootName,
+ PS_InRootDir = path::iterator::_InRootDir,
+ PS_InFilenames = path::iterator::_InFilenames,
PS_InTrailingSep = path::iterator::_InTrailingSep,
- PS_AtEnd = path::iterator::_AtEnd
+ PS_AtEnd = path::iterator::_AtEnd
};
const string_view_t Path;
@@ -55,8 +53,7 @@ struct PathParser {
ParserState State;
private:
- PathParser(string_view_t P, ParserState State) noexcept : Path(P),
- State(State) {}
+ PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {}
public:
PathParser(string_view_t P, string_view_t E, unsigned char S)
@@ -77,12 +74,12 @@ public:
PosPtr peek() const noexcept {
auto TkEnd = getNextTokenStartPos();
- auto End = getAfterBack();
+ auto End = getAfterBack();
return TkEnd == End ? nullptr : TkEnd;
}
void increment() noexcept {
- const PosPtr End = getAfterBack();
+ const PosPtr End = getAfterBack();
const PosPtr Start = getNextTokenStartPos();
if (Start == End)
return makeState(PS_AtEnd);
@@ -123,7 +120,7 @@ public:
}
void decrement() noexcept {
- const PosPtr REnd = getBeforeFront();
+ const PosPtr REnd = getBeforeFront();
const PosPtr RStart = getCurrentTokenStartPos() - 1;
if (RStart == REnd) // we're decrementing the begin
return makeState(PS_BeforeBegin);
@@ -147,8 +144,7 @@ public:
}
}
case PS_InTrailingSep:
- return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1,
- RStart + 1);
+ return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1, RStart + 1);
case PS_InFilenames: {
PosPtr SepEnd = consumeAllSeparators(RStart, REnd);
if (SepEnd == REnd)
@@ -191,9 +187,7 @@ public:
__libcpp_unreachable();
}
- explicit operator bool() const noexcept {
- return State != PS_BeforeBegin && State != PS_AtEnd;
- }
+ explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; }
PathParser& operator++() noexcept {
increment();
@@ -205,29 +199,21 @@ public:
return *this;
}
- bool atEnd() const noexcept {
- return State == PS_AtEnd;
- }
+ bool atEnd() const noexcept { return State == PS_AtEnd; }
- bool inRootDir() const noexcept {
- return State == PS_InRootDir;
- }
+ bool inRootDir() const noexcept { return State == PS_InRootDir; }
- bool inRootName() const noexcept {
- return State == PS_InRootName;
- }
+ bool inRootName() const noexcept { return State == PS_InRootName; }
- bool inRootPath() const noexcept {
- return inRootName() || inRootDir();
- }
+ bool inRootPath() const noexcept { return inRootName() || inRootDir(); }
private:
void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
- State = NewState;
+ State = NewState;
RawEntry = string_view_t(Start, End - Start);
}
void makeState(ParserState NewState) noexcept {
- State = NewState;
+ State = NewState;
RawEntry = {};
}
@@ -357,9 +343,7 @@ inline string_view_pair separate_filename(string_view_t const& s) {
return string_view_pair{s.substr(0, pos), s.substr(pos)};
}
-inline string_view_t createView(PosPtr S, PosPtr E) noexcept {
- return {S, static_cast<size_t>(E - S) + 1};
-}
+inline string_view_t createView(PosPtr S, PosPtr E) noexcept { return {S, static_cast<size_t>(E - S) + 1}; }
} // namespace parser