From b459cf34c4df1a1317a9bda1e1e2cc32364e62cf Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Sat, 1 Oct 2011 06:35:19 +0000 Subject: [PATCH] Address PR10616. The crash has already been fixed by Ted in r140725, so just refactor to use existing API + test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140932 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 2 +- test/Analysis/div-zero.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/Analysis/div-zero.cpp diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 3afbd87213..da08cbd88e 100644 --- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -315,7 +315,7 @@ bugreporter::getTrackNullOrUndefValueVisitor(const ExplodedNode *N, if (ps->getStmt() == S) break; } - N = N->pred_empty() ? 0 : *N->pred_begin(); + N = N->getFirstPred(); } if (!N) diff --git a/test/Analysis/div-zero.cpp b/test/Analysis/div-zero.cpp new file mode 100644 index 0000000000..d1261dc573 --- /dev/null +++ b/test/Analysis/div-zero.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core.DivideZero -verify %s + +int fooPR10616 (int qX ) { + int a, c, d; + + d = (qX-1); + while ( d != 0 ) { + d = c - (c/d) * d; + } + + return (a % (qX-1)); // expected-warning {{Division by zero}} + +} -- 2.40.0