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 | 042ca3de1e8d723cb73ee4d9984509e4489a6bb7 (patch) | |
| tree | 7d5ea2d4da1b72e0c0840d2a1c974522fdc06cc5 /lib/StaticAnalyzer/Core/BugReporter.cpp | |
| parent | 34d1a0a1522c7bcc7bf431f5b9a92cde3f2315fd (diff) | |
| download | clang-042ca3de1e8d723cb73ee4d9984509e4489a6bb7.tar.gz clang-042ca3de1e8d723cb73ee4d9984509e4489a6bb7.tar.bz2 clang-042ca3de1e8d723cb73ee4d9984509e4489a6bb7.tar.xz | |
[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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
| -rw-r--r-- | lib/StaticAnalyzer/Core/BugReporter.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 21a2af4efe..c74c08a216 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/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); } } |
