1 // Like the compiler, the static analyzer treats some functions differently if
2 // they come from a system header -- for example, it is assumed that system
3 // functions do not arbitrarily free() their parameters, and that some bugs
4 // found in system headers cannot be fixed by the user and should be
6 #pragma clang system_header
8 typedef unsigned char uint8_t;
10 typedef __typeof__(sizeof(int)) size_t;
11 void *memmove(void *s1, const void *s2, size_t n);
13 template <typename T, typename Ptr, typename Ref> struct __iterator {
14 typedef __iterator<T, T *, T &> iterator;
15 typedef __iterator<T, const T *, const T &> const_iterator;
17 __iterator(const Ptr p) : ptr(p) {}
19 __iterator<T, Ptr, Ref> operator++() { return *this; }
20 __iterator<T, Ptr, Ref> operator++(int) { return *this; }
21 __iterator<T, Ptr, Ref> operator--() { return *this; }
22 __iterator<T, Ptr, Ref> operator--(int) { return *this; }
23 Ref operator*() const { return *ptr; }
24 Ptr operator->() const { return *ptr; }
26 bool operator==(const iterator &rhs) const { return ptr == rhs.ptr; }
27 bool operator==(const const_iterator &rhs) const { return ptr == rhs.ptr; }
29 bool operator!=(const iterator &rhs) const { return ptr != rhs.ptr; }
30 bool operator!=(const const_iterator &rhs) const { return ptr != rhs.ptr; }
37 template <class T1, class T2>
42 pair() : first(), second() {}
43 pair(const T1 &a, const T2 &b) : first(a), second(b) {}
45 template<class U1, class U2>
46 pair(const pair<U1, U2> &other) : first(other.first), second(other.second) {}
49 typedef __typeof__(sizeof(int)) size_t;
53 typedef __iterator<T, T *, T &> iterator;
54 typedef __iterator<T, const T *, const T &> const_iterator;
60 vector() : _start(0), _finish(0), _end_of_storage(0) {}
64 return size_t(_finish - _start);
70 T &operator[](size_t n) {
74 const T &operator[](size_t n) const {
78 iterator begin() { return iterator(_start); }
79 const_iterator begin() const { return const_iterator(_start); }
80 iterator end() { return iterator(_finish); }
81 const_iterator end() const { return const_iterator(_finish); }
87 virtual ~exception() throw();
88 virtual const char *what() const throw() {
93 class bad_alloc : public exception {
96 bad_alloc(const bad_alloc&) throw();
97 bad_alloc& operator=(const bad_alloc&) throw();
98 virtual const char* what() const throw() {
105 extern const nothrow_t nothrow;
107 // libc++'s implementation
109 class initializer_list
114 initializer_list(const _E* __b, size_t __s)
120 typedef _E value_type;
121 typedef const _E& reference;
122 typedef const _E& const_reference;
123 typedef size_t size_type;
125 typedef const _E* iterator;
126 typedef const _E* const_iterator;
128 initializer_list() : __begin_(0), __size_(0) {}
130 size_t size() const {return __size_;}
131 const _E* begin() const {return __begin_;}
132 const _E* end() const {return __begin_ + __size_;}
135 template <bool, class _Tp = void> struct enable_if {};
136 template <class _Tp> struct enable_if<true, _Tp> {typedef _Tp type;};
138 template <class _Tp, _Tp __v>
139 struct integral_constant
141 static const _Tp value = __v;
142 typedef _Tp value_type;
143 typedef integral_constant type;
145 operator value_type() const {return value;}
147 value_type operator ()() const {return value;}
150 template <class _Tp, _Tp __v>
151 const _Tp integral_constant<_Tp, __v>::value;
153 template <class _Tp, class _Arg>
154 struct is_trivially_assignable
155 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
159 typedef integral_constant<bool,true> true_type;
160 typedef integral_constant<bool,false> false_type;
162 template <class _Tp> struct is_const : public false_type {};
163 template <class _Tp> struct is_const<_Tp const> : public true_type {};
165 template <class _Tp> struct is_reference : public false_type {};
166 template <class _Tp> struct is_reference<_Tp&> : public true_type {};
168 template <class _Tp, class _Up> struct is_same : public false_type {};
169 template <class _Tp> struct is_same<_Tp, _Tp> : public true_type {};
171 template <class _Tp, bool = is_const<_Tp>::value || is_reference<_Tp>::value >
172 struct __add_const {typedef _Tp type;};
175 struct __add_const<_Tp, false> {typedef const _Tp type;};
177 template <class _Tp> struct add_const {typedef typename __add_const<_Tp>::type type;};
179 template <class _Tp> struct remove_const {typedef _Tp type;};
180 template <class _Tp> struct remove_const<const _Tp> {typedef _Tp type;};
182 template <class _Tp> struct add_lvalue_reference {typedef _Tp& type;};
184 template <class _Tp> struct is_trivially_copy_assignable
185 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
186 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
188 template<class InputIter, class OutputIter>
189 OutputIter __copy(InputIter II, InputIter IE, OutputIter OI) {
196 template <class _Tp, class _Up>
200 is_same<typename remove_const<_Tp>::type, _Up>::value &&
201 is_trivially_copy_assignable<_Up>::value,
203 >::type __copy(_Tp* __first, _Tp* __last, _Up* __result) {
204 size_t __n = __last - __first;
207 memmove(__result, __first, __n * sizeof(_Up));
209 return __result + __n;
212 template<class InputIter, class OutputIter>
213 OutputIter copy(InputIter II, InputIter IE, OutputIter OI) {
214 return __copy(II, IE, OI);
217 template <class _BidirectionalIterator, class _OutputIterator>
220 __copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last,
221 _OutputIterator __result)
223 while (__first != __last)
224 *--__result = *--__last;
228 template <class _Tp, class _Up>
232 is_same<typename remove_const<_Tp>::type, _Up>::value &&
233 is_trivially_copy_assignable<_Up>::value,
235 >::type __copy_backward(_Tp* __first, _Tp* __last, _Up* __result) {
236 size_t __n = __last - __first;
241 memmove(__result, __first, __n * sizeof(_Up));
246 template<class InputIter, class OutputIter>
247 OutputIter copy_backward(InputIter II, InputIter IE, OutputIter OI) {
248 return __copy_backward(II, IE, OI);
251 template <class InputIterator, class T>
252 InputIterator find(InputIterator first, InputIterator last, const T &val);
253 template <class ForwardIterator1, class ForwardIterator2>
254 ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
255 ForwardIterator2 first2, ForwardIterator2 last2);
256 template <class ForwardIterator1, class ForwardIterator2>
257 ForwardIterator1 find_first_of(ForwardIterator1 first1,
258 ForwardIterator1 last1,
259 ForwardIterator2 first2,
260 ForwardIterator2 last2);
261 template <class InputIterator, class UnaryPredicate>
262 InputIterator find_if(InputIterator first, InputIterator last,
263 UnaryPredicate pred);
264 template <class InputIterator, class UnaryPredicate>
265 InputIterator find_if_not(InputIterator first, InputIterator last,
266 UnaryPredicate pred);
267 template <class InputIterator, class T>
268 InputIterator lower_bound(InputIterator first, InputIterator last,
270 template <class InputIterator, class T>
271 InputIterator upper_bound(InputIterator first, InputIterator last,
273 template <class ForwardIterator1, class ForwardIterator2>
274 ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1,
275 ForwardIterator2 first2, ForwardIterator2 last2);
276 template <class ForwardIterator1, class ForwardIterator2>
277 ForwardIterator1 search_n(ForwardIterator1 first1, ForwardIterator1 last1,
278 ForwardIterator2 first2, ForwardIterator2 last2);
280 struct input_iterator_tag { };
281 struct output_iterator_tag { };
282 struct forward_iterator_tag : public input_iterator_tag { };
283 struct bidirectional_iterator_tag : public forward_iterator_tag { };
284 struct random_access_iterator_tag : public bidirectional_iterator_tag { };
288 void* operator new(std::size_t, const std::nothrow_t&) throw();
289 void* operator new[](std::size_t, const std::nothrow_t&) throw();
290 void operator delete(void*, const std::nothrow_t&) throw();
291 void operator delete[](void*, const std::nothrow_t&) throw();
293 void* operator new (std::size_t size, void* ptr) throw() { return ptr; };
294 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
295 void operator delete (void* ptr, void*) throw() {};
296 void operator delete[] (void* ptr, void*) throw() {};
298 namespace __cxxabiv1 {
300 extern char *__cxa_demangle(const char *mangled_name,
305 namespace abi = __cxxabiv1;