forked from OSchip/llvm-project
[analyzer] Add system header simulator a symmetric random access iterator operator+
Summary: Random access iterators must handle operator+, where the iterator is on the RHS. The system header simulator library is extended with these operators. Reviewers: Szelethus Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, martong, ASDenysPetrov, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83226
This commit is contained in:
parent
23c9534515
commit
fd02a86260
|
@ -60,6 +60,11 @@ template <typename T, typename Ptr, typename Ref> struct __vector_iterator {
|
|||
__vector_iterator<T, Ptr, Ref> operator+(difference_type n) {
|
||||
return ptr + n;
|
||||
}
|
||||
friend __vector_iterator<T, Ptr, Ref> operator+(
|
||||
difference_type n,
|
||||
const __vector_iterator<T, Ptr, Ref> &iter) {
|
||||
return n + iter.ptr;
|
||||
}
|
||||
__vector_iterator<T, Ptr, Ref> operator-(difference_type n) {
|
||||
return ptr - n;
|
||||
}
|
||||
|
@ -118,6 +123,11 @@ template <typename T, typename Ptr, typename Ref> struct __deque_iterator {
|
|||
__deque_iterator<T, Ptr, Ref> operator+(difference_type n) {
|
||||
return ptr + n;
|
||||
}
|
||||
friend __deque_iterator<T, Ptr, Ref> operator+(
|
||||
difference_type n,
|
||||
const __deque_iterator<T, Ptr, Ref> &iter) {
|
||||
return n + iter.ptr;
|
||||
}
|
||||
__deque_iterator<T, Ptr, Ref> operator-(difference_type n) {
|
||||
return ptr - n;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ class C {
|
|||
void testCopyNull(C *I, C *E) {
|
||||
std::copy(I, E, (C *)0);
|
||||
#ifndef SUPPRESSED
|
||||
// expected-warning@../Inputs/system-header-simulator-cxx.h:699 {{Called C++ object pointer is null}}
|
||||
// expected-warning@../Inputs/system-header-simulator-cxx.h:709 {{Called C++ object pointer is null}}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue