зеркало из https://github.com/microsoft/clang-1.git
[analyzer;alternate arrows] adapt 'for' loop aesthetic cleanup to 'while' loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181504 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
bded6eaeed
Коммит
8841c532f2
|
@ -2011,34 +2011,38 @@ static void adjustLoopEdges(PathPieces &pieces, LocationContextMap &LCM,
|
||||||
if (!Dst || !Src)
|
if (!Dst || !Src)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const ForStmt *FS = 0;
|
const Stmt *Loop = 0;
|
||||||
const Stmt *S = Dst;
|
const Stmt *S = Dst;
|
||||||
while (const Stmt *Parent = PM.getParentIgnoreParens(S)) {
|
while (const Stmt *Parent = PM.getParentIgnoreParens(S)) {
|
||||||
FS = dyn_cast<ForStmt>(Parent);
|
if (const ForStmt *FS = dyn_cast<ForStmt>(Parent)) {
|
||||||
if (FS) {
|
if (FS->getCond()->IgnoreParens() == S)
|
||||||
if (FS->getCond()->IgnoreParens() != S)
|
Loop = FS;
|
||||||
FS = 0;
|
break;
|
||||||
|
}
|
||||||
|
if (const WhileStmt *WS = dyn_cast<WhileStmt>(Parent)) {
|
||||||
|
if (WS->getCond()->IgnoreParens() == S)
|
||||||
|
Loop = WS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
S = Parent;
|
S = Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If 'FS' is non-null we have found a match where we have an edge
|
// If 'Loop' is non-null we have found a match where we have an edge
|
||||||
// incident on the condition of a for statement.
|
// incident on the condition of a for/while statement.
|
||||||
if (!FS)
|
if (!Loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the current source of the edge is the 'for', then there is nothing
|
// If the current source of the edge is the 'for'/'while', then there is
|
||||||
// left to be done.
|
// nothing left to be done.
|
||||||
if (Src == FS)
|
if (Src == Loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Now look at the previous edge. We want to know if this was in the same
|
// Now look at the previous edge. We want to know if this was in the same
|
||||||
// "level" as the for statement.
|
// "level" as the for statement.
|
||||||
const Stmt *SrcParent = PM.getParentIgnoreParens(Src);
|
const Stmt *SrcParent = PM.getParentIgnoreParens(Src);
|
||||||
const Stmt *FSParent = PM.getParentIgnoreParens(FS);
|
const Stmt *FSParent = PM.getParentIgnoreParens(Loop);
|
||||||
if (SrcParent && SrcParent == FSParent) {
|
if (SrcParent && SrcParent == FSParent) {
|
||||||
PathDiagnosticLocation L(FS, SM, LC);
|
PathDiagnosticLocation L(Loop, SM, LC);
|
||||||
bool needsEdge = true;
|
bool needsEdge = true;
|
||||||
|
|
||||||
if (Prev != E) {
|
if (Prev != E) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче