[PATCH] D112786: [Support] Factorize more cases of style checks to use is_style_windows. NFC.

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 02:02:25 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: dexonsmith, rnk, thakis.
Herald added a subscriber: hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

These conditions apply in the same way for Windows path styles with
forward slashes.

After D112289 <https://reviews.llvm.org/D112289>, the only remaining uses of `real_path` are in
`preferred_separator`, `get_separator` (and in `remove_dots` which doesn't
compare literal enum values though).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112786

Files:
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===================================================================
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -43,7 +43,7 @@
   }
 
   inline const char *separators(Style style) {
-    if (real_style(style) == Style::windows)
+    if (is_style_windows(style))
       return "\\/";
     return "/";
   }
@@ -546,7 +546,7 @@
 void native(SmallVectorImpl<char> &Path, Style style) {
   if (Path.empty())
     return;
-  if (real_style(style) == Style::windows) {
+  if (is_style_windows(style)) {
     std::replace(Path.begin(), Path.end(), '/', '\\');
     if (Path[0] == '~' && (Path.size() == 1 || is_separator(Path[1], style))) {
       SmallString<128> PathHome;
@@ -560,7 +560,7 @@
 }
 
 std::string convert_to_slash(StringRef path, Style style) {
-  if (real_style(style) != Style::windows)
+  if (!is_style_windows(style))
     return std::string(path);
 
   std::string s = path.str();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112786.383261.patch
Type: text/x-patch
Size: 946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211029/6527b128/attachment.bin>


More information about the llvm-commits mailing list