[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / msan / dso-origin.cpp
blob4cc86dc44ec95d8787e999b122c1f211f047f74d
1 // Build a library with origin tracking and an executable w/o origin tracking.
2 // Test that origin tracking is enabled at runtime.
3 // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -DBUILD_SO -fPIC -shared -o %t-so.so
4 // RUN: %clangxx_msan -O0 %s %t-so.so -o %t && not %run %t 2>&1 | FileCheck %s
6 #ifdef BUILD_SO
8 #include <stdlib.h>
10 extern "C" {
11 void my_access(int *p) {
12 volatile int tmp;
13 // Force initialize-ness check.
14 if (*p)
15 tmp = 1;
18 void *my_alloc(unsigned sz) {
19 return malloc(sz);
21 } // extern "C"
23 #else // BUILD_SO
25 #include <stdlib.h>
27 extern "C" {
28 void my_access(int *p);
29 void *my_alloc(unsigned sz);
32 int main(int argc, char **argv) {
33 int *x = (int *)my_alloc(sizeof(int));
34 my_access(x);
35 delete x;
37 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
38 // CHECK: {{#0 0x.* in my_access .*dso-origin.cpp:}}
39 // CHECK: {{#1 0x.* in main .*dso-origin.cpp:}}[[@LINE-5]]
40 // CHECK: Uninitialized value was created by a heap allocation
41 // CHECK: {{#0 0x.* in .*malloc}}
42 // CHECK: {{#1 0x.* in my_alloc .*dso-origin.cpp:}}
43 // CHECK: {{#2 0x.* in main .*dso-origin.cpp:}}[[@LINE-10]]
44 // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*dso-origin.cpp:.* my_access}}
45 return 0;
48 #endif // BUILD_SO