[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / initialization-nobug.cpp
blobf66d501124bc48b8f168e51986c9e471e1e14c01
1 // A collection of various initializers which shouldn't trip up initialization
2 // order checking. If successful, this will just return 0.
4 // RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInitPoison"
5 // RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInitPoison"
6 // RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInitPoison"
7 // RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInitPoison"
9 // Simple access:
10 // Make sure that accessing a global in the same TU is safe
12 bool condition = true;
13 __attribute__((noinline, weak)) int initializeSameTU() {
14 return condition ? 0x2a : 052;
16 int sameTU = initializeSameTU();
18 // Linker initialized:
19 // Check that access to linker initialized globals originating from a different
20 // TU's initializer is safe.
22 int A = (1 << 1) + (1 << 3) + (1 << 5), B;
23 int getAB() {
24 return A * B;
27 // Function local statics:
28 // Check that access to function local statics originating from a different
29 // TU's initializer is safe.
31 int countCalls() {
32 static int calls;
33 return ++calls;
36 // Trivial constructor, non-trivial destructor.
37 struct StructWithDtor {
38 ~StructWithDtor() { }
39 int value;
41 StructWithDtor struct_with_dtor;
42 int getStructWithDtorValue() { return struct_with_dtor.value; }
44 int main() { return 0; }
46 // CHECK: DynInitPoison
47 // CHECK: DynInitPoison
49 // In general case entire set of DynInitPoison must be followed by at lest one
50 // DynInitUnpoison. In some cases we can limit the number of DynInitUnpoison,
51 // see initialization-nobug-lld.cpp.
53 // CHECK: DynInitUnpoison