Skip to content

Commit 2802ef4

Browse files
committed
Fix crash on StaticAnalyzer loop unrolling
1 parent 8ba915f commit 2802ef4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ static bool isPossiblyEscaped(ExplodedNode *N, const DeclRefExpr *DR) {
226226
return false;
227227
}
228228
}
229+
230+
if (const SwitchStmt *SS = dyn_cast<SwitchStmt>(S)) {
231+
for (const Stmt *CB : dyn_cast<CompoundStmt>(SS->getBody())->body()) {
232+
for (const Decl *D : dyn_cast<DeclStmt>(CB)->decls()) {
233+
// Once we reach the declaration of the VD we can return.
234+
if (D->getCanonicalDecl() == VD)
235+
return false;
236+
}
237+
}
238+
}
239+
229240
// Check the usage of the pass-by-ref function calls and adress-of operator
230241
// on VD and reference initialized by VD.
231242
ASTContext &ASTCtx =

0 commit comments

Comments
 (0)