Add modules for asan, msan, tsan and ubsan
This commit is contained in:

committed by
Matt Arsenault

parent
1121b004db
commit
42eac1f7af
12
test_project/CMakeLists.txt
Normal file
12
test_project/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
|
||||
include(FindUBSan)
|
||||
include(FindTSan)
|
||||
include(FindASan)
|
||||
include(FindMSan)
|
||||
|
||||
add_executable(test test.cpp)
|
48
test_project/test.cpp
Normal file
48
test_project/test.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
class BarB
|
||||
{
|
||||
public:
|
||||
float y;
|
||||
/* Include something that uses a virtual function. The symbols
|
||||
that are broken on current OS X libc++ involve this */
|
||||
virtual int arst(int o)
|
||||
{
|
||||
return 4 + o;
|
||||
}
|
||||
};
|
||||
|
||||
static void print_array(const int* a)
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
std::cout << a[i] << ", ";
|
||||
}
|
||||
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
/* Just include something that ubsan will need to check */
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
BarB* b = new BarB();
|
||||
if (argc > 1)
|
||||
{
|
||||
int uninitialized[4];
|
||||
//int* uninitialized = new int[4];
|
||||
print_array(uninitialized);
|
||||
//delete[] uninitialized;
|
||||
|
||||
int x = atoi(argv[1]);
|
||||
std::cout << (4 / x) << '\n';
|
||||
|
||||
fputs(argv[x], stdout);
|
||||
std::cout << b->arst(x) << '\n';
|
||||
}
|
||||
|
||||
delete b;
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user