-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathTestUtils.qll
51 lines (50 loc) · 1.21 KB
/
TestUtils.qll
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
private import codeql.swift.elements
private import codeql.swift.generated.ParentChild
// Internal classes are not imported by the tests:
import codeql.swift.elements.expr.internal.InitializerRefCallExpr
import codeql.swift.elements.expr.internal.DotSyntaxCallExpr
cached
predicate toBeTested(Element e) {
e instanceof File
or
e instanceof ParameterizedProtocolType
or
e instanceof PackType
or
e instanceof PackElementType
or
e instanceof PackArchetypeType
or
e instanceof MacroRole
or
exists(ModuleDecl m |
m = e and
not m.isBuiltinModule() and
not m.isSystemModule()
)
or
e.(Locatable).getLocation().getFile().getName().matches("%swift/ql/test%")
or
exists(Element tested |
toBeTested(tested) and
(
e = tested.(ValueDecl).getInterfaceType()
or
e = tested.(NominalTypeDecl).getType()
or
e = tested.(VarDecl).getType()
or
e = tested.(Expr).getType()
or
e = tested.(Type).getCanonicalType()
or
e = tested.(ExistentialType).getConstraint()
or
e.(UnspecifiedElement).getParent() = tested
or
e.(OpaqueTypeDecl).getNamingDeclaration() = tested
or
tested = getImmediateParent(e)
)
)
}