26 lines · c
1// RUN: %clang_cl_nocxx_asan %Gw %Od %s %Fe%t.exe2// RUN: %env_asan_opts=report_globals=2 %t.exe 2>&1 | FileCheck %s --check-prefix=NOSTRIP3// 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=STRIP7 8#include <stdio.h>9int dead_global = 42;10int live_global = 0;11int main() {12 puts("main");13 return live_global;14}15 16// Check that our global registration scheme works with MSVC's linker dead17// stripping (/OPT:REF).18 19// NOSTRIP: Added Global{{.*}}name=dead_global20// NOSTRIP: Added Global{{.*}}name=live_global21// NOSTRIP: main22 23// STRIP-NOT: Added Global{{.*}}name=dead_global24// STRIP: Added Global{{.*}}name=live_global25// STRIP: main26