Files
clang-p2996/compiler-rt/test/asan/TestCases/initialization-nobug.cc
Reid Kleckner 85220d0218 Use %env_asan_opts= substitution instead of 'env ASAN_OPTIONS=$ASAN_OPTIONS'
Summary:
The lit internal shell is used by default on Windows, and it does not
support bash variable expansion. Because bash variable expansion
interacts with tokenization, it is prohibitively difficult to make the
existing lit shell do general shell variable expansion.

The most common use of shell variables in the asan tests is to add
options to the default set of options set by lit.cfg. We can avoid the
need for variable expansion with a substitution that expands to 'env
ASAN_OPTIONS=<defaults:>'.

This has the side benefit of shortening the RUN lines, so it seemed
better than implementing limited variable expansion in lit.

Reviewers: samsonov, filcab

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11982

llvm-svn: 244839
2015-08-12 23:50:12 +00:00

49 lines
1.5 KiB
C++

// A collection of various initializers which shouldn't trip up initialization
// order checking. If successful, this will just return 0.
// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cc -o %t
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cc -o %t
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cc -o %t
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cc -o %t
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
// Simple access:
// Make sure that accessing a global in the same TU is safe
bool condition = true;
int initializeSameTU() {
return condition ? 0x2a : 052;
}
int sameTU = initializeSameTU();
// Linker initialized:
// Check that access to linker initialized globals originating from a different
// TU's initializer is safe.
int A = (1 << 1) + (1 << 3) + (1 << 5), B;
int getAB() {
return A * B;
}
// Function local statics:
// Check that access to function local statics originating from a different
// TU's initializer is safe.
int countCalls() {
static int calls;
return ++calls;
}
// Trivial constructor, non-trivial destructor.
struct StructWithDtor {
~StructWithDtor() { }
int value;
};
StructWithDtor struct_with_dtor;
int getStructWithDtorValue() { return struct_with_dtor.value; }
int main() { return 0; }