summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-03-02 18:55:46 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-03-02 18:55:46 +0000
commit1be519876d7e5c5c6bc4bbad34237a5e0b222765 (patch)
treecc03214a0d9d0f68dccf0d807138b557688975b8 /compiler-rt
parent9f4cfc574ed435d8e4d0db8d5d99d582a6400c37 (diff)
downloadbcm5719-llvm-1be519876d7e5c5c6bc4bbad34237a5e0b222765.tar.gz
bcm5719-llvm-1be519876d7e5c5c6bc4bbad34237a5e0b222765.zip
[Sanitizer] Fix StripPathPrefix function and improve test case.
llvm-svn: 230986
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.cc12
-rw-r--r--compiler-rt/test/asan/TestCases/strip_path_prefix.c4
2 files changed, 8 insertions, 8 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
index 030264b223d..350252e9fc7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
@@ -207,12 +207,12 @@ const char *StripPathPrefix(const char *filepath,
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) {
diff --git a/compiler-rt/test/asan/TestCases/strip_path_prefix.c b/compiler-rt/test/asan/TestCases/strip_path_prefix.c
index 4556e9031e2..c441eac9259 100644
--- a/compiler-rt/test/asan/TestCases/strip_path_prefix.c
+++ b/compiler-rt/test/asan/TestCases/strip_path_prefix.c
@@ -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]]
}
OpenPOWER on IntegriCloud