diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-09-15 20:48:57 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-10-29 11:46:44 -0700 |
commit | 4e4883e1f394f7c47ff3adee48039aa8374bb8d0 (patch) | |
tree | ae16f9ea2e10878a1cf37f8f6b26164cb0cb03da /llvm/lib/Support/Path.cpp | |
parent | d0e9879d9627c82a9c1b97cdf0d8da8829905574 (diff) | |
download | llvm-4e4883e1f394f7c47ff3adee48039aa8374bb8d0.zip llvm-4e4883e1f394f7c47ff3adee48039aa8374bb8d0.tar.gz llvm-4e4883e1f394f7c47ff3adee48039aa8374bb8d0.tar.bz2 |
Support: Expose sys::path::is_style_{posix,windows,native}()
Expose three helpers in namespace llvm::sys::path to detect the
path rules followed by sys::path::Style.
- is_style_posix()
- is_style_windows()
- is_style_native()
This are constexpr functions that that will allow a bunch of
path-related code to stop checking `_WIN32`.
Originally I looked at adding system_style(), analogous to
sys::endian::system_endianness(), but future patches (from others) will
add more Windows style variants for slash preferences. These helpers
should be resilient to that change, allowing callers to detect basic
path rules.
Differential Revision: https://reviews.llvm.org/D112288
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 5e9456c..89fe923 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -37,11 +37,9 @@ namespace { using llvm::sys::path::Style; inline Style real_style(Style style) { -#ifdef _WIN32 - return (style == Style::posix) ? Style::posix : Style::windows; -#else - return (style == Style::windows) ? Style::windows : Style::posix; -#endif + if (is_style_posix(style)) + return Style::posix; + return Style::windows; } inline const char *separators(Style style) { |