[ASan] init-order checker tests: move constexpr test that requires -std=c++11 to a separate test case. Check that structs with no ctor but non-trivial dtor are ignored.

llvm-svn: 178857
This commit is contained in:
Alexey Samsonov 2013-04-05 07:51:49 +00:00
parent cb9efbe6d7
commit 5afe6aa141
4 changed files with 62 additions and 36 deletions

View File

@ -0,0 +1,3 @@
// Constexpr:
int getCoolestInteger();
static int coolest_integer = getCoolestInteger();

View File

@ -4,6 +4,6 @@ static int ab = getAB();
// Function local statics: // Function local statics:
int countCalls(); int countCalls();
static int one = countCalls(); static int one = countCalls();
// Constexpr: // Trivial constructor, non-trivial destructor:
int getCoolestInteger(); int getStructWithDtorValue();
static int coolest_integer = getCoolestInteger(); static int val = getStructWithDtorValue();

View File

@ -0,0 +1,43 @@
// Constexpr:
// We need to check that a global variable initialized with a constexpr
// constructor can be accessed during dynamic initialization (as a constexpr
// constructor implies that it was initialized during constant initialization,
// not dynamic initialization).
// RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
class Integer {
private:
int value;
public:
constexpr Integer(int x = 0) : value(x) {}
int getValue() {return value;}
};
Integer coolestInteger(42);
int getCoolestInteger() { return coolestInteger.getValue(); }
int main() { return 0; }

View File

@ -1,32 +1,21 @@
// A collection of various initializers which shouldn't trip up initialization // A collection of various initializers which shouldn't trip up initialization
// order checking. If successful, this will just return 0. // order checking. If successful, this will just return 0.
// RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O1 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m64 -O1 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O2 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m64 -O2 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m64 -O3 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m64 -O3 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m32 -O1 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O1 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m32 -O2 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O2 %s %p/Helpers/initialization-nobug-extra.cc\ // RUN: %clangxx_asan -m32 -O3 %s %p/Helpers/initialization-nobug-extra.cc -fsanitize=init-order -o %t
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// RUN: %clangxx_asan -m32 -O3 %s %p/Helpers/initialization-nobug-extra.cc\
// RUN: --std=c++11 -fsanitize=init-order -o %t
// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
// Simple access: // Simple access:
@ -56,21 +45,12 @@ int countCalls() {
return ++calls; return ++calls;
} }
// Constexpr: // Trivial constructor, non-trivial destructor.
// We need to check that a global variable initialized with a constexpr struct StructWithDtor {
// constructor can be accessed during dynamic initialization (as a constexpr ~StructWithDtor() { }
// constructor implies that it was initialized during constant initialization,
// not dynamic initialization).
class Integer {
private:
int value; int value;
public:
constexpr Integer(int x = 0) : value(x) {}
int getValue() {return value;}
}; };
Integer coolestInteger(42); StructWithDtor struct_with_dtor;
int getCoolestInteger() { return coolestInteger.getValue(); } int getStructWithDtorValue() { return struct_with_dtor.value; }
int main() { return 0; } int main() { return 0; }