summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-30 01:05:58 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-30 01:05:58 +0000
commit543bdd1237e3ab6ea0ded408c82e3cca4b5769c2 (patch)
tree86eace9e95a35fa9fdf4eefabc7b8198cd899ea2 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parentd1c5a317213a7d5551701bf9e2adf9246ceb6283 (diff)
downloadbcm5719-llvm-543bdd1237e3ab6ea0ded408c82e3cca4b5769c2.tar.gz
bcm5719-llvm-543bdd1237e3ab6ea0ded408c82e3cca4b5769c2.zip
[analyzer; new edges] In for(;;), use the ForStmt itself for loop notes.
Most loop notes (like "entering loop body") are attached to the condition expression guarding a loop or its equivalent. For loops may not have a condition expression, though. Rather than crashing, just use the entire ForStmt as the location. This is probably the best we can do. <rdar://problem/14016063> llvm-svn: 182904
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 9659205e879..fe830183fbb 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1776,7 +1776,7 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,
}
if (str) {
- PathDiagnosticLocation L(TermCond, SM, PDB.LC);
+ PathDiagnosticLocation L(TermCond ? TermCond : Term, SM, PDB.LC);
PathDiagnosticEventPiece *PE =
new PathDiagnosticEventPiece(L, str);
PE->setPrunable(true);
@@ -2252,7 +2252,10 @@ static void adjustBranchEdges(PathPieces &pieces, LocationContextMap &LCM,
const Stmt *S = Dst;
while (const Stmt *Parent = getStmtParent(S, PM)) {
if (const ForStmt *FS = dyn_cast<ForStmt>(Parent)) {
- if (FS->getCond()->IgnoreParens() == S)
+ const Stmt *Cond = FS->getCond();
+ if (!Cond)
+ Cond = FS;
+ if (Cond == S)
Branch = FS;
break;
}
@@ -2267,7 +2270,7 @@ static void adjustBranchEdges(PathPieces &pieces, LocationContextMap &LCM,
break;
}
if (const ObjCForCollectionStmt *OFS =
- dyn_cast<ObjCForCollectionStmt>(Parent)) {
+ dyn_cast<ObjCForCollectionStmt>(Parent)) {
if (OFS->getElement() == S)
Branch = OFS;
break;
OpenPOWER on IntegriCloud