Home | History | Annotate | Download | only in Inputs
      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
      5 // suppressed.
      6 #pragma clang system_header
      7 
      8 typedef unsigned char uint8_t;
      9 
     10 typedef __typeof__(sizeof(int)) size_t;
     11 void *memmove(void *s1, const void *s2, size_t n);
     12 
     13 namespace std {
     14   template <class T1, class T2>
     15   struct pair {
     16     T1 first;
     17     T2 second;
     18 
     19     pair() : first(), second() {}
     20     pair(const T1 &a, const T2 &b) : first(a), second(b) {}
     21 
     22     template<class U1, class U2>
     23     pair(const pair<U1, U2> &other) : first(other.first), second(other.second) {}
     24   };
     25 
     26   typedef __typeof__(sizeof(int)) size_t;
     27 
     28   template<typename T>
     29   class vector {
     30     T *_start;
     31     T *_finish;
     32     T *_end_of_storage;
     33   public:
     34     vector() : _start(0), _finish(0), _end_of_storage(0) {}
     35     ~vector();
     36 
     37     size_t size() const {
     38       return size_t(_finish - _start);
     39     }
     40 
     41     void push_back();
     42     T pop_back();
     43 
     44     T &operator[](size_t n) {
     45       return _start[n];
     46     }
     47 
     48     const T &operator[](size_t n) const {
     49       return _start[n];
     50     }
     51 
     52     T *begin() { return _start; }
     53     const T *begin() const { return _start; }
     54 
     55     T *end() { return _finish; }
     56     const T *end() const { return _finish; }
     57   };
     58 
     59   class exception {
     60   public:
     61     exception() throw();
     62     virtual ~exception() throw();
     63     virtual const char *what() const throw() {
     64       return 0;
     65     }
     66   };
     67 
     68   class bad_alloc : public exception {
     69     public:
     70     bad_alloc() throw();
     71     bad_alloc(const bad_alloc&) throw();
     72     bad_alloc& operator=(const bad_alloc&) throw();
     73     virtual const char* what() const throw() {
     74       return 0;
     75     }
     76   };
     77 
     78   struct nothrow_t {};
     79 
     80   extern const nothrow_t nothrow;
     81 
     82   // libc++'s implementation
     83   template <class _E>
     84   class initializer_list
     85   {
     86     const _E* __begin_;
     87     size_t    __size_;
     88 
     89     initializer_list(const _E* __b, size_t __s)
     90       : __begin_(__b),
     91         __size_(__s)
     92     {}
     93 
     94   public:
     95     typedef _E        value_type;
     96     typedef const _E& reference;
     97     typedef const _E& const_reference;
     98     typedef size_t    size_type;
     99 
    100     typedef const _E* iterator;
    101     typedef const _E* const_iterator;
    102 
    103     initializer_list() : __begin_(0), __size_(0) {}
    104 
    105     size_t    size()  const {return __size_;}
    106     const _E* begin() const {return __begin_;}
    107     const _E* end()   const {return __begin_ + __size_;}
    108   };
    109 
    110   template <bool, class _Tp = void> struct enable_if {};
    111   template <class _Tp> struct enable_if<true, _Tp> {typedef _Tp type;};
    112 
    113   template <class _Tp, _Tp __v>
    114   struct integral_constant
    115   {
    116       static const _Tp      value = __v;
    117       typedef _Tp               value_type;
    118       typedef integral_constant type;
    119 
    120      operator value_type() const {return value;}
    121 
    122      value_type operator ()() const {return value;}
    123   };
    124 
    125   template <class _Tp, _Tp __v>
    126   const _Tp integral_constant<_Tp, __v>::value;
    127 
    128     template <class _Tp, class _Arg>
    129     struct is_trivially_assignable
    130       : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
    131     {
    132     };
    133 
    134   typedef integral_constant<bool,true>  true_type;
    135   typedef integral_constant<bool,false> false_type;
    136 
    137   template <class _Tp> struct is_const            : public false_type {};
    138   template <class _Tp> struct is_const<_Tp const> : public true_type {};
    139 
    140   template <class _Tp> struct  is_reference        : public false_type {};
    141   template <class _Tp> struct  is_reference<_Tp&>  : public true_type {};
    142 
    143   template <class _Tp, class _Up> struct  is_same           : public false_type {};
    144   template <class _Tp>            struct  is_same<_Tp, _Tp> : public true_type {};
    145 
    146   template <class _Tp, bool = is_const<_Tp>::value || is_reference<_Tp>::value    >
    147   struct __add_const             {typedef _Tp type;};
    148 
    149   template <class _Tp>
    150   struct __add_const<_Tp, false> {typedef const _Tp type;};
    151 
    152   template <class _Tp> struct add_const {typedef typename __add_const<_Tp>::type type;};
    153 
    154   template <class _Tp> struct  remove_const            {typedef _Tp type;};
    155   template <class _Tp> struct  remove_const<const _Tp> {typedef _Tp type;};
    156 
    157   template <class _Tp> struct  add_lvalue_reference    {typedef _Tp& type;};
    158 
    159   template <class _Tp> struct is_trivially_copy_assignable
    160       : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
    161             typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
    162 
    163     template<class InputIter, class OutputIter>
    164     OutputIter __copy(InputIter II, InputIter IE, OutputIter OI) {
    165       while (II != IE)
    166         *OI++ = *II++;
    167 
    168       return OI;
    169     }
    170 
    171   template <class _Tp, class _Up>
    172   inline
    173   typename enable_if
    174   <
    175       is_same<typename remove_const<_Tp>::type, _Up>::value &&
    176       is_trivially_copy_assignable<_Up>::value,
    177       _Up*
    178   >::type __copy(_Tp* __first, _Tp* __last, _Up* __result) {
    179       size_t __n = __last - __first;
    180 
    181       if (__n > 0)
    182         memmove(__result, __first, __n * sizeof(_Up));
    183 
    184       return __result + __n;
    185     }
    186 
    187   template<class InputIter, class OutputIter>
    188   OutputIter copy(InputIter II, InputIter IE, OutputIter OI) {
    189     return __copy(II, IE, OI);
    190   }
    191 
    192   template <class _BidirectionalIterator, class _OutputIterator>
    193   inline
    194   _OutputIterator
    195   __copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last,
    196                   _OutputIterator __result)
    197   {
    198       while (__first != __last)
    199           *--__result = *--__last;
    200       return __result;
    201   }
    202 
    203   template <class _Tp, class _Up>
    204   inline
    205   typename enable_if
    206   <
    207       is_same<typename remove_const<_Tp>::type, _Up>::value &&
    208       is_trivially_copy_assignable<_Up>::value,
    209       _Up*
    210   >::type __copy_backward(_Tp* __first, _Tp* __last, _Up* __result) {
    211       size_t __n = __last - __first;
    212 
    213     if (__n > 0)
    214     {
    215         __result -= __n;
    216         memmove(__result, __first, __n * sizeof(_Up));
    217     }
    218     return __result;
    219   }
    220 
    221   template<class InputIter, class OutputIter>
    222   OutputIter copy_backward(InputIter II, InputIter IE, OutputIter OI) {
    223     return __copy_backward(II, IE, OI);
    224   }
    225 
    226   struct input_iterator_tag { };
    227   struct output_iterator_tag { };
    228   struct forward_iterator_tag : public input_iterator_tag { };
    229   struct bidirectional_iterator_tag : public forward_iterator_tag { };
    230   struct random_access_iterator_tag : public bidirectional_iterator_tag { };
    231 
    232 }
    233 
    234 void* operator new(std::size_t, const std::nothrow_t&) throw();
    235 void* operator new[](std::size_t, const std::nothrow_t&) throw();
    236 void operator delete(void*, const std::nothrow_t&) throw();
    237 void operator delete[](void*, const std::nothrow_t&) throw();
    238 
    239 void* operator new (std::size_t size, void* ptr) throw() { return ptr; };
    240 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
    241 void operator delete (void* ptr, void*) throw() {};
    242 void operator delete[] (void* ptr, void*) throw() {};
    243