From 33706e3cbf35dd55f67ee0802d50e96b07757bc1 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 1 Feb 2019 21:35:17 +0000 Subject: [PATCH] [ubsan] Make suppressions.cpp test pass for me on Windows The test seems to be failing because the module suppression file contains a colon. I found that it was sufficient to just use the basename of the suppression file. While I was here, I noticed that we don't implement IsAbsolutePath for Windows, so I added it. llvm-svn: 352921 --- compiler-rt/lib/sanitizer_common/sanitizer_win.cc | 8 +++++++- compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc index 228f9530e69a..27262dad9f10 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc @@ -486,8 +486,14 @@ bool IsPathSeparator(const char c) { return c == '\\' || c == '/'; } +static bool IsAlpha(char c) { + c = ToLower(c); + return c >= 'a' && c <= 'z'; +} + bool IsAbsolutePath(const char *path) { - UNIMPLEMENTED(); + return path != nullptr && IsAlpha(path[0]) && path[1] == ':' && + IsPathSeparator(path[2]); } void SleepForSeconds(int seconds) { diff --git a/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp b/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp index 65d8bba13b01..c6f8f4158401 100644 --- a/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp +++ b/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp @@ -15,7 +15,10 @@ // RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.func-supp"' %run %t -// RUN: echo "unsigned-integer-overflow:%t" > %t.module-supp +// FIXME: The '%t' substitution can't be used for the module name because it +// contains a colon, so we have to use the basename, which is +// suppressions.cpp.tmp. +// RUN: echo "unsigned-integer-overflow:suppressions.cpp.tmp" > %t.module-supp // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.module-supp"' %run %t // Note: file-level suppressions should work even without debug info.