Fix isImplicitInit; use it in empty-container query

This commit is contained in:
Chris Smowton
2023-11-06 11:49:44 +00:00
parent 7106ec77bc
commit 9035ba1f30
2 changed files with 25 additions and 6 deletions

View File

@@ -40,6 +40,6 @@ where
) and
// Also, any value that `v` is initialized to is a fresh container,
forall(Expr e | e = v.getAnAssignedValue() | e instanceof FreshContainer) and
// and `v` is not implicitly initialized by a for-each loop.
not exists(EnhancedForStmt efs | efs.getVariable().getVariable() = v)
// and `v` is not implicitly initialized.
not v.(LocalVariableDecl).getDeclExpr().hasImplicitInit()
select v, "The contents of this container are never initialized."