[compiler-rt] r230986 - [Sanitizer] Fix StripPathPrefix function and improve test case.

Alexey Samsonov vonosmas at gmail.com
Mon Mar 2 10:55:46 PST 2015


Author: samsonov
Date: Mon Mar  2 12:55:46 2015
New Revision: 230986

URL: http://llvm.org/viewvc/llvm-project?rev=230986&view=rev
Log:
[Sanitizer] Fix StripPathPrefix function and improve test case.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
    compiler-rt/trunk/test/asan/TestCases/strip_path_prefix.c

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=230986&r1=230985&r2=230986&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Mon Mar  2 12:55:46 2015
@@ -207,12 +207,12 @@ const char *StripPathPrefix(const char *
                             const char *strip_path_prefix) {
   if (filepath == 0) return 0;
   if (strip_path_prefix == 0) return filepath;
-  const char *pos = internal_strstr(filepath, strip_path_prefix);
-  if (pos == 0) return filepath;
-  pos += internal_strlen(strip_path_prefix);
-  if (pos[0] == '.' && pos[1] == '/')
-    pos += 2;
-  return pos;
+  const char *res = filepath;
+  if (const char *pos = internal_strstr(filepath, strip_path_prefix))
+    res = pos + internal_strlen(strip_path_prefix);
+  if (res[0] == '.' && res[1] == '/')
+    res += 2;
+  return res;
 }
 
 const char *StripModuleName(const char *module) {

Modified: compiler-rt/trunk/test/asan/TestCases/strip_path_prefix.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/strip_path_prefix.c?rev=230986&r1=230985&r2=230986&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/strip_path_prefix.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/strip_path_prefix.c Mon Mar  2 12:55:46 2015
@@ -1,5 +1,5 @@
 // RUN: %clang_asan -O2 %s -o %t
-// RUN: env ASAN_OPTIONS="strip_path_prefix='/'" not %run %t 2>&1 | FileCheck %s
+// RUN: env ASAN_OPTIONS="strip_path_prefix='%S/'" not %run %t 2>&1 | FileCheck %s
 
 #include <stdlib.h>
 int main() {
@@ -8,5 +8,5 @@ int main() {
   return x[5];
   // Check that paths in error report don't start with slash.
   // CHECK: heap-use-after-free
-  // CHECK-NOT: #0 0x{{.*}} ({{[/].*}})
+  // CHECK: #0 0x{{.*}} in main strip_path_prefix.c:[[@LINE-3]]
 }





More information about the llvm-commits mailing list