[llvm-branch-commits] [cfe-branch] r368427 - Merging r367802:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 9 03:19:34 PDT 2019
Author: hans
Date: Fri Aug 9 03:19:34 2019
New Revision: 368427
URL: http://llvm.org/viewvc/llvm-project?rev=368427&view=rev
Log:
Merging r367802:
------------------------------------------------------------------------
r367802 | baloghadamsoftware | 2019-08-05 08:45:41 +0200 (Mon, 05 Aug 2019) | 6 lines
[Analyzer] Iterator Checkers - Fix for Crash on Iterator Differences
Iterators differences were mistakenly handled as random decrements which
causes an assertion. This patch fixes this.
------------------------------------------------------------------------
Modified:
cfe/branches/release_90/ (props changed)
cfe/branches/release_90/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/branches/release_90/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/branches/release_90/test/Analysis/diagnostics/explicit-suppression.cpp
cfe/branches/release_90/test/Analysis/iterator-range.cpp
Propchange: cfe/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 9 03:19:34 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367823,367906,368104,368202
+/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367802,367823,367906,368104,368202
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_90/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=368427&r1=368426&r2=368427&view=diff
==============================================================================
--- cfe/branches/release_90/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/branches/release_90/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Fri Aug 9 03:19:34 2019
@@ -406,13 +406,15 @@ void IteratorChecker::checkPreCall(const
} else if (isRandomIncrOrDecrOperator(Func->getOverloadedOperator())) {
if (const auto *InstCall = dyn_cast<CXXInstanceCall>(&Call)) {
// Check for out-of-range incrementions and decrementions
- if (Call.getNumArgs() >= 1) {
+ if (Call.getNumArgs() >= 1 &&
+ Call.getArgExpr(0)->getType()->isIntegralOrEnumerationType()) {
verifyRandomIncrOrDecr(C, Func->getOverloadedOperator(),
InstCall->getCXXThisVal(),
Call.getArgSVal(0));
}
} else {
- if (Call.getNumArgs() >= 2) {
+ if (Call.getNumArgs() >= 2 &&
+ Call.getArgExpr(1)->getType()->isIntegralOrEnumerationType()) {
verifyRandomIncrOrDecr(C, Func->getOverloadedOperator(),
Call.getArgSVal(0), Call.getArgSVal(1));
}
@@ -590,14 +592,16 @@ void IteratorChecker::checkPostCall(cons
return;
} else if (isRandomIncrOrDecrOperator(Func->getOverloadedOperator())) {
if (const auto *InstCall = dyn_cast<CXXInstanceCall>(&Call)) {
- if (Call.getNumArgs() >= 1) {
+ if (Call.getNumArgs() >= 1 &&
+ Call.getArgExpr(0)->getType()->isIntegralOrEnumerationType()) {
handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
Call.getReturnValue(),
InstCall->getCXXThisVal(), Call.getArgSVal(0));
return;
}
} else {
- if (Call.getNumArgs() >= 2) {
+ if (Call.getNumArgs() >= 2 &&
+ Call.getArgExpr(1)->getType()->isIntegralOrEnumerationType()) {
handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
Call.getReturnValue(), Call.getArgSVal(0),
Call.getArgSVal(1));
Modified: cfe/branches/release_90/test/Analysis/Inputs/system-header-simulator-cxx.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Analysis/Inputs/system-header-simulator-cxx.h?rev=368427&r1=368426&r2=368427&view=diff
==============================================================================
--- cfe/branches/release_90/test/Analysis/Inputs/system-header-simulator-cxx.h (original)
+++ cfe/branches/release_90/test/Analysis/Inputs/system-header-simulator-cxx.h Fri Aug 9 03:19:34 2019
@@ -70,6 +70,9 @@ template <typename T, typename Ptr, type
return ptr -= n;
}
+ template<typename U, typename Ptr2, typename Ref2>
+ difference_type operator-(const __vector_iterator<U, Ptr2, Ref2> &rhs);
+
Ref operator*() const { return *ptr; }
Ptr operator->() const { return *ptr; }
Modified: cfe/branches/release_90/test/Analysis/diagnostics/explicit-suppression.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Analysis/diagnostics/explicit-suppression.cpp?rev=368427&r1=368426&r2=368427&view=diff
==============================================================================
--- cfe/branches/release_90/test/Analysis/diagnostics/explicit-suppression.cpp (original)
+++ cfe/branches/release_90/test/Analysis/diagnostics/explicit-suppression.cpp Fri Aug 9 03:19:34 2019
@@ -19,6 +19,6 @@ class C {
void testCopyNull(C *I, C *E) {
std::copy(I, E, (C *)0);
#ifndef SUPPRESSED
- // expected-warning at ../Inputs/system-header-simulator-cxx.h:677 {{Called C++ object pointer is null}}
+ // expected-warning at ../Inputs/system-header-simulator-cxx.h:680 {{Called C++ object pointer is null}}
#endif
}
Modified: cfe/branches/release_90/test/Analysis/iterator-range.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Analysis/iterator-range.cpp?rev=368427&r1=368426&r2=368427&view=diff
==============================================================================
--- cfe/branches/release_90/test/Analysis/iterator-range.cpp (original)
+++ cfe/branches/release_90/test/Analysis/iterator-range.cpp Fri Aug 9 03:19:34 2019
@@ -236,3 +236,8 @@ void good_derived(simple_container c) {
*i0; // no-warning
}
}
+
+void iter_diff(std::vector<int> &V) {
+ auto i0 = V.begin(), i1 = V.end();
+ ptrdiff_t len = i1 - i0; // no-crash
+}
More information about the llvm-branch-commits
mailing list