summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Analysis/UndefBranchChecker.cpp3
-rw-r--r--clang/test/Analysis/misc-ps.m17
2 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Analysis/UndefBranchChecker.cpp b/clang/lib/Analysis/UndefBranchChecker.cpp
index 8d72b5a96be..0a66e21de94 100644
--- a/clang/lib/Analysis/UndefBranchChecker.cpp
+++ b/clang/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/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index 85095f4e079..385fcafdc57 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -752,6 +752,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.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud