зеркало из https://github.com/microsoft/clang-1.git
[analyzer; alternate arrows] for "loop back" edges add back the extra edge to the closing '}'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181505 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8841c532f2
Коммит
afde200cda
|
@ -1722,6 +1722,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,
|
||||||
// Are we jumping to the head of a loop? Add a special diagnostic.
|
// Are we jumping to the head of a loop? Add a special diagnostic.
|
||||||
if (const Stmt *Loop = BE->getSrc()->getLoopTarget()) {
|
if (const Stmt *Loop = BE->getSrc()->getLoopTarget()) {
|
||||||
PathDiagnosticLocation L(Loop, SM, PDB.LC);
|
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 =
|
PathDiagnosticEventPiece *p =
|
||||||
new PathDiagnosticEventPiece(L, "Looping back to the head "
|
new PathDiagnosticEventPiece(L, "Looping back to the head "
|
||||||
|
@ -1730,6 +1736,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,
|
||||||
|
|
||||||
addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), PDB.LC);
|
addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), PDB.LC);
|
||||||
PD.getActivePath().push_front(p);
|
PD.getActivePath().push_front(p);
|
||||||
|
|
||||||
|
if (CS) {
|
||||||
|
addEdgeToPath(PD.getActivePath(), PrevLoc,
|
||||||
|
PathDiagnosticLocation::createEndBrace(CS, SM),
|
||||||
|
PDB.LC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFGBlock *BSrc = BE->getSrc();
|
const CFGBlock *BSrc = BE->getSrc();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче