summaryrefslogtreecommitdiff
path: root/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
commit3e8a85fcfc3d264e4c5b21fbdd741bbc0c24a266 (patch)
tree87acf4d6f6e84b01a30e167fa1186c6822213c60 /lib/StaticAnalyzer/Core/BugReporter.cpp
parent1bc085aec3901e22b819bb6761d5ccc360194604 (diff)
downloadclang-3e8a85fcfc3d264e4c5b21fbdd741bbc0c24a266.tar.gz
clang-3e8a85fcfc3d264e4c5b21fbdd741bbc0c24a266.tar.bz2
clang-3e8a85fcfc3d264e4c5b21fbdd741bbc0c24a266.tar.xz
[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> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 9659205e87..fe830183fb 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/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;