Skip to content

Commit 9347030

Browse files
committed
Swift: rename Ipa to Synth
1 parent 6dc90bc commit 9347030

File tree

300 files changed

+896
-839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+896
-839
lines changed

swift/codegen/generators/qlgen.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ def _to_db_type(x: str) -> str:
9191

9292
def get_ql_ipa_class(cls: schema.Class):
9393
if cls.derived:
94-
return ql.Ipa.NonFinalClass(name=cls.name, derived=sorted(cls.derived),
95-
root=(cls.name == schema.root_class_name))
94+
return ql.Synth.NonFinalClass(name=cls.name, derived=sorted(cls.derived),
95+
root=(cls.name == schema.root_class_name))
9696
if cls.ipa and cls.ipa.from_class is not None:
9797
source = cls.ipa.from_class
98-
_final_db_class_lookup.setdefault(source, ql.Ipa.FinalClassDb(source)).subtract_type(cls.name)
99-
return ql.Ipa.FinalClassDerivedIpa(name=cls.name, params=[ql.Ipa.Param("id", _to_db_type(source))])
98+
_final_db_class_lookup.setdefault(source, ql.Synth.FinalClassDb(source)).subtract_type(cls.name)
99+
return ql.Synth.FinalClassDerivedIpa(name=cls.name, params=[ql.Synth.Param("id", _to_db_type(source))])
100100
if cls.ipa and cls.ipa.on_arguments is not None:
101-
return ql.Ipa.FinalClassFreshIpa(name=cls.name, params=[ql.Ipa.Param(k, _to_db_type(v)) for k, v in
102-
cls.ipa.on_arguments.items()])
103-
return _final_db_class_lookup.setdefault(cls.name, ql.Ipa.FinalClassDb(cls.name))
101+
return ql.Synth.FinalClassFreshIpa(name=cls.name, params=[ql.Synth.Param(k, _to_db_type(v)) for k, v in
102+
cls.ipa.on_arguments.items()])
103+
return _final_db_class_lookup.setdefault(cls.name, ql.Synth.FinalClassDb(cls.name))
104104

105105

106106
def get_import(file: pathlib.Path, swift_dir: pathlib.Path):
@@ -275,13 +275,13 @@ def generate(opts, renderer):
275275
if ipa_type.is_ipa and ipa_type.has_params:
276276
stub_file = stub_out / cls.dir / f"{cls.name}Constructor.qll"
277277
if not stub_file.is_file() or _is_generated_stub(stub_file):
278-
renderer.render(ql.Ipa.ConstructorStub(ipa_type), stub_file)
278+
renderer.render(ql.Synth.ConstructorStub(ipa_type), stub_file)
279279
constructor_imports.append(get_import(stub_file, opts.swift_dir))
280280
else:
281281
non_final_ipa_types.append(ipa_type)
282282

283-
renderer.render(ql.Ipa.Types(schema.root_class_name, final_ipa_types, non_final_ipa_types), out / "Ipa.qll")
284-
renderer.render(ql.ImportList(constructor_imports), out / "IpaConstructors.qll")
283+
renderer.render(ql.Synth.Types(schema.root_class_name, final_ipa_types, non_final_ipa_types), out / "Synth.qll")
284+
renderer.render(ql.ImportList(constructor_imports), out / "SynthConstructors.qll")
285285

286286
renderer.cleanup(existing)
287287
if opts.ql_format:

swift/codegen/lib/ql.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class MissingTestInstructions:
158158
template: ClassVar = 'ql_test_missing'
159159

160160

161-
class Ipa:
161+
class Synth:
162162
@dataclass
163163
class Class:
164164
is_final: ClassVar = False
@@ -185,7 +185,7 @@ class Param:
185185

186186
@dataclass
187187
class FinalClassIpa(FinalClass):
188-
params: List["Ipa.Param"] = field(default_factory=list)
188+
params: List["Synth.Param"] = field(default_factory=list)
189189

190190
def __post_init__(self):
191191
if self.params:
@@ -207,10 +207,10 @@ class FinalClassFreshIpa(FinalClassIpa):
207207
class FinalClassDb(FinalClass):
208208
is_db: ClassVar = True
209209

210-
subtracted_ipa_types: List["Ipa.Class"] = field(default_factory=list)
210+
subtracted_ipa_types: List["Synth.Class"] = field(default_factory=list)
211211

212212
def subtract_type(self, type: str):
213-
self.subtracted_ipa_types.append(Ipa.Class(type, first=not self.subtracted_ipa_types))
213+
self.subtracted_ipa_types.append(Synth.Class(type, first=not self.subtracted_ipa_types))
214214

215215
@property
216216
def has_subtracted_ipa_types(self) -> bool:
@@ -222,11 +222,11 @@ def db_id(self) -> str:
222222

