Skip to content

Commit 9cd2ae2

Browse files
committed
Swift: rename Synth conversion functions
1 parent 98819f6 commit 9cd2ae2

File tree

138 files changed

+1729
-1391
lines changed

Some content is hidden

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

138 files changed

+1729
-1391
lines changed

swift/codegen/templates/ql_class.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class {{name}}Base extends Synth::T{{name}}{{#bases}}, {{.}}{{/bases}} {
2929
{{#type_is_class}}
3030
{{type}} getImmediate{{singular}}({{#is_repeated}}int index{{/is_repeated}}) {
3131
{{^ipa}}
32-
result = Synth::fromRaw{{type}}(Synth::toRaw{{name}}(this){{^root}}.(Raw::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}}))
32+
result = Synth::convert{{type}}FromRaw(Synth::convert{{name}}ToRaw(this){{^root}}.(Raw::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}}))
3333
{{/ipa}}
3434
{{#ipa}}
3535
none()
@@ -44,7 +44,7 @@ class {{name}}Base extends Synth::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}}Synth::toRaw{{name}}(this){{^root}}.(Raw::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}})
47+
{{^is_predicate}}result = {{/is_predicate}}Synth::convert{{name}}ToRaw(this){{^root}}.(Raw::{{name}}){{/root}}.{{getter}}({{#is_repeated}}index{{/is_repeated}})
4848
{{/ipa}}
4949
{{#ipa}}
5050
none()

swift/codegen/templates/ql_ipa_types.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cached module Synth {
1717
{{/non_final_classes}}
1818

1919
{{#final_classes}}
20-
cached T{{name}} fromRaw{{name}}(Raw::Element e) {
20+
cached T{{name}} convert{{name}}FromRaw(Raw::Element e) {
2121
{{^is_fresh_ipa}}
2222
result = T{{name}}(e)
2323
{{/is_fresh_ipa}}
@@ -28,18 +28,18 @@ cached module Synth {
2828
{{/final_classes}}
2929

3030
{{#non_final_classes}}
31-
cached T{{name}} fromRaw{{name}}(Raw::Element e) {
31+
cached T{{name}} convert{{name}}FromRaw(Raw::Element e) {
3232
{{#derived}}
3333
{{^first}}
3434
or
3535
{{/first}}
36-
result = fromRaw{{name}}(e)
36+
result = convert{{name}}FromRaw(e)
3737
{{/derived}}
3838
}
3939
{{/non_final_classes}}
4040

4141
{{#final_classes}}
42-
cached Raw::Element toRaw{{name}}(T{{name}} e) {
42+
cached Raw::Element convert{{name}}ToRaw(T{{name}} e) {
4343
{{^is_fresh_ipa}}
4444
e = T{{name}}(result)
4545
{{/is_fresh_ipa}}
@@ -50,12 +50,12 @@ cached module Synth {
5050
{{/final_classes}}
5151

5252
{{#non_final_classes}}
53-
cached Raw::Element toRaw{{name}}(T{{name}} e) {
53+
cached Raw::Element convert{{name}}ToRaw(T{{name}} e) {
5454
{{#derived}}
5555
{{^first}}
5656
or
5757
{{/first}}
58-
result = toRaw{{name}}(e)
58+
result = convert{{name}}ToRaw(e)
5959
{{/derived}}
6060
}
6161
{{/non_final_classes}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private module JoinBlockPredecessors {
202202
private predicate idOfDbAstNode(Raw::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(Synth::toRawAstNode(x), y) }
205+
private predicate idOf(AstNode x, int y) { idOfDbAstNode(Synth::convertAstNodeToRaw(x), y) }
206206

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

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import codeql.swift.elements.decl.ParamDecl
77

88
class CallableBase extends Synth::TCallable, Element {
99
ParamDecl getImmediateParam(int index) {
10-
result = Synth::fromRawParamDecl(Synth::toRawCallable(this).(Raw::Callable).getParam(index))
10+
result =
11+
Synth::convertParamDeclFromRaw(Synth::convertCallableToRaw(this)
12+
.(Raw::Callable)
13+
.getParam(index))
1114
}
1215

1316
final ParamDecl getParam(int index) { result = getImmediateParam(index).resolve() }
@@ -17,7 +20,8 @@ class CallableBase extends Synth::TCallable, Element {
1720
final int getNumberOfParams() { result = count(getAParam()) }
1821

1922
BraceStmt getImmediateBody() {
20-
result = Synth::fromRawBraceStmt(Synth::toRawCallable(this).(Raw::Callable).getBody())
23+
result =
24+
Synth::convertBraceStmtFromRaw(Synth::convertCallableToRaw(this).(Raw::Callable).getBody())
2125
}
2226

2327
final BraceStmt getBody() { result = getImmediateBody().resolve() }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import codeql.swift.elements.Locatable
66
class CommentBase extends Synth::TComment, Locatable {
77
override string getAPrimaryQlClass() { result = "Comment" }
88

9-
string getText() { result = Synth::toRawComment(this).(Raw::Comment).getText() }
9+
string getText() { result = Synth::convertCommentToRaw(this).(Raw::Comment).getText() }
1010
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ class ElementBase extends Synth::TElement {
1717
result = getResolveStep().resolve()
1818
}
1919

20-
predicate isUnknown() { Synth::toRawElement(this).isUnknown() }
20+
predicate isUnknown() { Synth::convertElementToRaw(this).isUnknown() }
2121
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ private import codeql.swift.generated.Raw
44
import codeql.swift.elements.Element
55

66
class FileBase extends Synth::TFile, Element {
7-
string getName() { result = Synth::toRawFile(this).(Raw::File).getName() }
7+
string getName() { result = Synth::convertFileToRaw(this).(Raw::File).getName() }
88
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import codeql.swift.elements.Location
66

77
class LocatableBase extends Synth::TLocatable, Element {
88
Location getImmediateLocation() {
9-
result = Synth::fromRawLocation(Synth::toRawLocatable(this).(Raw::Locatable).getLocation())
9+
result =
10+
Synth::convertLocationFromRaw(Synth::convertLocatableToRaw(this)
11+
.(Raw::Locatable)
12+
.getLocation())
1013
}
1114

1215
final Location getLocation() { result = getImmediateLocation().resolve() }

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import codeql.swift.elements.File
66

77
class LocationBase extends Synth::TLocation, Element {
88
File getImmediateFile() {
9-
result = Synth::fromRawFile(Synth::toRawLocation(this).(Raw::Location).getFile())
9+
result = Synth::convertFileFromRaw(Synth::convertLocationToRaw(this).(Raw::Location).getFile())
1010
}
1111

1212
final File getFile() { result = getImmediateFile().resolve() }
1313

14-
int getStartLine() { result = Synth::toRawLocation(this).(Raw::Location).getStartLine() }
14+
int getStartLine() { result = Synth::convertLocationToRaw(this).(Raw::Location).getStartLine() }
1515

16-
int getStartColumn() { result = Synth::toRawLocation(this).(Raw::Location).getStartColumn() }
16+
int getStartColumn() {
17+
result = Synth::convertLocationToRaw(this).(Raw::Location).getStartColumn()
18+
}
1719

18-
int getEndLine() { result = Synth::toRawLocation(this).(Raw::Location).getEndLine() }
20+
int getEndLine() { result = Synth::convertLocationToRaw(this).(Raw::Location).getEndLine() }
1921

20-
int getEndColumn() { result = Synth::toRawLocation(this).(Raw::Location).getEndColumn() }
22+
int getEndColumn() { result = Synth::convertLocationToRaw(this).(Raw::Location).getEndColumn() }
2123
}

0 commit comments

Comments
 (0)