From fd02a86260b3fb01361175af9600d53354631fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= Date: Mon, 6 Jul 2020 16:25:57 +0200 Subject: [PATCH] [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 --- .../test/Analysis/Inputs/system-header-simulator-cxx.h | 10 ++++++++++ .../test/Analysis/diagnostics/explicit-suppression.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h index fe4b9d081e9c..1dee3294d732 100644 --- a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h +++ b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h @@ -60,6 +60,11 @@ template struct __vector_iterator { __vector_iterator operator+(difference_type n) { return ptr + n; } + friend __vector_iterator operator+( + difference_type n, + const __vector_iterator &iter) { + return n + iter.ptr; + } __vector_iterator operator-(difference_type n) { return ptr - n; } @@ -118,6 +123,11 @@ template struct __deque_iterator { __deque_iterator operator+(difference_type n) { return ptr + n; } + friend __deque_iterator operator+( + difference_type n, + const __deque_iterator &iter) { + return n + iter.ptr; + } __deque_iterator operator-(difference_type n) { return ptr - n; } diff --git a/clang/test/Analysis/diagnostics/explicit-suppression.cpp b/clang/test/Analysis/diagnostics/explicit-suppression.cpp index 2b586add19ee..0ef01771e58b 100644 --- a/clang/test/Analysis/diagnostics/explicit-suppression.cpp +++ b/clang/test/Analysis/diagnostics/explicit-suppression.cpp @@ -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 }