xref: /aosp_15_r20/external/compiler-rt/test/msan/inline.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O3 %s -o %t && %run %t
2*7c3d14c8STreehugger Robot 
3*7c3d14c8STreehugger Robot // Test that no_sanitize_memory attribute applies even when the function would
4*7c3d14c8STreehugger Robot // be normally inlined.
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot #include <stdlib.h>
7*7c3d14c8STreehugger Robot 
8*7c3d14c8STreehugger Robot __attribute__((no_sanitize_memory))
f(int * p)9*7c3d14c8STreehugger Robot int f(int *p) {
10*7c3d14c8STreehugger Robot   if (*p) // BOOOM?? Nope!
11*7c3d14c8STreehugger Robot     exit(0);
12*7c3d14c8STreehugger Robot   return 0;
13*7c3d14c8STreehugger Robot }
14*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)15*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
16*7c3d14c8STreehugger Robot   int x;
17*7c3d14c8STreehugger Robot   int * volatile p = &x;
18*7c3d14c8STreehugger Robot   int res = f(p);
19*7c3d14c8STreehugger Robot   return 0;
20*7c3d14c8STreehugger Robot }
21