Supports either default of -f[no-]sanitize-memory-param-retval.
Reviewed By: aeubanks, MaskRay
Differential Revision: https://reviews.llvm.org/D134683
-// RUN: %clangxx_msan -fno-sanitize=memory -c %s -o %t-main.o
-// RUN: %clangxx_msan %t-main.o %s -o %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fno-sanitize=memory -c %s -o %t-main.o
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval %t-main.o %s -o %t
// RUN: %run %t
#include <assert.h>
// __NO_INLINE__ is defined so bsearch needs interceptor.
-// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON_DATA -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -DPOISON_KEY -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_DATA -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_KEY -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// __NO_INLINE__ is undefined so bsearch should be inlined and instrumented and still work as expected.
-// RUN: %clangxx_msan -O2 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON_DATA -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -DPOISON_KEY -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O2 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_DATA -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_KEY -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <assert.h>
#include <stdlib.h>
volatile int x, y;
-__attribute__((noinline))
-void fn_g(int a) {
- x = a;
-}
+__attribute__((noinline)) void fn_g(int &a) { x = a; }
-__attribute__((noinline))
-void fn_f(int a) {
- fn_g(a);
-}
+__attribute__((noinline)) void fn_f(int &a) { fn_g(a); }
-__attribute__((noinline))
-void fn_h() {
- y = x;
-}
+__attribute__((noinline)) void fn_h() { y = x; }
int main(int argc, char *argv[]) {
#ifdef HEAP
#else
int volatile z;
#endif
- fn_f(z);
+ fn_f((int &)z);
fn_h();
return y;
}
// CHECK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-4]]
// CHECK: Uninitialized value was stored to memory at
-// CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-19]]
+// CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-18]]
// CHECK-FULL-STACK: {{#1 .* in main.*chained_origin.cpp:}}[[@LINE-9]]
// CHECK-SHORT-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-21]]
// CHECK: Uninitialized value was stored to memory at
-// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-34]]
-// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cpp:}}[[@LINE-30]]
+// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-27]]
+// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cpp:}}[[@LINE-26]]
// CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cpp:}}[[@LINE-16]]
// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-37]]
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
// RUN: MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
// Test that stack trace for the intermediate store is not empty.
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
-
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t %p
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t %p
// PR17377: C++ module destructors get stale argument shadow.
int y;
};
-mypair my_make_pair(int64_t x, int y) {
+mypair my_make_pair(int64_t &x, int y) {
mypair p;
p.x = x;
p.y = y;
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O1 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O2 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O3 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O1 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O2 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O3 %s -o %t && %run %t >%t.out 2>&1
// Test that (no_sanitize_memory) functions DO NOT propagate shadow.
-// RUN: %clangxx_msan %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan %s -fno-sanitize-memory-param-retval -o %t && %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=MISSED --allow-empty < %t.out
-// RUN: %clangxx_msan %s -mllvm -msan-eager-checks=1 -o %t && not %run %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan %s -disable-noundef-analysis -fsanitize-memory-param-retval -o %t && not %run %t >%t.out 2>&1
+// RUN: %clangxx_msan %s -mllvm -msan-eager-checks=1 -fno-sanitize-memory-param-retval -o %t && not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out
struct SimpleStruct {
// ParamTLS has limited size. Everything that does not fit is considered fully
// initialized.
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O0 %s -o %t && %run %t
//
// AArch64 fails with:
// void f801(S<801>): Assertion `__msan_test_shadow(&s, sizeof(s)) == -1' failed
-// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <assert.h>
#include <errno.h>
-// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -std=c++11 -O0 %s -o %t && %run %t
//
// Test that va_arg shadow from a signal handler does not leak outside.
// compile main() without MSan.
// RUN: %clangxx_msan -fno-sanitize=memory -c %s -o %t-main.o
-// RUN: %clangxx_msan %t-main.o %s -o %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval %t-main.o %s -o %t
// RUN: %run %t
#include <assert.h>
#include <emmintrin.h>
-int to_int(double v) {
+int to_int(double &v) {
__m128d t = _mm_set_sd(v);
int x = _mm_cvtsd_si32(t);
return x;