diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-22 18:16:20 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-22 18:16:20 +0000 |
commit | a301a6773db085575ac51e3c966858180390c25b (patch) | |
tree | cfd1aebb39231610449eab3de62c9f7ac56b83b2 /lib/Analysis/BugReporter.cpp | |
parent | 8f33290741c2c6190576523e06a0d3bb698554b1 (diff) |
BugReporter (extensive diagnostic algorithm): The initial control-flow edge now
starts from the first character of the first statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 7e7132aaab..33ff12d17e 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -796,8 +796,9 @@ class VISIBILITY_HIDDEN EdgeBuilder { 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(); @@ -808,6 +809,15 @@ public: ~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); @@ -907,6 +917,10 @@ void EdgeBuilder::rawAddEdge(PathDiagnosticLocation NewLoc) { } void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) { + + if (!alwaysAdd && NewLoc.asLocation().isMacroID()) + return; + const PathDiagnosticLocation &CLoc = getContextLocation(NewLoc); while (!CLocs.empty()) { |