223223
@dataclass
224224
class NonFinalClass(Class):
225-
derived: List["Ipa.Class"] = field(default_factory=list)
225+
derived: List["Synth.Class"] = field(default_factory=list)
226226
root: bool = False
227227

228228
def __post_init__(self):
229-
self.derived = [Ipa.Class(c) for c in self.derived]
229+
self.derived = [Synth.Class(c) for c in self.derived]
230230
if self.derived:
231231
self.derived[0].first = True
232232

@@ -235,8 +235,8 @@ class Types:
235235
template: ClassVar = "ql_ipa_types"
236236

237237
root: str
238-
final_classes: List["Ipa.FinalClass"] = field(default_factory=list)
239-
non_final_classes: List["Ipa.NonFinalClass"] = field(default_factory=list)
238+
final_classes: List["Synth.FinalClass"] = field(default_factory=list)
239+
non_final_classes: List["Synth.NonFinalClass"] = field(default_factory=list)
240240

241241
def __post_init__(self):
242242
if self.final_classes:
@@ -246,4 +246,4 @@ def __post_init__(self):
246246
class ConstructorStub:
247247
template: ClassVar = "ql_ipa_constructor_stub"
248248

249-
cls: Union["Ipa.FinalClassDerivedIpa", "Ipa.FinalClassFreshIpa"]
249+
cls: Union["Synth.FinalClassDerivedIpa", "Synth.FinalClassFreshIpa"]

swift/codegen/lib/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def load(path):
160160
cls.properties.extend(_parse_property(kk, vv, is_child=True) for kk, vv in v.items())
161161
elif k == "_pragma":
162162
cls.pragmas = _auto_list(v)
163-
elif k == "_ipa":
163+
elif k == "_synth":
164164
cls.ipa = _parse_ipa(v)
165165
else:
166166
raise Error(f"unknown metadata {k} for class {name}")

swift/codegen/schema.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DbFile:
2626

2727
UnknownFile:
2828
_extends: File
29-
_ipa:
29+
_synth:
3030
on: {}
3131

3232
Locatable:
@@ -48,7 +48,7 @@ DbLocation:
4848

4949
UnknownLocation:
5050
_extends: Location
51-
_ipa:
51+
_synth:
5252
on: {}
5353

5454
Comment:
@@ -816,7 +816,7 @@ TryExpr:
816816

817817
#MethodCallExpr:
818818
# _extends: ApplyExpr
819-
# _ipa:
819+
# _synth:
820820
# from: CallExpr
821821
# qualifier: Expr
822822

