Files
codeql/swift/ql/test/TestUtils.qll
Nora Dimitrijević 16fc42a53f Swift: fix formatting
2023-04-26 16:01:57 +02:00

44 lines
1.1 KiB
Plaintext

private import codeql.swift.elements
private import codeql.swift.generated.ParentChild
// Internal classes are not imported by the tests:
import codeql.swift.elements.expr.InitializerRefCallExpr
import codeql.swift.elements.expr.DotSyntaxCallExpr
cached
predicate toBeTested(Element e) {
e instanceof File
or
e instanceof ParameterizedProtocolType
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)
)
)
}