2014-05-01 05:34:17 +08:00
|
|
|
// RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t >%t.out 2>&1
|
2014-07-03 19:35:08 +08:00
|
|
|
// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %run %t >%t.out 2>&1
|
|
|
|
// RUN: FileCheck %s < %t.out
|
|
|
|
// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %run %t >%t.out 2>&1
|
|
|
|
// RUN: FileCheck %s < %t.out
|
|
|
|
// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %run %t >%t.out 2>&1
|
|
|
|
// RUN: FileCheck %s < %t.out
|
2013-02-28 19:25:54 +08:00
|
|
|
|
2014-07-03 19:35:08 +08:00
|
|
|
// Test that (no_sanitize_memory) functions propagate shadow.
|
|
|
|
|
|
|
|
// Note that at -O0 there is no report, because 'x' in 'f' is spilled to the
|
|
|
|
// stack, and then loaded back as a fully initialiazed value (due to
|
|
|
|
// no_sanitize_memory attribute).
|
2013-02-28 19:25:54 +08:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
__attribute__((noinline))
|
|
|
|
__attribute__((no_sanitize_memory))
|
|
|
|
int f(int x) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
int x;
|
|
|
|
int * volatile p = &x;
|
|
|
|
int y = f(*p);
|
2014-07-03 19:35:08 +08:00
|
|
|
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
|
|
|
|
// CHECK: {{#0 0x.* in main .*no_sanitize_memory_prop.cc:}}[[@LINE+1]]
|
2013-02-28 19:25:54 +08:00
|
|
|
if (y)
|
|
|
|
exit(0);
|
|
|
|
return 0;
|
|
|
|
}
|