diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-05-31 06:11:17 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-05-31 06:11:17 +0000 |
commit | 263595f4f3f02165eb163b35ad96a439a849ad57 (patch) | |
tree | 36299fe465a869b9e562b781d6903b84a569436c /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | d59fbca22532f61a90a349bb6f9ed9f959601360 (diff) | |
download | bcm5719-llvm-263595f4f3f02165eb163b35ad96a439a849ad57.tar.gz bcm5719-llvm-263595f4f3f02165eb163b35ad96a439a849ad57.zip |
[analyzer; new edges] in splitBranchConditionEdges() do not check that predecessor edge has source in the same lexical scope as the target branch.
Fixes <rdar://problem/14031292>.
llvm-svn: 182987
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 21a2af4efe3..c74c08a2165 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2287,6 +2287,13 @@ static void splitBranchConditionEdges(PathPieces &pieces, Branch = OFS; break; } + if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(Parent)) { + if (BO->isLogicalOp()) { + if (BO->getLHS()->IgnoreParens() == S) + Branch = BO; + break; + } + } S = Parent; } @@ -2303,34 +2310,31 @@ static void splitBranchConditionEdges(PathPieces &pieces, // Now look at the previous edge. We want to know if this was in the same // "level" as the for statement. - const Stmt *SrcParent = getStmtParent(Src, PM); const Stmt *BranchParent = getStmtParent(Branch, PM); - if (SrcParent && SrcParent == BranchParent) { - PathDiagnosticLocation L(Branch, SM, LC); - bool needsEdge = true; - - if (Prev != E) { - if (PathDiagnosticControlFlowPiece *P = - dyn_cast<PathDiagnosticControlFlowPiece>(*Prev)) { - const Stmt *PrevSrc = getLocStmt(P->getStartLocation()); - if (PrevSrc) { - const Stmt *PrevSrcParent = getStmtParent(PrevSrc, PM); - if (PrevSrcParent == BranchParent) { - P->setEndLocation(L); - needsEdge = false; - } + PathDiagnosticLocation L(Branch, SM, LC); + bool needsEdge = true; + + if (Prev != E) { + if (PathDiagnosticControlFlowPiece *P = + dyn_cast<PathDiagnosticControlFlowPiece>(*Prev)) { + const Stmt *PrevSrc = getLocStmt(P->getStartLocation()); + if (PrevSrc) { + const Stmt *PrevSrcParent = getStmtParent(PrevSrc, PM); + if (PrevSrcParent == BranchParent) { + P->setEndLocation(L); + needsEdge = false; } } } + } - if (needsEdge) { - PathDiagnosticControlFlowPiece *P = - new PathDiagnosticControlFlowPiece(PieceI->getStartLocation(), L); - pieces.insert(I, P); - } - - PieceI->setStartLocation(L); + if (needsEdge) { + PathDiagnosticControlFlowPiece *P = + new PathDiagnosticControlFlowPiece(PieceI->getStartLocation(), L); + pieces.insert(I, P); } + + PieceI->setStartLocation(L); } } |