diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-01 18:48:52 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-01 18:48:52 +0000 |
commit | ed47d79cc2c5f7d825766d0b5b947d0963f0a61f (patch) | |
tree | 2a83c8510b7933b667452c126d5a2351c76ccf54 /clang/lib/Analysis/BugReporter.cpp | |
parent | cff6953c456fb359c971c3b0ae263d19ea4b4ae4 (diff) | |
download | bcm5719-llvm-ed47d79cc2c5f7d825766d0b5b947d0963f0a61f.tar.gz bcm5719-llvm-ed47d79cc2c5f7d825766d0b5b947d0963f0a61f.zip |
BugReporter: for extensive path diagnostics:
- When processing BlockEdges with terminators, using the condition as the
control-flow point for terminators that are expressions (e.g., '&&', '?')
- When processing events, allow intra-compound statement "jumping"
llvm-svn: 68228
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index f4a7ff1aee6..94432c01ce2 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -810,12 +810,8 @@ static bool IsNestedDeclStmt(const Stmt *S, ParentMap &PM) { if (const ForStmt *FS = dyn_cast<ForStmt>(Parent)) return FS->getInit() == DS; - // FIXME: In the future IfStmt/WhileStmt may contain DeclStmts in their condition. -// if (const IfStmt *IF = dyn_cast<IfStmt>(Parent)) -// return IF->getCond() == DS; -// -// if (const WhileStmt *WS = dyn_cast<WhileStmt>(Parent)) -// return WS->getCond() == DS; + // FIXME: In the future IfStmt/WhileStmt may contain DeclStmts in their + // condition. return false; } @@ -847,11 +843,13 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, } if (const Stmt *Term = Blk.getTerminator()) { - const Stmt *Cond = Blk.getTerminatorCondition(); - + const Stmt *Cond = Blk.getTerminatorCondition(); if (!Cond || !IsControlFlowExpr(Cond)) { - GenExtAddEdge(PD, PDB, PathDiagnosticLocation(Term, SMgr), PrevLoc, - true); + // For terminators that are control-flow expressions like '&&', '?', + // have the condition be the anchor point for the control-flow edge + // instead of the terminator. + const Stmt *X = isa<Expr>(Term) ? (Cond ? Cond : Term) : Term; + GenExtAddEdge(PD, PDB, PathDiagnosticLocation(X, SMgr), PrevLoc,true); continue; } } @@ -893,7 +891,7 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, PDB.getBugReporter(), PDB.getNodeMapClosure()); if (p) { - GenExtAddEdge(PD, PDB, p->getLocation(), PrevLoc); + GenExtAddEdge(PD, PDB, p->getLocation(), PrevLoc, true); PD.push_front(p); } } |