1 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=0 -O3 %s -o %t && \
2 // RUN: not %run %t va_arg_tls >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK < %t.out
5 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=0 -O3 %s -o %t && \
6 // RUN: not %run %t overflow >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK < %t.out
9 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
10 // RUN: not %run %t va_arg_tls >%t.out 2>&1
11 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN < %t.out
13 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
14 // RUN: not %run %t overflow >%t.out 2>&1
15 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN < %t.out
17 // Check that shadow and origin are passed through va_args.
19 // Copying origins on AArch64, LoongArch64, MIPS and PowerPC isn't supported yet.
20 // XFAIL: target={{(aarch64|loongarch64|mips|powerpc64).*}}
25 __attribute__((noinline
))
31 for (i
= 0; i
< n
; i
++) {
32 arg
= va_arg(args
, int);
39 int main(int argc
, char *argv
[]) {
41 volatile int a
= 1, b
= 2;
43 // Shadow/origin will be passed via va_arg_tls/va_arg_origin_tls.
44 if (strcmp(argv
[1], "va_arg_tls") == 0) {
45 return sum(3, uninit
, a
, b
);
47 // Shadow/origin of |uninit| will be passed via overflow area.
48 if (strcmp(argv
[1], "overflow") == 0) {
50 a
, a
, a
, a
, a
, a
, uninit
57 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
58 // CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame