forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfgDeadEnds.ql
More file actions
64 lines (62 loc) · 1.44 KB
/
cfgDeadEnds.ql
File metadata and controls
64 lines (62 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java
predicate shouldBeDeadEnd(ExprParent n) {
n instanceof BreakStmt and n.getFile().isKotlinSourceFile() // TODO
or
n instanceof Interface // TODO
or
n instanceof Class // TODO
or
n instanceof Parameter // TODO
or
n instanceof Field // TODO
or
n instanceof Annotation // TODO
or
n instanceof TypeAccess // TODO
or
n instanceof ArrayTypeAccess // TODO
or
n instanceof UnionTypeAccess // TODO
or
n instanceof IntersectionTypeAccess // TODO
or
n instanceof ArrayAccess // TODO
or
n instanceof AddExpr // TODO
or
n instanceof MinusExpr // TODO
or
n instanceof LocalVariableDecl // TODO
or
n instanceof FieldDeclaration // TODO
or
n instanceof ArrayInit // TODO
or
n instanceof VarAccess // TODO
or
n instanceof Literal // TODO
or
n instanceof TypeLiteral // TODO
or
n instanceof TypeVariable // TODO
or
n instanceof WildcardTypeAccess // TODO
or
n instanceof MethodCall // TODO
or
n instanceof Method
or
n instanceof Constructor
or
not exists(n.getFile().getRelativePath()) // TODO
or
n = any(ConstCase c).getValue(_) // TODO
}
from ControlFlowNode n, ExprParent astnode, string s
where
astnode = n.getAstNode() and
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n.getAstNode()) and s = "expected dead end"
not exists(n.getASuccessor()) and
not shouldBeDeadEnd(astnode) and
s = "unexpected dead end"
select n, astnode.getPrimaryQlClasses(), s