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 namespace std {
      9   template <class T1, class T2>
     10   struct pair {
     11     T1 first;
     12     T2 second;
     13 
     14     pair() : first(), second() {}
     15     pair(const T1 &a, const T2 &b) : first(a), second(b) {}
     16 
     17     template<class U1, class U2>
     18     pair(const pair<U1, U2> &other) : first(other.first), second(other.second) {}
     19   };
     20 
     21   typedef __typeof__(sizeof(int)) size_t;
     22 
     23   template<typename T>
     24   class vector {
     25     T *_start;
     26     T *_finish;
     27     T *_end_of_storage;
     28   public:
     29     vector() : _start(0), _finish(0), _end_of_storage(0) {}
     30     ~vector();
     31 
     32     size_t size() const {
     33       return size_t(_finish - _start);
     34     }
     35 
     36     void push_back();
     37     T pop_back();
     38 
     39     T &operator[](size_t n) {
     40       return _start[n];
     41     }
     42 
     43     const T &operator[](size_t n) const {
     44       return _start[n];
     45     }
     46 
     47     T *begin() { return _start; }
     48     const T *begin() const { return _start; }
     49 
     50     T *end() { return _finish; }
     51     const T *end() const { return _finish; }
     52   };
     53 
     54   class exception {
     55   public:
     56     exception() throw();
     57     virtual ~exception() throw();
     58     virtual const char *what() const throw() {
     59       return 0;
     60     }
     61   };
     62 
     63   class bad_alloc : public exception {
     64     public:
     65     bad_alloc() throw();
     66     bad_alloc(const bad_alloc&) throw();
     67     bad_alloc& operator=(const bad_alloc&) throw();
     68     virtual const char* what() const throw() {
     69       return 0;
     70     }
     71   };
     72 
     73   struct nothrow_t {};
     74 
     75   extern const nothrow_t nothrow;
     76 
     77   // libc++'s implementation
     78   template <class _E>
     79   class initializer_list
     80   {
     81     const _E* __begin_;
     82     size_t    __size_;
     83 
     84     initializer_list(const _E* __b, size_t __s)
     85       : __begin_(__b),
     86         __size_(__s)
     87     {}
     88 
     89   public:
     90     typedef _E        value_type;
     91     typedef const _E& reference;
     92     typedef const _E& const_reference;
     93     typedef size_t    size_type;
     94 
     95     typedef const _E* iterator;
     96     typedef const _E* const_iterator;
     97 
     98     initializer_list() : __begin_(0), __size_(0) {}
     99 
    100     size_t    size()  const {return __size_;}
    101     const _E* begin() const {return __begin_;}
    102     const _E* end()   const {return __begin_ + __size_;}
    103   };
    104 
    105   template<class InputIter, class OutputIter>
    106   OutputIter copy(InputIter II, InputIter IE, OutputIter OI) {
    107     while (II != IE)
    108       *OI++ = *II++;
    109     return OI;
    110   }
    111 
    112   struct input_iterator_tag { };
    113   struct output_iterator_tag { };
    114   struct forward_iterator_tag : public input_iterator_tag { };
    115   struct bidirectional_iterator_tag : public forward_iterator_tag { };
    116   struct random_access_iterator_tag : public bidirectional_iterator_tag { };
    117 
    118   template <class _Tp>
    119   class allocator {};
    120 
    121   template <class _Tp, class _Alloc>
    122   class __list_imp
    123   {};
    124 
    125   template <class _Tp, class _Alloc = allocator<_Tp> >
    126   class list
    127   : private __list_imp<_Tp, _Alloc>
    128   {
    129   public:
    130     void pop_front() {
    131       // Fake use-after-free.
    132       // No warning is expected as we are suppressing warning comming
    133       // out of std::list.
    134       int z = 0;
    135       z = 5/z;
    136     }
    137     bool empty() const;
    138   };
    139 
    140 }
    141 
    142 void* operator new(std::size_t, const std::nothrow_t&) throw();
    143 void* operator new[](std::size_t, const std::nothrow_t&) throw();
    144 void operator delete(void*, const std::nothrow_t&) throw();
    145 void operator delete[](void*, const std::nothrow_t&) throw();
    146 
    147 void* operator new (std::size_t size, void* ptr) throw() { return ptr; };
    148 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
    149 void operator delete (void* ptr, void*) throw() {};
    150 void operator delete[] (void* ptr, void*) throw() {};
    151