xref: /aosp_15_r20/external/compiler-rt/test/msan/unpoison_string.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t
2*7c3d14c8STreehugger Robot // RUN: %run %t
3*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t
4*7c3d14c8STreehugger Robot // RUN: %run %t
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot #include <assert.h>
7*7c3d14c8STreehugger Robot #include <string.h>
8*7c3d14c8STreehugger Robot #include <sanitizer/msan_interface.h>
9*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)10*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
11*7c3d14c8STreehugger Robot   char s[20] = "string";
12*7c3d14c8STreehugger Robot   __msan_poison(s, sizeof(s));
13*7c3d14c8STreehugger Robot   __msan_unpoison_string(s);
14*7c3d14c8STreehugger Robot   assert(__msan_test_shadow(s, sizeof(s)) == strlen("string") + 1);
15*7c3d14c8STreehugger Robot   return 0;
16*7c3d14c8STreehugger Robot }
17