]> granicus.if.org Git - clang/commitdiff
Add another null pointer check. Simplify condition.
authorTed Kremenek <kremenek@apple.com>
Thu, 2 Apr 2009 03:44:00 +0000 (03:44 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 2 Apr 2009 03:44:00 +0000 (03:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68283 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BugReporter.cpp

index 7637a1614c2569729fb1166dd208e6e96d7ca682..2baef5e4bfe174d24db5a72efe145045493c7d0f 100644 (file)
@@ -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;
+            }
           }
         }