summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2018-07-24 13:06:19 +0000
committerIgor Kudrin <ikudrin@accesssoftek.com>2018-07-24 13:06:19 +0000
commit37bd9aa510166186a9bba5cf13d717d6b097c95e (patch)
treee1aa734436d1bd891fed2a6e5e7256859f063f88
parent936ae292f7447ca449f8edb613a86415df172166 (diff)
[profile] Fix finding the first and last directory separators on Windows.
Until now, our code preferred backslashes to slashes, whereas Windows allows using both types of directory separators in one path string. Differential Revision: https://reviews.llvm.org/D49664 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337826 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/profile/InstrProfilingUtil.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/profile/InstrProfilingUtil.c b/lib/profile/InstrProfilingUtil.c
index 7f49d0f9f..d053ab160 100644
--- a/lib/profile/InstrProfilingUtil.c
+++ b/lib/profile/InstrProfilingUtil.c
@@ -243,23 +243,21 @@ lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
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;
}