aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-26 20:33:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-26 20:33:22 +0000
commit10fcf738d732204a1f1e28878d68a27c5f12cf3b (patch)
tree7c66ecc62314115c1e895c238381883363acafd8 /test
parent4658ff5fee0369e08fe69bce90019fad154d9330 (diff)
downloadsrc-10fcf738d732204a1f1e28878d68a27c5f12cf3b.tar.gz
src-10fcf738d732204a1f1e28878d68a27c5f12cf3b.zip
Vendor import of compiler-rt trunk r306325:vendor/compiler-rt/compiler-rt-trunk-r306325
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=320378 svn path=/vendor/compiler-rt/compiler-rt-trunk-r306325/; revision=320379; tag=vendor/compiler-rt/compiler-rt-trunk-r306325
Diffstat (limited to 'test')
-rw-r--r--test/asan/TestCases/Linux/allocator_oom_test.cc3
-rw-r--r--test/asan/TestCases/Linux/preinstalled_signal.cc44
-rw-r--r--test/asan/TestCases/Windows/oom.cc2
-rw-r--r--test/asan/TestCases/pr33372.cc39
-rw-r--r--test/asan/lit.cfg1
-rw-r--r--test/esan/TestCases/workingset-midreport.cpp3
-rw-r--r--test/esan/TestCases/workingset-samples.cpp3
-rw-r--r--test/esan/TestCases/workingset-simple.cpp3
-rw-r--r--test/lsan/TestCases/Darwin/dispatch.mm59
-rw-r--r--test/lsan/TestCases/Darwin/lit.local.cfg9
-rw-r--r--test/lsan/lit.common.cfg2
-rw-r--r--test/profile/Linux/counter_promo_for.c59
-rw-r--r--test/profile/Linux/counter_promo_while.c55
-rw-r--r--test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc2
-rw-r--r--test/scudo/random_shuffle.cpp2
-rw-r--r--test/ubsan/TestCases/Misc/nonnull.cpp37
-rw-r--r--test/ubsan/TestCases/Misc/nullability.c2
-rw-r--r--test/xray/TestCases/Linux/arg1-arg0-logging.cc39
18 files changed, 333 insertions, 31 deletions
diff --git a/test/asan/TestCases/Linux/allocator_oom_test.cc b/test/asan/TestCases/Linux/allocator_oom_test.cc
index c93e9fe21726..4c696f325803 100644
--- a/test/asan/TestCases/Linux/allocator_oom_test.cc
+++ b/test/asan/TestCases/Linux/allocator_oom_test.cc
@@ -28,6 +28,9 @@
// RUN: %env_asan_opts=allocator_may_return_null=1 %run %t realloc-after-malloc 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK-MALLOC-REALLOC,CHECK-NULL
+// ASan shadow memory on s390 is too large for this test.
+// UNSUPPORTED: s390
+
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
diff --git a/test/asan/TestCases/Linux/preinstalled_signal.cc b/test/asan/TestCases/Linux/preinstalled_signal.cc
index 40dadf43dc4e..4d466c21f944 100644
--- a/test/asan/TestCases/Linux/preinstalled_signal.cc
+++ b/test/asan/TestCases/Linux/preinstalled_signal.cc
@@ -4,11 +4,13 @@
// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=2 not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx -std=c++11 -DTEST_INSTALL_SIG_HANDLER %s -o %t
-// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-HANDLER %s
+// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-HANDLER
+// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=1 not %run %t 2>&1 | FileCheck %s
// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=2 not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx -std=c++11 -DTEST_INSTALL_SIG_ACTION %s -o %t
-// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ACTION %s
+// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ACTION
+// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=1 not %run %t 2>&1 | FileCheck %s
// RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=2 not %run %t 2>&1 | FileCheck %s
// REQUIRES: asan-dynamic-runtime
@@ -51,22 +53,22 @@ int InternalSigaction(int sig, KernelSigaction *act, KernelSigaction *oact) {
return syscall(__NR_rt_sigaction, sig, act, oact, NSIG / 8);
}
-struct KernelSigaction sigact = {};
+struct KernelSigaction pre_asan = {};
static void Init() {
- int res = InternalSigaction(SIGSEGV, nullptr, &sigact);
+ int res = InternalSigaction(SIGSEGV, nullptr, &pre_asan);
assert(res >= 0);
- assert(sigact.handler == SIG_DFL || sigact.handler == SIG_IGN);
+ assert(pre_asan.handler == SIG_DFL || pre_asan.handler == SIG_IGN);
#if defined(TEST_INSTALL_SIG_HANDLER)
- sigact = {};
- sigact.handler = &SigHandler;
- res = InternalSigaction(SIGSEGV, &sigact, nullptr);
+ pre_asan = {};
+ pre_asan.handler = &SigHandler;
+ res = InternalSigaction(SIGSEGV, &pre_asan, nullptr);
assert(res >= 0);
#elif defined(TEST_INSTALL_SIG_ACTION)
- sigact = {};
- sigact.flags = SA_SIGINFO | SA_NODEFER;
- sigact.handler = (__sighandler_t)&SigAction;
- res = InternalSigaction(SIGSEGV, &sigact, nullptr);
+ pre_asan = {};
+ pre_asan.flags = SA_SIGINFO | SA_NODEFER;
+ pre_asan.handler = (__sighandler_t)&SigAction;
+ res = InternalSigaction(SIGSEGV, &pre_asan, nullptr);
assert(res >= 0);
#endif
}
@@ -74,21 +76,21 @@ static void Init() {
__attribute__((section(".preinit_array"), used))
void (*__local_test_preinit)(void) = Init;
-bool ShouldAsanInstallHandlers() {
+bool ExpectUserHandler() {
#if defined(TEST_INSTALL_SIG_HANDLER) || defined(TEST_INSTALL_SIG_ACTION)
- return !strcmp(getenv("ASAN_OPTIONS"), "handle_segv=2");
+ return !strcmp(getenv("ASAN_OPTIONS"), "handle_segv=0");
#endif
- return true;
+ return false;
}
int main(int argc, char *argv[]) {
- KernelSigaction sigact_asan = {};
- InternalSigaction(SIGSEGV, nullptr, &sigact_asan);
+ KernelSigaction post_asan = {};
+ InternalSigaction(SIGSEGV, nullptr, &post_asan);
- assert(sigact_asan.handler != SIG_DFL);
- assert(sigact_asan.handler != SIG_IGN);
- assert(ShouldAsanInstallHandlers() ==
- (sigact_asan.handler != sigact.handler));
+ assert(post_asan.handler != SIG_DFL);
+ assert(post_asan.handler != SIG_IGN);
+ assert(ExpectUserHandler() ==
+ (post_asan.handler == pre_asan.handler));
raise(SIGSEGV);
printf("%s\n", handler);
diff --git a/test/asan/TestCases/Windows/oom.cc b/test/asan/TestCases/Windows/oom.cc
index 59cc7ed0e9d1..71a9c2a759a9 100644
--- a/test/asan/TestCases/Windows/oom.cc
+++ b/test/asan/TestCases/Windows/oom.cc
@@ -8,5 +8,5 @@ int main() {
while (true) {
void *ptr = malloc(200 * 1024 * 1024); // 200MB
}
-// CHECK: failed to allocate
+// CHECK: allocator is terminating the process instead of returning 0
}
diff --git a/test/asan/TestCases/pr33372.cc b/test/asan/TestCases/pr33372.cc
new file mode 100644
index 000000000000..a4b606e025c9
--- /dev/null
+++ b/test/asan/TestCases/pr33372.cc
@@ -0,0 +1,39 @@
+// RUN: %clangxx_asan -O0 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O1 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O2 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
+
+// Test that we do not detect false buffer overflows cased by optimization when
+// when local variable replaced by a smaller global constant.
+// https://bugs.llvm.org/show_bug.cgi?id=33372
+
+#include <stdio.h>
+#include <string.h>
+
+struct A { int x, y, z; };
+struct B { A a; /*gap*/ long b; };
+B *bb;
+
+void test1() {
+ A a1 = {1, 1, 2};
+ B b1 = {a1, 6};
+ bb = new B(b1);
+}
+
+const char KKK[] = {1, 1, 2};
+char bbb[100000];
+
+void test2() {
+ char cc[sizeof(bbb)];
+ memcpy(cc, KKK , sizeof(KKK));
+ memcpy(bbb, cc, sizeof(bbb));
+}
+
+int main(int argc, char *argv[]) {
+ test1();
+ test2();
+ printf("PASSED");
+ return 0;
+}
+
+// CHECK-NOT: ERROR: AddressSanitizer
+// CHECK: PASSED
diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg
index 063c33b02697..e25dd297aa3b 100644
--- a/test/asan/lit.cfg
+++ b/test/asan/lit.cfg
@@ -114,6 +114,7 @@ asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
if config.android == "1":
config.available_features.add('android')
compile_wrapper = os.path.join(asan_lit_source_dir, "android_commands", "android_compile.py") + " "
+ config.compile_wrapper = compile_wrapper
else:
config.available_features.add('not-android')
diff --git a/test/esan/TestCases/workingset-midreport.cpp b/test/esan/TestCases/workingset-midreport.cpp
index 2c29cf48ccf7..38c376554380 100644
--- a/test/esan/TestCases/workingset-midreport.cpp
+++ b/test/esan/TestCases/workingset-midreport.cpp
@@ -4,6 +4,9 @@
// RUN: %clang -O0 %s -o %t 2>&1
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ESAN
+// FIXME: Re-enable once PR33590 is fixed.
+// UNSUPPORTED: x86_64
+
#include <sanitizer/esan_interface.h>
#include <sched.h>
#include <stdio.h>
diff --git a/test/esan/TestCases/workingset-samples.cpp b/test/esan/TestCases/workingset-samples.cpp
index 7db2110b924f..d97b62ba4e8a 100644
--- a/test/esan/TestCases/workingset-samples.cpp
+++ b/test/esan/TestCases/workingset-samples.cpp
@@ -1,6 +1,9 @@
// RUN: %clang_esan_wset -O0 %s -o %t 2>&1
// RUN: %run %t 2>&1 | FileCheck %s
+// FIXME: Re-enable once PR33590 is fixed.
+// UNSUPPORTED: x86_64
+
#include <sanitizer/esan_interface.h>
#include <sched.h>
#include <stdlib.h>
diff --git a/test/esan/TestCases/workingset-simple.cpp b/test/esan/TestCases/workingset-simple.cpp
index c8a2d52e7b55..f1ac2ecfe132 100644
--- a/test/esan/TestCases/workingset-simple.cpp
+++ b/test/esan/TestCases/workingset-simple.cpp
@@ -1,6 +1,9 @@
// RUN: %clang_esan_wset -O0 %s -o %t 2>&1
// RUN: %run %t 2>&1 | FileCheck %s
+// FIXME: Re-enable once PR33590 is fixed.
+// UNSUPPORTED: x86_64
+
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
diff --git a/test/lsan/TestCases/Darwin/dispatch.mm b/test/lsan/TestCases/Darwin/dispatch.mm
new file mode 100644
index 000000000000..606cc9e1cb1e
--- /dev/null
+++ b/test/lsan/TestCases/Darwin/dispatch.mm
@@ -0,0 +1,59 @@
+// Test for threads spawned with wqthread_start
+// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
+// RUN: %clangxx_lsan %s -DDISPATCH_ASYNC -o %t-async -framework Foundation
+// RUN: %clangxx_lsan %s -DDISPATCH_SYNC -o %t-sync -framework Foundation
+// RUN: %env_lsan_opts=$LSAN_BASE not %run %t-async 2>&1 | FileCheck %s
+// RUN: %env_lsan_opts=$LSAN_BASE not %run %t-sync 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include "sanitizer_common/print_address.h"
+
+bool done = false;
+
+void worker_do_leak(int size) {
+ void *p = malloc(size);
+ print_address("Test alloc: ", 1, p);
+ done = true;
+}
+
+#if DISPATCH_ASYNC
+// Tests for the Grand Central Dispatch. See
+// http://developer.apple.com/library/mac/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html
+// for the reference.
+void TestGCDDispatch() {
+ dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
+ dispatch_block_t block = ^{
+ worker_do_leak(1337);
+ };
+ // dispatch_async() runs the task on a worker thread that does not go through
+ // pthread_create(). We need to verify that LeakSanitizer notices that the
+ // thread has started.
+ dispatch_async(queue, block);
+ while (!done)
+ pthread_yield_np();
+}
+#elif DISPATCH_SYNC
+void TestGCDDispatch() {
+ dispatch_queue_t queue = dispatch_get_global_queue(2, 0);
+ dispatch_block_t block = ^{
+ worker_do_leak(1337);
+ };
+ // dispatch_sync() runs the task on a worker thread that does not go through
+ // pthread_create(). We need to verify that LeakSanitizer notices that the
+ // thread has started.
+ dispatch_sync(queue, block);
+}
+#endif
+
+int main() {
+ TestGCDDispatch();
+ return 0;
+}
+
+// CHECK: Test alloc: [[addr:0x[0-9,a-f]+]]
+// CHECK: LeakSanitizer: detected memory leaks
+// CHECK: [[addr]] (1337 bytes)
+// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/Darwin/lit.local.cfg b/test/lsan/TestCases/Darwin/lit.local.cfg
new file mode 100644
index 000000000000..a85dfcd24c08
--- /dev/null
+++ b/test/lsan/TestCases/Darwin/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+ if not config.parent:
+ return config
+ return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Darwin']:
+ config.unsupported = True
diff --git a/test/lsan/lit.common.cfg b/test/lsan/lit.common.cfg
index 309e8f27be66..610b1b1ad958 100644
--- a/test/lsan/lit.common.cfg
+++ b/test/lsan/lit.common.cfg
@@ -77,4 +77,4 @@ if not (supported_linux or supported_darwin):
if re.search('mthumb', config.target_cflags) is not None:
config.unsupported = True
-config.suffixes = ['.c', '.cc', '.cpp']
+config.suffixes = ['.c', '.cc', '.cpp', '.mm']
diff --git a/test/profile/Linux/counter_promo_for.c b/test/profile/Linux/counter_promo_for.c
new file mode 100644
index 000000000000..3139646699d5
--- /dev/null
+++ b/test/profile/Linux/counter_promo_for.c
@@ -0,0 +1,59 @@
+// RUN: rm -fr %t.promo.prof
+// RUN: rm -fr %t.nopromo.prof
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen -O2 %s
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen.ll -emit-llvm -S -O2 %s
+// RUN: cat %t.promo.gen.ll | FileCheck --check-prefix=PROMO %s
+// RUN: %run %t.promo.gen
+// RUN: llvm-profdata merge -o %t.promo.profdata %t.promo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.promo.profdata > %t.promo.dump
+// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -o %t.nopromo.gen -O2 %s
+// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s
+// RUN: cat %t.nopromo.gen.ll | FileCheck --check-prefix=NOPROMO %s
+// RUN: %run %t.nopromo.gen
+// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
+// RUN: diff %t.promo.profdata %t.nopromo.profdata
+
+int g;
+__attribute__((noinline)) void bar(int i) { g += i; }
+
+__attribute__((noinline)) void foo(int n, int N) {
+// PROMO-LABEL: @foo
+// PROMO: load{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 2){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 2){{.*}}
+// PROMO: load{{.*}}@__profc_foo{{.*}} 3){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 3){{.*}}
+//
+// NOPROMO-LABEL: @foo
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 2){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 2){{.*}}
+ int i;
+ for (i = 0; i < N; i++) {
+ if (i < n + 1)
+ bar(1);
+ else if (i < n - 1)
+ bar(2);
+ else
+ bar(3);
+ }
+}
+
+int main() {
+ foo(10, 20);
+ return 0;
+}
diff --git a/test/profile/Linux/counter_promo_while.c b/test/profile/Linux/counter_promo_while.c
new file mode 100644
index 000000000000..b4d4e7aa20fe
--- /dev/null
+++ b/test/profile/Linux/counter_promo_while.c
@@ -0,0 +1,55 @@
+// RUN: rm -fr %t.promo.prof
+// RUN: rm -fr %t.nopromo.prof
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen -O2 %s
+// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen.ll -emit-llvm -S -O2 %s
+// RUN: cat %t.promo.gen.ll | FileCheck --check-prefix=PROMO %s
+// RUN: %run %t.promo.gen
+// RUN: llvm-profdata merge -o %t.promo.profdata %t.promo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.promo.profdata > %t.promo.dump
+// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -o %t.nopromo.gen -O2 %s
+// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s
+// RUN: cat %t.nopromo.gen.ll | FileCheck --check-prefix=NOPROMO %s
+// RUN: %run %t.nopromo.gen
+// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
+// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
+// RUN: diff %t.promo.profdata %t.nopromo.profdata
+int g;
+__attribute__((noinline)) void bar(int i) { g += i; }
+__attribute__((noinline)) void foo(int n, int N) {
+// PROMO-LABEL: @foo
+// PROMO: load{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 2){{.*}}
+// PROMO-NEXT: add
+// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 2){{.*}}
+//
+// NOPROMO-LABEL: @foo
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 0){{.*}}
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 1){{.*}}
+// NOPROMO: load{{.*}}@__profc_foo{{.*}} 2){{.*}}
+// NOPROMO-NEXT: add
+// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 2){{.*}}
+ int i = 0;
+ while (i < N) {
+ if (i < n + 1)
+ bar(1);
+ else if (i < n - 1)
+ bar(2);
+ else
+ bar(3);
+ i++;
+ }
+}
+
+int main() {
+ foo(10, 20);
+ return 0;
+}
diff --git a/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc b/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc
index 1a4ad1f066d9..b7246ebf2751 100644
--- a/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc
+++ b/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc
@@ -1,7 +1,7 @@
// Tests -fsanitize-coverage=inline-8bit-counters
//
// REQUIRES: has_sancovcc,stable-runtime
-// UNSUPPORTED: i386-darwin, x86_64-darwin, x86_64h-darwin
+// UNSUPPORTED: i386-darwin
//
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters 2>&1
diff --git a/test/scudo/random_shuffle.cpp b/test/scudo/random_shuffle.cpp
index 41e67ded67e9..05a432615017 100644
--- a/test/scudo/random_shuffle.cpp
+++ b/test/scudo/random_shuffle.cpp
@@ -7,7 +7,7 @@
// RUN: %run %t 10000 > %T/random_shuffle_tmp_dir/out2
// RUN: not diff %T/random_shuffle_tmp_dir/out?
// RUN: rm -rf %T/random_shuffle_tmp_dir
-// UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux,aarch64-linux
+// UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux,aarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux
// Tests that the allocator shuffles the chunks before returning to the user.
diff --git a/test/ubsan/TestCases/Misc/nonnull.cpp b/test/ubsan/TestCases/Misc/nonnull.cpp
index c3ab49c11df7..d5cd2bf763b7 100644
--- a/test/ubsan/TestCases/Misc/nonnull.cpp
+++ b/test/ubsan/TestCases/Misc/nonnull.cpp
@@ -1,15 +1,42 @@
-// RUN: %clangxx -fsanitize=returns-nonnull-attribute %s -O3 -o %t
-// RUN: %run %t foo
+// RUN: %clangxx -fsanitize=returns-nonnull-attribute -w %s -O3 -o %t
+// RUN: %run %t foo 2>&1 | count 0
// RUN: %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx -fsanitize=returns-nonnull-attribute -fno-sanitize-recover=returns-nonnull-attribute -w %s -O3 -o %t.abort
+// RUN: not %run %t.abort &> /dev/null
__attribute__((returns_nonnull)) char *foo(char *a);
char *foo(char *a) {
+ // CHECK: nonnull.cpp:[[@LINE+2]]:3: runtime error: null pointer returned from function declared to never return null
+ // CHECK-NEXT: nonnull.cpp:[[@LINE-4]]:16: note: returns_nonnull attribute specified here
return a;
- // CHECK: nonnull.cpp:[[@LINE+2]]:1: runtime error: null pointer returned from function declared to never return null
- // CHECK-NEXT: nonnull.cpp:[[@LINE-5]]:16: note: returns_nonnull attribute specified here
+}
+
+__attribute__((returns_nonnull)) char *bar(int x, char *a) {
+ if (x > 10) {
+ // CHECK: nonnull.cpp:[[@LINE+2]]:5: runtime error: null pointer returned from function declared to never return null
+ // CHECK-NEXT: nonnull.cpp:[[@LINE-3]]:16: note: returns_nonnull attribute specified here
+ return a;
+ } else {
+ // CHECK: nonnull.cpp:[[@LINE+2]]:5: runtime error: null pointer returned from function declared to never return null
+ // CHECK-NEXT: nonnull.cpp:[[@LINE-7]]:16: note: returns_nonnull attribute specified here
+ return a;
+ }
}
int main(int argc, char **argv) {
- return foo(argv[1]) == 0;
+ char *a = argv[1];
+
+ foo(a);
+
+ bar(20, a);
+
+ // We expect to see a runtime error the first time we cover the "else"...
+ bar(5, a);
+
+ // ... but not a second time.
+ // CHECK-NOT: runtime error
+ bar(5, a);
+
+ return 0;
}
diff --git a/test/ubsan/TestCases/Misc/nullability.c b/test/ubsan/TestCases/Misc/nullability.c
index 583b8ec12583..a6ddf0e2315b 100644
--- a/test/ubsan/TestCases/Misc/nullability.c
+++ b/test/ubsan/TestCases/Misc/nullability.c
@@ -2,7 +2,7 @@
// RUN: %run %t foo 2>&1 | count 0
// RUN: %run %t 2>&1 | FileCheck %s
-// CHECK: nullability.c:[[@LINE+2]]:51: runtime error: null pointer returned from function declared to never return null
+// CHECK: nullability.c:[[@LINE+2]]:41: runtime error: null pointer returned from function declared to never return null
// CHECK-NEXT: nullability.c:[[@LINE+1]]:6: note: _Nonnull return type annotation specified here
int *_Nonnull nonnull_retval1(int *p) { return p; }
diff --git a/test/xray/TestCases/Linux/arg1-arg0-logging.cc b/test/xray/TestCases/Linux/arg1-arg0-logging.cc
new file mode 100644
index 000000000000..e7730bfa6172
--- /dev/null
+++ b/test/xray/TestCases/Linux/arg1-arg0-logging.cc
@@ -0,0 +1,39 @@
+// Allow having both the no-arg and arg1 logging implementation live together,
+// and be called in the correct cases.
+//
+// RUN: rm arg0-arg1-logging-* || true
+// RUN: %clangxx_xray -std=c++11 %s -o %t
+// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=arg0-arg1-logging-" %run %t
+//
+// TODO: Support these in ARM and PPC
+// XFAIL: arm || aarch64 || mips
+// UNSUPPORTED: powerpc64le
+
+#include "xray/xray_interface.h"
+#include <cassert>
+#include <cstdio>
+
+using namespace std;
+
+bool arg0loggercalled = false;
+void arg0logger(int32_t, XRayEntryType) { arg0loggercalled = true; }
+
+[[clang::xray_always_instrument]] void arg0fn() { printf("hello, arg0!\n"); }
+
+bool arg1loggercalled = false;
+void arg1logger(int32_t, XRayEntryType, uint64_t) { arg1loggercalled = true; }
+
+[[ clang::xray_always_instrument, clang::xray_log_args(1) ]] void
+arg1fn(uint64_t arg1) {
+ printf("hello, arg1!\n");
+}
+
+int main(int argc, char *argv[]) {
+ __xray_set_handler(arg0logger);
+ __xray_set_handler_arg1(arg1logger);
+ arg0fn();
+ arg1fn(0xcafef00d);
+ __xray_remove_handler_arg1();
+ __xray_remove_handler();
+ assert(arg0loggercalled && arg1loggercalled);
+}