mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
Swift: add imported modules properties to ModuleDecl
This commit is contained in:
@@ -1121,6 +1121,8 @@ ModuleDecl:
|
||||
_extends: TypeDecl
|
||||
is_builtin_module: predicate
|
||||
is_system_module: predicate
|
||||
imported_modules: ModuleDecl*
|
||||
exported_modules: ModuleDecl*
|
||||
|
||||
ConstructorRefCallExpr:
|
||||
_extends: SelfApplyExpr
|
||||
|
||||
@@ -1398,6 +1398,10 @@ module Raw {
|
||||
predicate isBuiltinModule() { module_decl_is_builtin_module(this) }
|
||||
|
||||
predicate isSystemModule() { module_decl_is_system_module(this) }
|
||||
|
||||
ModuleDecl getImportedModule(int index) { module_decl_imported_modules(this, index, result) }
|
||||
|
||||
ModuleDecl getExportedModule(int index) { module_decl_exported_modules(this, index, result) }
|
||||
}
|
||||
|
||||
class NumberLiteralExpr extends @number_literal_expr, BuiltinLiteralExpr { }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// generated by codegen/codegen.py
|
||||
private import codeql.swift.generated.Synth
|
||||
private import codeql.swift.generated.Raw
|
||||
import codeql.swift.elements.decl.ModuleDecl
|
||||
import codeql.swift.elements.decl.TypeDecl
|
||||
|
||||
class ModuleDeclBase extends Synth::TModuleDecl, TypeDecl {
|
||||
@@ -13,4 +14,34 @@ class ModuleDeclBase extends Synth::TModuleDecl, TypeDecl {
|
||||
predicate isSystemModule() {
|
||||
Synth::convertModuleDeclToRaw(this).(Raw::ModuleDecl).isSystemModule()
|
||||
}
|
||||
|
||||
ModuleDecl getImmediateImportedModule(int index) {
|
||||
result =
|
||||
Synth::convertModuleDeclFromRaw(Synth::convertModuleDeclToRaw(this)
|
||||
.(Raw::ModuleDecl)
|
||||
.getImportedModule(index))
|
||||
}
|
||||
|
||||
final ModuleDecl getImportedModule(int index) {
|
||||
result = getImmediateImportedModule(index).resolve()
|
||||
}
|
||||
|
||||
final ModuleDecl getAnImportedModule() { result = getImportedModule(_) }
|
||||
|
||||
final int getNumberOfImportedModules() { result = count(getAnImportedModule()) }
|
||||
|
||||
ModuleDecl getImmediateExportedModule(int index) {
|
||||
result =
|
||||
Synth::convertModuleDeclFromRaw(Synth::convertModuleDeclToRaw(this)
|
||||
.(Raw::ModuleDecl)
|
||||
.getExportedModule(index))
|
||||
}
|
||||
|
||||
final ModuleDecl getExportedModule(int index) {
|
||||
result = getImmediateExportedModule(index).resolve()
|
||||
}
|
||||
|
||||
final ModuleDecl getAnExportedModule() { result = getExportedModule(_) }
|
||||
|
||||
final int getNumberOfExportedModules() { result = count(getAnExportedModule()) }
|
||||
}
|
||||
|
||||
@@ -2116,6 +2116,20 @@ module_decl_is_system_module( //dir=decl
|
||||
int id: @module_decl ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
module_decl_imported_modules( //dir=decl
|
||||
int id: @module_decl ref,
|
||||
int index: int ref,
|
||||
int imported_module: @module_decl ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
module_decl_exported_modules( //dir=decl
|
||||
int id: @module_decl ref,
|
||||
int index: int ref,
|
||||
int exported_module: @module_decl ref
|
||||
);
|
||||
|
||||
constructor_ref_call_exprs( //dir=expr
|
||||
unique int id: @constructor_ref_call_expr
|
||||
);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements
|
||||
import TestUtils
|
||||
|
||||
from ModuleDecl x, int index
|
||||
where toBeTested(x) and not x.isUnknown()
|
||||
select x, index, x.getExportedModule(index)
|
||||
@@ -0,0 +1,7 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements
|
||||
import TestUtils
|
||||
|
||||
from ModuleDecl x, int index
|
||||
where toBeTested(x) and not x.isUnknown()
|
||||
select x, index, x.getImportedModule(index)
|
||||
Reference in New Issue
Block a user