mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: implement imported_ and exported_modules
This has expanded the required builtin symbols.
This commit is contained in:
@@ -90,20 +90,68 @@ static void getBuiltinDecls(swift::ModuleDecl& builtinModule,
|
||||
llvm::SmallVector<swift::Decl*>& decls) {
|
||||
llvm::SmallVector<swift::ValueDecl*> values;
|
||||
for (auto symbol : {
|
||||
"zeroInitializer", "BridgeObject", "Word", "NativeObject",
|
||||
"RawPointer", "Int1", "Int8", "Int16",
|
||||
"Int32", "Int64", "IntLiteral", "FPIEEE16",
|
||||
"FPIEEE32", "FPIEEE64", "FPIEEE80", "Vec2xInt8",
|
||||
"Vec4xInt8", "Vec8xInt8", "Vec16xInt8", "Vec32xInt8",
|
||||
"Vec64xInt8", "Vec2xInt16", "Vec4xInt16", "Vec8xInt16",
|
||||
"Vec16xInt16", "Vec32xInt16", "Vec64xInt16", "Vec2xInt32",
|
||||
"Vec4xInt32", "Vec8xInt32", "Vec16xInt32", "Vec32xInt32",
|
||||
"Vec64xInt32", "Vec2xInt64", "Vec4xInt64", "Vec8xInt64",
|
||||
"Vec16xInt64", "Vec32xInt64", "Vec64xInt64", "Vec2xFPIEEE16",
|
||||
"Vec4xFPIEEE16", "Vec8xFPIEEE16", "Vec16xFPIEEE16", "Vec32xFPIEEE16",
|
||||
"Vec64xFPIEEE16", "Vec2xFPIEEE32", "Vec4xFPIEEE32", "Vec8xFPIEEE32",
|
||||
"Vec16xFPIEEE32", "Vec32xFPIEEE32", "Vec64xFPIEEE32", "Vec2xFPIEEE64",
|
||||
"Vec4xFPIEEE64", "Vec8xFPIEEE64", "Vec16xFPIEEE64", "Vec32xFPIEEE64",
|
||||
"zeroInitializer",
|
||||
"BridgeObject",
|
||||
"Word",
|
||||
"NativeObject",
|
||||
"RawPointer",
|
||||
"Executor",
|
||||
"Job",
|
||||
"RawUnsafeContinuation",
|
||||
"addressof",
|
||||
"initialize",
|
||||
"reinterpretCast",
|
||||
"Int1",
|
||||
"Int8",
|
||||
"Int16",
|
||||
"Int32",
|
||||
"Int64",
|
||||
"IntLiteral",
|
||||
"FPIEEE16",
|
||||
"FPIEEE32",
|
||||
"FPIEEE64",
|
||||
"FPIEEE80",
|
||||
"Vec2xInt8",
|
||||
"Vec4xInt8",
|
||||
"Vec8xInt8",
|
||||
"Vec16xInt8",
|
||||
"Vec32xInt8",
|
||||
"Vec64xInt8",
|
||||
"Vec2xInt16",
|
||||
"Vec4xInt16",
|
||||
"Vec8xInt16",
|
||||
"Vec16xInt16",
|
||||
"Vec32xInt16",
|
||||
"Vec64xInt16",
|
||||
"Vec2xInt32",
|
||||
"Vec4xInt32",
|
||||
"Vec8xInt32",
|
||||
"Vec16xInt32",
|
||||
"Vec32xInt32",
|
||||
"Vec64xInt32",
|
||||
"Vec2xInt64",
|
||||
"Vec4xInt64",
|
||||
"Vec8xInt64",
|
||||
"Vec16xInt64",
|
||||
"Vec32xInt64",
|
||||
"Vec64xInt64",
|
||||
"Vec2xFPIEEE16",
|
||||
"Vec4xFPIEEE16",
|
||||
"Vec8xFPIEEE16",
|
||||
"Vec16xFPIEEE16",
|
||||
"Vec32xFPIEEE16",
|
||||
"Vec64xFPIEEE16",
|
||||
"Vec2xFPIEEE32",
|
||||
"Vec4xFPIEEE32",
|
||||
"Vec8xFPIEEE32",
|
||||
"Vec16xFPIEEE32",
|
||||
"Vec32xFPIEEE32",
|
||||
"Vec64xFPIEEE32",
|
||||
"Vec2xFPIEEE64",
|
||||
"Vec4xFPIEEE64",
|
||||
"Vec8xFPIEEE64",
|
||||
"Vec16xFPIEEE64",
|
||||
"Vec32xFPIEEE64",
|
||||
"Vec64xFPIEEE64",
|
||||
}) {
|
||||
builtinModule.lookupValue(builtinModule.getASTContext().getIdentifier(symbol),
|
||||
|
||||
@@ -264,6 +264,17 @@ std::optional<codeql::ModuleDecl> DeclVisitor::translateModuleDecl(const swift::
|
||||
}
|
||||
entry->is_builtin_module = decl.isBuiltinModule();
|
||||
entry->is_system_module = decl.isSystemModule();
|
||||
using K = swift::ModuleDecl::ImportFilterKind;
|
||||
llvm::SmallVector<swift::ImportedModule> imports;
|
||||
decl.getImportedModules(imports, K::Default);
|
||||
for (const auto& import : imports) {
|
||||
entry->imported_modules.push_back(dispatcher_.fetchLabel(import.importedModule));
|
||||
}
|
||||
imports.clear();
|
||||
decl.getImportedModules(imports, K::Exported);
|
||||
for (const auto& import : imports) {
|
||||
entry->exported_modules.push_back(dispatcher_.fetchLabel(import.importedModule));
|
||||
}
|
||||
fillTypeDecl(decl, *entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
| file://:0:0:0:0 | Foo | getModule: | file://:0:0:0:0 | Foo | getInterfaceType: | module<Foo> | getName: | Foo | isBuiltinModule: | no | isSystemModule: | no |
|
||||
| file://:0:0:0:0 | __ObjC | getModule: | file://:0:0:0:0 | __ObjC | getInterfaceType: | module<__ObjC> | getName: | __ObjC | isBuiltinModule: | no | isSystemModule: | no |
|
||||
| file://:0:0:0:0 | default_module_name | getModule: | file://:0:0:0:0 | default_module_name | getInterfaceType: | module<default_module_name> | getName: | default_module_name | isBuiltinModule: | no | isSystemModule: | no |
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
| file://:0:0:0:0 | Foo | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | Foo | 1 | file://:0:0:0:0 | _Concurrency |
|
||||
| file://:0:0:0:0 | Foo | 2 | file://:0:0:0:0 | SwiftOnoneSupport |
|
||||
| file://:0:0:0:0 | __ObjC | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | default_module_name | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | default_module_name | 1 | file://:0:0:0:0 | _Concurrency |
|
||||
| file://:0:0:0:0 | default_module_name | 2 | file://:0:0:0:0 | SwiftOnoneSupport |
|
||||
@@ -0,0 +1 @@
|
||||
| file://:0:0:0:0 | Foo | 0 | file://:0:0:0:0 | Swift |
|
||||
@@ -0,0 +1,7 @@
|
||||
| file://:0:0:0:0 | Foo | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | Foo | 1 | file://:0:0:0:0 | _Concurrency |
|
||||
| file://:0:0:0:0 | Foo | 2 | file://:0:0:0:0 | SwiftOnoneSupport |
|
||||
| file://:0:0:0:0 | __ObjC | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | default_module_name | 0 | file://:0:0:0:0 | Swift |
|
||||
| file://:0:0:0:0 | default_module_name | 1 | file://:0:0:0:0 | _Concurrency |
|
||||
| file://:0:0:0:0 | default_module_name | 2 | file://:0:0:0:0 | SwiftOnoneSupport |
|
||||
@@ -1 +1,2 @@
|
||||
//codeql-extractor-options: -module-name Foo
|
||||
@_exported import Swift
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
| Builtin.BridgeObject | getName: | Builtin.BridgeObject | getCanonicalType: | Builtin.BridgeObject |
|
||||
| Builtin.Executor | getName: | Builtin.Executor | getCanonicalType: | Builtin.Executor |
|
||||
| Builtin.FPIEEE32 | getName: | Builtin.FPIEEE32 | getCanonicalType: | Builtin.FPIEEE32 |
|
||||
| Builtin.FPIEEE64 | getName: | Builtin.FPIEEE64 | getCanonicalType: | Builtin.FPIEEE64 |
|
||||
| Builtin.IntLiteral | getName: | Builtin.IntLiteral | getCanonicalType: | Builtin.IntLiteral |
|
||||
| Builtin.Job | getName: | Builtin.Job | getCanonicalType: | Builtin.Job |
|
||||
| Builtin.NativeObject | getName: | Builtin.NativeObject | getCanonicalType: | Builtin.NativeObject |
|
||||
| Builtin.RawPointer | getName: | Builtin.RawPointer | getCanonicalType: | Builtin.RawPointer |
|
||||
| Builtin.RawUnsafeContinuation | getName: | Builtin.RawUnsafeContinuation | getCanonicalType: | Builtin.RawUnsafeContinuation |
|
||||
|
||||
@@ -5,5 +5,8 @@ func foo(
|
||||
_: Builtin.FPIEEE64,
|
||||
_: Builtin.BridgeObject,
|
||||
_: Builtin.NativeObject,
|
||||
_: Builtin.RawPointer
|
||||
_: Builtin.RawPointer,
|
||||
_: Builtin.Executor,
|
||||
_: Builtin.Job,
|
||||
_: Builtin.RawUnsafeContinuation
|
||||
) {}
|
||||
|
||||
Reference in New Issue
Block a user