summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan/TestCases/memcmp_test.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
committerNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
commit673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582 (patch)
tree93e9f9c3508af096ba717ef85186950135b4c225 /compiler-rt/test/asan/TestCases/memcmp_test.cpp
parenta96cfee98a22e262367868f343b599c2312149b7 (diff)
downloadbcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.tar.gz
bcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.zip
compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes. llvm-svn: 367887
Diffstat (limited to 'compiler-rt/test/asan/TestCases/memcmp_test.cpp')
-rw-r--r--compiler-rt/test/asan/TestCases/memcmp_test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/memcmp_test.cpp b/compiler-rt/test/asan/TestCases/memcmp_test.cpp
new file mode 100644
index 00000000000..e666b6d162b
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/memcmp_test.cpp
@@ -0,0 +1,17 @@
+// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: compiler-rt-optimized
+
+#include <string.h>
+int main(int argc, char **argv) {
+ char a1[] = {static_cast<char>(argc), 2, 3, 4};
+ char a2[] = {1, static_cast<char>(2*argc), 3, 4};
+ int res = memcmp(a1, a2, 4 + argc); // BOOM
+ // CHECK: AddressSanitizer: stack-buffer-overflow
+ // CHECK: {{#1.*memcmp}}
+ // CHECK: {{#2.*main}}
+ return res;
+}
OpenPOWER on IntegriCloud