Files
codeql/swift/ql/test/TestUtils.qll
Paolo Tranquilli 3a975174c3 Swift: extract ImportDecl and ModuleDecl
As `ASTMangler` crashes when called on `ModuleDecl`, we simply use
its name.

This might probably not work reliably in a scenario where multiple
modules are compiled with the same name (like `main`), but this is left
for future work. At the moment this cannot create DB inconsistencies.
2022-07-01 15:29:30 +02:00

29 lines
682 B
Plaintext

private import codeql.swift.elements
cached
predicate toBeTested(Element e) {
e instanceof File
or
exists(ModuleDecl m | m = e and not m.isBuiltinModule() and not m.isSystemModule())
or
exists(Locatable loc |
loc.getLocation().getFile().getName().matches("%swift/ql/test%") and
(
e = loc
or
exists(Type t |
(e = t or e = t.(ExistentialType).getConstraint() or e = t.getCanonicalType()) and
(
t = loc.(ValueDecl).getInterfaceType()
or
t = loc.(NominalTypeDecl).getType()
or
t = loc.(VarDecl).getType()
or
t = loc.(Expr).getType()
)
)
)
)
}