swift/codegen/templates/ql_class.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// generated by {{generator}}
2-
private import codeql.swift.generated.Ipa
2+
private import codeql.swift.generated.Synth
33
private import codeql.swift.generated.Db
44
{{#imports}}
55
import {{.}}
66
{{/imports}}
77

8-
class {{name}}Base extends Ipa::T{{name}}{{#bases}}, {{.}}{{/bases}} {
8+
class {{name}}Base extends Synth::T{{name}}{{#bases}}, {{.}}{{/bases}} {
99
{{#root}}
1010
string toString() { none() } // overridden by subclasses
1111

@@ -29,7 +29,7 @@ class {{name}}Base extends Ipa::T{{name}}{{#bases}}, {{.}}{{/bases}} {
2929
{{#type_is_class}}
3030
{{type}} getImmediate{{singular}}({{#is_repeated}}int index{{/is_repeated}}) {
3131
{{^ipa}}
32-
result = Ipa::convert{{type}}FromDb(Ipa::convert{{name}}ToDb(this){{^root}}.(Db::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}}))
32+
result = Synth::convert{{type}}FromDb(Synth::convert{{name}}ToDb(this){{^root}}.(Db::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}}))
3333
{{/ipa}}
3434
{{#ipa}}
3535
none()
@@ -44,7 +44,7 @@ class {{name}}Base extends Ipa::T{{name}}{{#bases}}, {{.}}{{/bases}} {
4444
{{^type_is_class}}
4545
{{type}} {{getter}}({{#is_repeated}}int index{{/is_repeated}}) {
4646
{{^ipa}}
47-
{{^is_predicate}}result = {{/is_predicate}}Ipa::convert{{name}}ToDb(this){{^root}}.(Db::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}})
47+
{{^is_predicate}}result = {{/is_predicate}}Synth::convert{{name}}ToDb(this){{^root}}.(Db::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}})
4848
{{/ipa}}
4949
{{#ipa}}
5050
none()

swift/codegen/templates/ql_ipa_types.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
private import codeql.swift.generated.IpaConstructors
1+
private import codeql.swift.generated.SynthConstructors
22
private import codeql.swift.generated.Db
33

4-
cached module Ipa {
4+
cached module Synth {
55
cached newtype T{{root}} =
66
{{#final_classes}}
77
{{^first}}

swift/codegen/test/test_qlgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _filter_generated_classes(ret, output_test_files=False):
101101
str(f): ret[ql_test_output_path() / f]
102102
for f in test_files
103103
}
104-
base_files -= {pathlib.Path(f"{name}.qll") for name in ("Db", "Ipa", "IpaConstructors")}
104+
base_files -= {pathlib.Path(f"{name}.qll") for name in ("Db", "Synth", "SynthConstructors")}
105105
assert stub_files == base_files
106106
return {
107107
str(f): (ret[stub_path() / f], ret[ql_output_path() / f])
@@ -129,8 +129,8 @@ def test_empty(generate):
129129
assert generate([]) == {
130130
import_file(): ql.ImportList(),
131131
children_file(): ql.GetParentImplementation(),
132-
ql_output_path() / "Ipa.qll": ql.Ipa.Types(schema.root_class_name),
133-
ql_output_path() / "IpaConstructors.qll": ql.ImportList(),
132+
ql_output_path() / "Synth.qll": ql.Synth.Types(schema.root_class_name),
133+
ql_output_path() / "SynthConstructors.qll": ql.ImportList(),
134134
ql_output_path() / "Db.qll": ql.DbClasses(),
135135
ql_output_path() / "Db.qll": ql.DbClasses(),
136136
}

swift/codegen/test/test_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_class_with_unknown_metadata(load):
306306
def test_ipa_class_from(load):
307307
ret = load("""
308308
MyClass:
309-
_ipa:
309+
_synth:
310310
from: A
311311
""")
312312
assert ret.classes == {
@@ -318,7 +318,7 @@ def test_ipa_class_from(load):
318318
def test_ipa_class_on(load):
319319
ret = load("""
320320
MyClass:
321-
_ipa:
321+
_synth:
322322
on:
323323
x: A
324324
y: int
@@ -329,7 +329,7 @@ def test_ipa_class_on(load):
329329
}
330330

331331

332-
# TODO rejection tests and implementation for malformed `_ipa` clauses
332+
# TODO rejection tests and implementation for malformed `_synth` clauses
333333

334334

335335
if __name__ == '__main__':

swift/ql/lib/codeql/swift/controlflow/BasicBlocks.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ private import internal.ControlFlowElements
77
private import CfgNodes
88
private import SuccessorTypes
99
private import codeql.swift.generated.Db
10-
private import codeql.swift.generated.Ipa
10+
private import codeql.swift.generated.Synth
1111

1212
/**
1313
* A basic block, that is, a maximal straight-line sequence of control flow nodes
@@ -202,7 +202,7 @@ private module JoinBlockPredecessors {
202202
private predicate idOfDbAstNode(Db::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
203203

204204
// TODO does not work if fresh ipa entities (`ipa: on:`) turn out to be first of the block
205-
private predicate idOf(AstNode x, int y) { idOfDbAstNode(Ipa::convertAstNodeToDb(x), y) }
205+
private predicate idOf(AstNode x, int y) { idOfDbAstNode(Synth::convertAstNodeToDb(x), y) }
206206

207207
private AstNode projectToAst(ControlFlowElement n) {
208208
result = n.asAstNode()

swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
private import swift
3535
private import codeql.swift.controlflow.ControlFlowGraph
36-
private import codeql.swift.generated.Ipa
36+
private import codeql.swift.generated.Synth
3737
private import Completion
3838
private import Scope
3939
import ControlFlowGraphImplShared
@@ -380,9 +380,9 @@ module Stmts {
380380
* Control-flow for loops.
381381
*/
382382
module Loops {
383-
class ConditionalLoop = Ipa::TWhileStmt or Ipa::TRepeatWhileStmt;
383+
class ConditionalLoop = Synth::TWhileStmt or Synth::TRepeatWhileStmt;
384384

385-
class LoopStmt = Ipa::TForEachStmt or ConditionalLoop;
385+
class LoopStmt = Synth::TForEachStmt or ConditionalLoop;
386386

387387
abstract class LoopTree extends AstPreOrderTree {
388388
LoopTree() { ast instanceof ConditionalLoop }
@@ -1708,7 +1708,7 @@ module Exprs {
17081708

17091709
module Conversions {
17101710
class ConversionOrIdentity =
1711-
Ipa::TIdentityExpr or Ipa::TExplicitCastExpr or Ipa::TImplicitConversionExpr;
1711+
Synth::TIdentityExpr or Synth::TExplicitCastExpr or Synth::TImplicitConversionExpr;
17121712

17131713
abstract class ConversionOrIdentityTree extends AstStandardPostOrderTree {
17141714
ConversionOrIdentityTree() { ast instanceof ConversionOrIdentity }

0 commit comments

Comments
 (0)