зеркало из https://github.com/github/codeql.git
changes based on review
This commit is contained in:
Родитель
40fd1825e9
Коммит
3784b180d8
|
@ -29,23 +29,6 @@ predicate deadStoreOfLocal(VarDef vd, PurelyLocalVariable v) {
|
|||
not exists(SsaExplicitDefinition ssa | ssa.defines(vd, v))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if there exists another definition of the variable `v` that dominates `dead`.
|
||||
*/
|
||||
predicate hasDominatingDef(VarDef dead, PurelyLocalVariable v) {
|
||||
exists(VarDef otherDef | not otherDef = dead and otherDef.getAVariable() = v |
|
||||
dead.getBasicBlock().getASuccessor+() = otherDef.getBasicBlock()
|
||||
or
|
||||
exists(ReachableBasicBlock bb, int i, int j |
|
||||
bb = otherDef.getBasicBlock() and bb = dead.getBasicBlock()
|
||||
|
|
||||
bb.defAt(i, v, dead) and
|
||||
bb.defAt(j, v, otherDef) and
|
||||
j > i
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
from VarDef dead, PurelyLocalVariable v, string msg
|
||||
where
|
||||
deadStoreOfLocal(dead, v) and
|
||||
|
@ -80,8 +63,10 @@ where
|
|||
(
|
||||
// To avoid confusion about the meaning of "definition" and "declaration" we avoid
|
||||
// the term "definition" when the alert location is a variable declaration.
|
||||
if dead instanceof VariableDeclarator and hasDominatingDef(dead, v)
|
||||
if
|
||||
dead instanceof VariableDeclarator and
|
||||
not exists(SsaImplicitInit init | init.getVariable().getSourceVariable() = v) // the variable is dead at the hoisted implicit initialization.
|
||||
then msg = "The initial value of " + v.getName() + " is unused, since it is always overwritten."
|
||||
else msg = "This definition of " + v.getName() + " is useless, since its value is never read."
|
||||
else msg = "The value assigned to " + v.getName() + " here is unused."
|
||||
)
|
||||
select dead, msg
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
| overload.ts:10:12:10:14 | baz | This definition of baz is useless, since its value is never read. |
|
||||
| overload.ts:10:12:10:14 | baz | The value assigned to baz here is unused. |
|
||||
| tst2.js:26:9:26:14 | x = 23 | The initial value of x is unused, since it is always overwritten. |
|
||||
| tst2.js:28:9:28:14 | x = 42 | This definition of x is useless, since its value is never read. |
|
||||
| tst3.js:2:1:2:36 | exports ... a: 23 } | This definition of exports is useless, since its value is never read. |
|
||||
| tst3b.js:2:18:2:36 | exports = { a: 23 } | This definition of exports is useless, since its value is never read. |
|
||||
| tst.js:6:2:6:7 | y = 23 | This definition of y is useless, since its value is never read. |
|
||||
| tst2.js:28:9:28:14 | x = 42 | The value assigned to x here is unused. |
|
||||
| tst3.js:2:1:2:36 | exports ... a: 23 } | The value assigned to exports here is unused. |
|
||||
| tst3b.js:2:18:2:36 | exports = { a: 23 } | The value assigned to exports here is unused. |
|
||||
| tst.js:6:2:6:7 | y = 23 | The value assigned to y here is unused. |
|
||||
| tst.js:13:6:13:11 | a = 23 | The initial value of a is unused, since it is always overwritten. |
|
||||
| tst.js:13:14:13:19 | a = 42 | This definition of a is useless, since its value is never read. |
|
||||
| tst.js:13:14:13:19 | a = 42 | The value assigned to a here is unused. |
|
||||
| tst.js:45:6:45:11 | x = 23 | The initial value of x is unused, since it is always overwritten. |
|
||||
| tst.js:51:6:51:11 | x = 23 | The initial value of x is unused, since it is always overwritten. |
|
||||
| tst.js:132:7:132:13 | {x} = o | The initial value of x is unused, since it is always overwritten. |
|
||||
| tst.js:162:6:162:14 | [x] = [0] | The initial value of x is unused, since it is always overwritten. |
|
||||
| tst.js:172:7:172:17 | nSign = foo | This definition of nSign is useless, since its value is never read. |
|
||||
| tst.js:172:7:172:17 | nSign = foo | The value assigned to nSign here is unused. |
|
||||
|
|
Загрузка…
Ссылка в новой задаче