1// Check that -asan-use-private-alias silence the false
2// positive ODR violation on Darwin with LTO.
3
4// REQUIRES: lto
5
6// RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto -mllvm -asan-use-private-alias
7// RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto -mllvm -asan-use-private-alias
8// RUN: %clangxx_asan_lto %t-1.o %t-2.o -o %t -flto -mlinker-version=133
9// RUN: %run %t 2>&1 | FileCheck %s
10
11#include <stdio.h>
12#include <stdlib.h>
13void putstest();
14
15#if PART == 1
16
17static const char *my_global = "test\n\00abc";
18
19int main()
20{
21 fputs(my_global, stderr);
22 putstest();
23 fprintf(stderr, "Done.\n");
24 return 0;
25}
26
27#else // PART == 1
28
29static const char *my_other_global = "test\n\00abc";
30
31void putstest()
32{
33 fputs(s: my_other_global, stderr);
34}
35
36#endif // PART == 1
37
38// CHECK-NOT: ERROR: AddressSanitizer: odr-violation
39// CHECK: Done.
40

source code of compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp