public:
EdgeBuilder(PathDiagnostic &pd, PathDiagnosticBuilder &pdb)
: PD(pd), PDB(pdb) {
- CLocs.push_back(PathDiagnosticLocation(&PDB.getCodeDecl(),
- PDB.getSourceManager()));
+
+ // If the PathDiagnostic already has pieces, add the enclosing statement
+ // of the first piece as a context as well.
if (!PD.empty()) {
PrevLoc = PD.begin()->getLocation();
~EdgeBuilder() {
while (!CLocs.empty()) popLocation();
+
+ // Finally, add an initial edge from the start location of the first
+ // statement (if it doesn't already exist).
+ if (const CompoundStmt *CS = PDB.getCodeDecl().getBody(PDB.getContext()))
+ if (!CS->body_empty()) {
+ SourceLocation Loc = (*CS->body_begin())->getLocStart();
+ rawAddEdge(PathDiagnosticLocation(Loc, PDB.getSourceManager()));
+ }
+
}
void addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd = false);
}
void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) {
+
+ if (!alwaysAdd && NewLoc.asLocation().isMacroID())
+ return;
+
const PathDiagnosticLocation &CLoc = getContextLocation(NewLoc);
while (!CLocs.empty()) {