Skip to content

Commit 5bad696

Browse files
committed
Swift: remove unused no-parameter constructors
1 parent 9de5985 commit 5bad696

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

swift/codegen/generators/qlgen.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,14 @@ def generate(opts, renderer):
279279
ipa_type = get_ql_ipa_class(cls)
280280
if ipa_type.is_final:
281281
final_ipa_types.append(ipa_type)
282-
stub_file = stub_out / cls.dir / f"{cls.name}Constructor.qll"
283-
if not stub_file.is_file() or _is_generated_stub(stub_file):
284-
renderer.render(ql.Synth.ConstructorStub(ipa_type), stub_file)
285-
constructor_import = get_import(stub_file, opts.swift_dir)
286-
constructor_imports.append(constructor_import)
287-
if ipa_type.is_ipa:
288-
ipa_constructor_imports.append(constructor_import)
282+
if ipa_type.has_params:
283+
stub_file = stub_out / cls.dir / f"{cls.name}Constructor.qll"
284+
if not stub_file.is_file() or _is_generated_stub(stub_file):
285+
renderer.render(ql.Synth.ConstructorStub(ipa_type), stub_file)
286+
constructor_import = get_import(stub_file, opts.swift_dir)
287+
constructor_imports.append(constructor_import)
288+
if ipa_type.is_ipa:
289+
ipa_constructor_imports.append(constructor_import)
289290
else:
290291
non_final_ipa_types.append(ipa_type)
291292

swift/ql/lib/codeql/swift/elements/UnknownFileConstructor.qll

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
21
private import codeql.swift.generated.Raw
32

4-
predicate constructUnknownLocation() { none() }
3+
predicate constructUnknownLocation() { any() }
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1+
12
// generated by codegen/codegen.py
2-
import codeql.swift.elements.UnknownFileConstructor
3-
import codeql.swift.elements.UnknownLocationConstructor

swift/ql/lib/codeql/swift/generated/SynthConstructors.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import codeql.swift.elements.CommentConstructor
33
import codeql.swift.elements.DbFileConstructor
44
import codeql.swift.elements.DbLocationConstructor
5-
import codeql.swift.elements.UnknownFileConstructor
6-
import codeql.swift.elements.UnknownLocationConstructor
75
import codeql.swift.elements.decl.AccessorDeclConstructor
86
import codeql.swift.elements.decl.AssociatedTypeDeclConstructor
97
import codeql.swift.elements.decl.ClassDeclConstructor

0 commit comments

Comments
 (0)