From: Anna Zaks Date: Mon, 12 Sep 2011 18:07:30 +0000 (+0000) Subject: [analyzer] Fix a failure encountered while analyzing bind (radar://10105448). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a756463ffe90f9a06c8cc8c190f22a5e4366c25;p=clang [analyzer] Fix a failure encountered while analyzing bind (radar://10105448). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139509 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 9b5a60c0d6..5a56afb056 100644 --- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -553,7 +553,7 @@ ConditionBRVisitor::VisitTrueTest(const Expr *Cond, default: return 0; case Stmt::BinaryOperatorClass: - return VisitTrueTest(Cond, cast(Cond), tookTrue, BRC); + return VisitTrueTest(Cond, cast(Ex), tookTrue, BRC); case Stmt::DeclRefExprClass: return VisitTrueTest(Cond, cast(Ex), tookTrue, BRC); case Stmt::UnaryOperatorClass: { diff --git a/test/Analysis/undef-buffers.c b/test/Analysis/undef-buffers.c index ccc55c2dee..cfdd7f4e1a 100644 --- a/test/Analysis/undef-buffers.c +++ b/test/Analysis/undef-buffers.c @@ -15,6 +15,17 @@ char stackBased2 () { return buf[0]; // expected-warning{{Undefined}} } +// Exercise the conditional visitor. Radar://10105448 +char stackBased3 (int *x) { + char buf[2]; + int *y; + buf[0] = 'a'; + if (!(y = x)) { + return buf[1]; // expected-warning{{Undefined}} + } + return buf[0]; +} + char heapBased1 () { char *buf = malloc(2); buf[0] = 'a';