diff options
Diffstat (limited to 'test/msan/no_sanitize_memory.cc')
-rw-r--r-- | test/msan/no_sanitize_memory.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/msan/no_sanitize_memory.cc b/test/msan/no_sanitize_memory.cc new file mode 100644 index 000000000000..c5643816c281 --- /dev/null +++ b/test/msan/no_sanitize_memory.cc @@ -0,0 +1,34 @@ +// RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O1 %s -o %t && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O2 %s -o %t && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O3 %s -o %t && %run %t >%t.out 2>&1 + +// RUN: %clangxx_msan -m64 -O0 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O1 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O2 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -m64 -O3 %s -o %t -DCHECK_IN_F && %run %t >%t.out 2>&1 + +// Test that (no_sanitize_memory) functions +// * don't check shadow values (-DCHECK_IN_F) +// * treat all values loaded from memory as fully initialized (-UCHECK_IN_F) + +#include <stdlib.h> +#include <stdio.h> + +__attribute__((noinline)) +__attribute__((no_sanitize_memory)) +int f(void) { + int x; + int * volatile p = &x; +#ifdef CHECK_IN_F + if (*p) + exit(0); +#endif + return *p; +} + +int main(void) { + if (f()) + exit(0); + return 0; +} |