From a2a735e7fa865850e64eaf678ef60c08d8b9f37f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 2 Apr 2009 03:44:00 +0000 Subject: Add another null pointer check. Simplify condition. llvm-svn: 68283 --- clang/lib/Analysis/BugReporter.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'clang/lib/Analysis/BugReporter.cpp') diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index 7637a1614c2..2baef5e4bfe 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -806,15 +806,16 @@ static void GenExtAddEdge(PathDiagnostic& PD, // FIXME: We need a version of getParent that ignores '()' and casts. const Stmt *parentY = PDB.getParent(Y.asStmt()); - if (IsControlFlowExpr(parentX)) { - if (IsControlFlowExpr(parentY) && parentX == parentY) { + if (parentX && IsControlFlowExpr(parentX)) { + if (parentX == parentY) break; - } else { - const PathDiagnosticLocation &W = - PDB.getEnclosingStmtLocation(PDB.getParent(parentX)); - - if (W != Y) X = W; + if (const Stmt *grandparentX = PDB.getParent(parentX)) { + const PathDiagnosticLocation &W = + PDB.getEnclosingStmtLocation(grandparentX); + + if (W != Y) X = W; + } } } -- cgit v1.2.3