]> granicus.if.org Git - clang/commitdiff
Address PR10616. The crash has already been fixed by Ted in r140725, so just refactor...
authorAnna Zaks <ganna@apple.com>
Sat, 1 Oct 2011 06:35:19 +0000 (06:35 +0000)
committerAnna Zaks <ganna@apple.com>
Sat, 1 Oct 2011 06:35:19 +0000 (06:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140932 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/div-zero.cpp [new file with mode: 0644]

index 3afbd872138194b9f6cc6093a8796bf148b841fa..da08cbd88e07871f3dbf0f69803378fcf3836747 100644 (file)
@@ -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 (file)
index 0000000..d1261dc
--- /dev/null
@@ -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}}
+
+}