[ASan/Win] Use clang rather than clang-cl by default for lit tests. Make Windows...
[blocksruntime.git] / test / msan / strlen_of_shadow.cc
blobbb9fe17d41cdb18422623d845ba3a8fa2a7e7f2d
1 // RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t
3 // Check that strlen() and similar intercepted functions can be called on shadow
4 // memory.
6 #include <assert.h>
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <string.h>
11 const char *mem_to_shadow(const char *p) {
12 return (char *)((uintptr_t)p & ~0x400000000000ULL);
15 int main(void) {
16 const char *s = "abcdef";
17 assert(strlen(s) == 6);
18 assert(strlen(mem_to_shadow(s)) == 0);
20 char *t = new char[42];
21 t[41] = 0;
22 assert(strlen(mem_to_shadow(t)) == 41);
23 return 0;