PrevLoc = PD.begin()->getLocation();
if (const Stmt *S = PrevLoc.asStmt())
- addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
}
void rawAddEdge(PathDiagnosticLocation NewLoc);
void addContext(const Stmt *S);
+ void addExtendedContext(const Stmt *S);
};
} // end anonymous namespace
return false;
}
+void EdgeBuilder::addExtendedContext(const Stmt *S) {
+ if (!S)
+ return;
+
+ const Stmt *Parent = PDB.getParent(S);
+ while (Parent) {
+ if (isa<CompoundStmt>(Parent))
+ Parent = PDB.getParent(Parent);
+ else
+ break;
+ }
+
+ if (Parent) {
+ switch (Parent->getStmtClass()) {
+ case Stmt::DoStmtClass:
+ case Stmt::ObjCAtSynchronizedStmtClass:
+ addContext(Parent);
+ default:
+ break;
+ }
+ }
+
+ addContext(S);
+}
+
void EdgeBuilder::addContext(const Stmt *S) {
if (!S)
return;
EB.addContext(S);
}
else
- EB.addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
continue;
EB.addEdge(Loc, true);
PD.push_front(p);
if (const Stmt *S = Loc.asStmt())
- EB.addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
}
}