summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
diff options
context:
space:
mode:
authorHenry Wong <movietravelcode@outlook.com>2018-03-20 09:27:02 +0000
committerHenry Wong <movietravelcode@outlook.com>2018-03-20 09:27:02 +0000
commit167b1f1859885d01c4bb71f63e56405b3321ab45 (patch)
tree509bdb84daae9a750fe326c7c5270a5dc0cf3613 /lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
parent73fed20ccfe3c439d8568756463c79a032e7c9e0 (diff)
downloadclang-167b1f1859885d01c4bb71f63e56405b3321ab45.tar.gz
[analyzer] Fix the crash in IteratorChecker.cpp when 'SymbolConjured' has a null Stmt.
When the loop has a null terminator statement and sets 'widen-loops=true', 'invalidateRegions' will constructs the 'SymbolConjured' with null 'Stmt'. And this will lead to a crash in 'IteratorChecker.cpp'. This patch use 'dyn_cast_or_null<>' instead of 'dyn_cast<>' in IteratorChecker.cpp. Differential Revision: https://reviews.llvm.org/D44606 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/IteratorChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/IteratorChecker.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp b/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
index 11f42229f5..29d48ef1c5 100644
--- a/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -604,7 +604,7 @@ BinaryOperator::Opcode getOpcode(const SymExpr *SE) {
if (const auto *BSE = dyn_cast<BinarySymExpr>(SE)) {
return BSE->getOpcode();
} else if (const auto *SC = dyn_cast<SymbolConjured>(SE)) {
- const auto *COE = dyn_cast<CXXOperatorCallExpr>(SC->getStmt());
+ const auto *COE = dyn_cast_or_null<CXXOperatorCallExpr>(SC->getStmt());
if (!COE)
return BO_Comma; // Extremal value, neither EQ nor NE
if (COE->getOperator() == OO_EqualEqual) {