1 | // RUN: %clang_cl_nocxx_asan %Gw %Od %s %Fe%t.exe |
2 | // RUN: %env_asan_opts=report_globals=2 %t.exe 2>&1 | FileCheck %s --check-prefix=NOSTRIP |
3 | // RUN: %clang_cl_nocxx_asan %Gw -O2 %s %Fe%t.exe \ |
4 | // RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections %} \ |
5 | // RUN: %else %{ -link -opt:ref %} |
6 | // RUN: %env_asan_opts=report_globals=2 %t.exe 2>&1 | FileCheck %s --check-prefix=STRIP |
7 | |
8 | #include <stdio.h> |
9 | int dead_global = 42; |
10 | int live_global = 0; |
11 | int main() { |
12 | puts(s: "main" ); |
13 | return live_global; |
14 | } |
15 | |
16 | // Check that our global registration scheme works with MSVC's linker dead |
17 | // stripping (/OPT:REF). |
18 | |
19 | // NOSTRIP: Added Global{{.*}}name=dead_global |
20 | // NOSTRIP: Added Global{{.*}}name=live_global |
21 | // NOSTRIP: main |
22 | |
23 | // STRIP-NOT: Added Global{{.*}}name=dead_global |
24 | // STRIP: Added Global{{.*}}name=live_global |
25 | // STRIP: main |
26 | |