summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-05-09 06:55:41 +0000
committerTed Kremenek <kremenek@apple.com>2013-05-09 06:55:41 +0000
commit399980acf5ffd48feafe43530a16c1d7f75aa114 (patch)
tree9d98db8476a0c089de9ffe460b4d6436946bcc93 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parentb5999f6321bf6b523273340d5ba2f9ff979c12a3 (diff)
downloadbcm5719-llvm-399980acf5ffd48feafe43530a16c1d7f75aa114.tar.gz
bcm5719-llvm-399980acf5ffd48feafe43530a16c1d7f75aa114.zip
[analyzer; alternate arrows] for "loop back" edges add back the extra edge to the closing '}'
llvm-svn: 181505
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 7ce3f988679..b43625f8069 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1722,6 +1722,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,
// Are we jumping to the head of a loop? Add a special diagnostic.
if (const Stmt *Loop = BE->getSrc()->getLoopTarget()) {
PathDiagnosticLocation L(Loop, SM, PDB.LC);
+ const CompoundStmt *CS = NULL;
+
+ if (const ForStmt *FS = dyn_cast<ForStmt>(Loop))
+ CS = dyn_cast<CompoundStmt>(FS->getBody());
+ else if (const WhileStmt *WS = dyn_cast<WhileStmt>(Loop))
+ CS = dyn_cast<CompoundStmt>(WS->getBody());
PathDiagnosticEventPiece *p =
new PathDiagnosticEventPiece(L, "Looping back to the head "
@@ -1730,6 +1736,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,
addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), PDB.LC);
PD.getActivePath().push_front(p);
+
+ if (CS) {
+ addEdgeToPath(PD.getActivePath(), PrevLoc,
+ PathDiagnosticLocation::createEndBrace(CS, SM),
+ PDB.LC);
+ }
}
const CFGBlock *BSrc = BE->getSrc();
OpenPOWER on IntegriCloud