[PATCH] D49664: [profile] Fix finding the first and last directory separators on Windows.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 24 06:06:37 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337826: [profile] Fix finding the first and last directory separators on Windows. (authored by ikudrin, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D49664?vs=156749&id=157014#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49664

Files:
  compiler-rt/trunk/lib/profile/InstrProfilingUtil.c


Index: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
===================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
@@ -243,23 +243,21 @@
 
 COMPILER_RT_VISIBILITY const char *
 lprofFindFirstDirSeparator(const char *Path) {
-  const char *Sep;
-  Sep = strchr(Path, DIR_SEPARATOR);
-  if (Sep)
-    return Sep;
+  const char *Sep = strchr(Path, DIR_SEPARATOR);
 #if defined(DIR_SEPARATOR_2)
-  Sep = strchr(Path, DIR_SEPARATOR_2);
+  const char *Sep2 = strchr(Path, DIR_SEPARATOR_2);
+  if (Sep2 && (!Sep || Sep2 < Sep))
+    Sep = Sep2;
 #endif
   return Sep;
 }
 
 COMPILER_RT_VISIBILITY const char *lprofFindLastDirSeparator(const char *Path) {
-  const char *Sep;
-  Sep = strrchr(Path, DIR_SEPARATOR);
-  if (Sep)
-    return Sep;
+  const char *Sep = strrchr(Path, DIR_SEPARATOR);
 #if defined(DIR_SEPARATOR_2)
-  Sep = strrchr(Path, DIR_SEPARATOR_2);
+  const char *Sep2 = strrchr(Path, DIR_SEPARATOR_2);
+  if (Sep2 && (!Sep || Sep2 > Sep))
+    Sep = Sep2;
 #endif
   return Sep;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49664.157014.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180724/52c01434/attachment.bin>


More information about the llvm-commits mailing list