[PATCH] D83226: [analyzer] Add system header simulator a symmetric random access iterator operator+
Endre Fülöp via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 12:54:04 PDT 2020
gamesh411 created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, steakhal, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
Random access iterators must handle operator+, where the iterator is on the
RHS. The system header simulator library is extended with these operators.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83226
Files:
clang/test/Analysis/Inputs/system-header-simulator-cxx.h
clang/test/Analysis/diagnostics/explicit-suppression.cpp
Index: clang/test/Analysis/diagnostics/explicit-suppression.cpp
===================================================================
--- clang/test/Analysis/diagnostics/explicit-suppression.cpp
+++ clang/test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
void testCopyNull(C *I, C *E) {
std::copy(I, E, (C *)0);
#ifndef SUPPRESSED
- // expected-warning at ../Inputs/system-header-simulator-cxx.h:699 {{Called C++ object pointer is null}}
+ // expected-warning at ../Inputs/system-header-simulator-cxx.h:709 {{Called C++ object pointer is null}}
#endif
}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===================================================================
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -60,6 +60,11 @@
__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 @@
__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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83226.275703.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200706/1f9910f3/attachment-0001.bin>
More information about the cfe-commits
mailing list