From c2feac75fd3f3ef3f64465e498848699ff43286f Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Mon, 28 Mar 2016 21:32:46 +0000 Subject: [PATCH] [libprofile] Handle '\\' in __llvm_profile_recursive_mkdir This is implicitly needed at least by gcc-flag-compatibility.test The thing that needs it is the `\` preceding the "default.profraw" appended internally by clang when doing `-fprofile-use=`. Clang uses `\` because is uses sys::path::append which will use `\` on a Windows host. This is wrong, but I don't think there's an easy way to solve it (maybe just always using `/` since places that accept `\` also tend to accept `/`, but not the other way around). llvm-svn: 264665 --- compiler-rt/lib/profile/InstrProfilingFile.c | 2 +- compiler-rt/lib/profile/InstrProfilingUtil.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index 2f24f00..9d63269 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -79,7 +79,7 @@ static void truncateCurrentFile(void) { return; /* Create the directory holding the file, if needed. */ - if (strchr(Filename, '/')) { + if (strchr(Filename, '/') || strchr(Filename, '\\')) { char *Copy = malloc(strlen(Filename) + 1); strcpy(Copy, Filename); __llvm_profile_recursive_mkdir(Copy); diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c b/compiler-rt/lib/profile/InstrProfilingUtil.c index 5359984..04bdb3e 100644 --- a/compiler-rt/lib/profile/InstrProfilingUtil.c +++ b/compiler-rt/lib/profile/InstrProfilingUtil.c @@ -28,14 +28,16 @@ void __llvm_profile_recursive_mkdir(char *path) { int i; for (i = 1; path[i] != '\0'; ++i) { - if (path[i] != '/') continue; + char save = path[i]; + if (!(path[i] == '/' || path[i] == '\\')) + continue; path[i] = '\0'; #ifdef _WIN32 _mkdir(path); #else mkdir(path, 0755); /* Some of these will fail, ignore it. */ #endif - path[i] = '/'; + path[i] = save; } } -- 2.7.4