From: Ted Kremenek Date: Sat, 20 Dec 2008 01:41:43 +0000 (+0000) Subject: Fix : BugReporter should correctly handle switch statements... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ddc4d5f50dc6cd899ed07419413222c1d785d1c;p=clang Fix : BugReporter should correctly handle switch statements with no default case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61270 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 8274ce71ff..e6840c3ad2 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -549,12 +549,14 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, if (Stmt* S = Dst->getLabel()) switch (S->getStmtClass()) { - default: - assert(false && "Not a valid switch label."); - continue; + default: { + os << "No cases match in the switch statement. " + "Control jumps to line " + << SMgr.getLogicalLineNumber(S->getLocStart()) << ".\n"; + break; + } - case Stmt::DefaultStmtClass: { - + case Stmt::DefaultStmtClass: { os << "Control jumps to the 'default' case at line " << SMgr.getLogicalLineNumber(S->getLocStart()) << ".\n";