From 998c133a3b1cd0c34c52907f3ec2798e0dde7e0e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 23 Nov 2009 17:58:48 +0000 Subject: [PATCH] Cleanup title/description of "undefined branch" BugType and add some test cases for this check. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89679 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/UndefBranchChecker.cpp | 3 +-- test/Analysis/misc-ps.m | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Analysis/UndefBranchChecker.cpp b/lib/Analysis/UndefBranchChecker.cpp index 8d72b5a96b..0a66e21de9 100644 --- a/lib/Analysis/UndefBranchChecker.cpp +++ b/lib/Analysis/UndefBranchChecker.cpp @@ -72,8 +72,7 @@ void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder, if (N) { N->markAsSink(); if (!BT) - BT = new BuiltinBug("Undefined branch", - "Branch condition evaluates to an undefined or garbage value"); + BT = new BuiltinBug("Branch condition evaluates to a garbage value"); EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getDescription(),N); R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, Condition); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 85095f4e07..385fcafdc5 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -751,6 +751,23 @@ void test_undefined_array_subscript() { } @end +//===----------------------------------------------------------------------===// +// Test using an uninitialized value as a branch condition. +//===----------------------------------------------------------------------===// + +int test_uninit_branch(void) { + int x; + if (x) // expected-warning{{Branch condition evaluates to a garbage value}} + return 1; + return 0; +} + +int test_uninit_branch_b(void) { + int x; + return x ? 1 : 0; // expected-warning{{Branch condition evaluates to a garbage value}} +} + + //===----------------------------------------------------------------------===// // Test passing an undefined value in a message or function call. //===----------------------------------------------------------------------===// -- 2.40.0