1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
// Like the compiler, the static analyzer treats some functions differently if
// they come from a system header -- for example, it is assumed that system
// functions do not arbitrarily free() their parameters, and that some bugs
// found in system headers cannot be fixed by the user and should be
// suppressed.
#pragma clang system_header
typedef unsigned char uint8_t;
namespace std {
template <class T1, class T2>
struct pair {
T1 first;
T2 second;
pair() : first(), second() {}
pair(const T1 &a, const T2 &b) : first(a), second(b) {}
template<class U1, class U2>
pair(const pair<U1, U2> &other) : first(other.first), second(other.second) {}
};
typedef __typeof__(sizeof(int)) size_t;
template<typename T>
class vector {
T *_start;
T *_finish;
T *_end_of_storage;
public:
vector() : _start(0), _finish(0), _end_of_storage(0) {}
~vector();
size_t size() const {
return size_t(_finish - _start);
}
void push_back();
T pop_back();
T &operator[](size_t n) {
return _start[n];
}
const T &operator[](size_t n) const {
return _start[n];
}
T *begin() { return _start; }
const T *begin() const { return _start; }
T *end() { return _finish; }
const T *end() const { return _finish; }
};
class exception {
public:
exception() throw();
virtual ~exception() throw();
virtual const char *what() const throw() {
return 0;
}
};
class bad_alloc : public exception {
public:
bad_alloc() throw();
bad_alloc(const bad_alloc&) throw();
bad_alloc& operator=(const bad_alloc&) throw();
virtual const char* what() const throw() {
return 0;
}
};
struct nothrow_t {};
extern const nothrow_t nothrow;
// libc++'s implementation
template <class _E>
class initializer_list
{
const _E* __begin_;
size_t __size_;
initializer_list(const _E* __b, size_t __s)
: __begin_(__b),
__size_(__s)
{}
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
initializer_list() : __begin_(0), __size_(0) {}
size_t size() const {return __size_;}
const _E* begin() const {return __begin_;}
const _E* end() const {return __begin_ + __size_;}
};
template<class InputIter, class OutputIter>
OutputIter copy(InputIter II, InputIter IE, OutputIter OI) {
while (II != IE)
*OI++ = *II++;
return OI;
}
struct input_iterator_tag { };
struct output_iterator_tag { };
struct forward_iterator_tag : public input_iterator_tag { };
struct bidirectional_iterator_tag : public forward_iterator_tag { };
struct random_access_iterator_tag : public bidirectional_iterator_tag { };
template <class _Tp>
class allocator {
public:
void deallocate(void *p) {
::delete p;
}
};
template <class _Alloc>
class allocator_traits {
public:
static void deallocate(void *p) {
_Alloc().deallocate(p);
}
};
template <class _Tp, class _Alloc>
class __list_imp
{};
template <class _Tp, class _Alloc = allocator<_Tp> >
class list
: private __list_imp<_Tp, _Alloc>
{
public:
void pop_front() {
// Fake use-after-free.
// No warning is expected as we are suppressing warning comming
// out of std::list.
int z = 0;
z = 5/z;
}
bool empty() const;
};
// basic_string
template<class _CharT, class _Alloc = allocator<_CharT> >
class __attribute__ ((__type_visibility__("default"))) basic_string {
_CharT localStorage[4];
typedef allocator_traits<_Alloc> __alloc_traits;
public:
void push_back(int c) {
// Fake error trigger.
// No warning is expected as we are suppressing warning comming
// out of std::basic_string.
int z = 0;
z = 5/z;
}
basic_string &operator +=(int c) {
// Fake deallocate stack-based storage.
// No warning is expected as we are suppressing warnings within
// allocators being used by std::basic_string.
__alloc_traits::deallocate(&localStorage);
}
};
}
void* operator new(std::size_t, const std::nothrow_t&) throw();
void* operator new[](std::size_t, const std::nothrow_t&) throw();
void operator delete(void*, const std::nothrow_t&) throw();
void operator delete[](void*, const std::nothrow_t&) throw();
void* operator new (std::size_t size, void* ptr) throw() { return ptr; };
void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
void operator delete (void* ptr, void*) throw() {};
void operator delete[] (void* ptr, void*) throw() {};
|