[llvm] 8077a19 - Support: Remove sys::path::is_style_native()

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 17:13:49 PDT 2021


Author: Duncan P. N. Exon Smith
Date: 2021-10-29T16:50:10-07:00
New Revision: 8077a19f66b50573a043ef1c405e2149e0c69cb7

URL: https://github.com/llvm/llvm-project/commit/8077a19f66b50573a043ef1c405e2149e0c69cb7
DIFF: https://github.com/llvm/llvm-project/commit/8077a19f66b50573a043ef1c405e2149e0c69cb7.diff

LOG: Support: Remove sys::path::is_style_native()

Remove sys::path::is_style_native(), which was added alongside
is_style_windows() and is_style_posix().

Thinking a bit about the windows forward-slash style variant in
https://reviews.llvm.org/D111879, it's not clear to me how the new
sys::path::is_style_native() should behave for them.

- Should it return true for both `windows_slash` and
  `windows_backslash`?
- Should it return true for only one of them?

I can think of hypothetical uses and justifications for either one, and
I could also imagine clients guessing either behaviour when just looking
at the function name in code.

Call sites will probably be more clear if they don't use this function,
and instead write out the code:

```
// Is "S" the coarse-grained native style?
if (is_style_windows(S) == is_style_windows(Style::native))

// Is "S" the fine-grained native style?
if (is_style_windows(S) == is_style_windows(Style::native) &&
    preferred_separator(S) == preferred_separator(Style::native))
```

Can always add this again if someone needs it and can justify one
behaviour over the other, but for now might as well avoid growing users.

Added: 
    

Modified: 
    llvm/include/llvm/Support/Path.h
    llvm/unittests/Support/Path.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h
index 5a253ea1f3290..eb063d0719961 100644
--- a/llvm/include/llvm/Support/Path.h
+++ b/llvm/include/llvm/Support/Path.h
@@ -43,11 +43,6 @@ constexpr bool is_style_posix(Style S) {
 /// Check if \p S uses Windows path rules.
 constexpr bool is_style_windows(Style S) { return !is_style_posix(S); }
 
-/// Check if \p S uses the same path rules as Style::native.
-constexpr bool is_style_native(Style S) {
-  return is_style_posix(S) == is_style_posix(Style::native);
-}
-
 /// @name Lexical Component Iterator
 /// @{
 

diff  --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 52e447fc2b324..927b7eb35e9cb 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -86,11 +86,6 @@ TEST(is_style_Style, Works) {
   EXPECT_TRUE(is_style_posix(Style::native));
   EXPECT_FALSE(is_style_windows(Style::native));
 #endif
-
-  // Check is_style_native().
-  EXPECT_TRUE(is_style_native(Style::native));
-  EXPECT_EQ(is_style_posix(Style::native), is_style_native(Style::posix));
-  EXPECT_EQ(is_style_windows(Style::native), is_style_native(Style::windows));
 }
 
 TEST(is_separator, Works) {


        


More information about the llvm-commits mailing list