Skip to content

Commit fdd975b

Browse files
authored
Merge pull request github#12842 from github/redsun82/swift-qlgen-qldoc
Swift: add QLdoc for generated `Raw` and `Synth` modules
2 parents 4e49df1 + edb355b commit fdd975b

File tree

5 files changed

+4106
-2
lines changed

5 files changed

+4106
-2
lines changed

misc/codegen/templates/ql_db.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
/**
2+
* INTERNAL: Do not use.
3+
* This module holds thin fully generated class definitions around DB entities.
4+
*/
15
module Raw {
26
{{#classes}}
7+
/**
8+
* INTERNAL: Do not use.
9+
{{#doc}}
10+
* {{.}}
11+
{{/doc}}
12+
*/
313
class {{name}} extends {{db_id}}{{#bases}}, {{.}}{{/bases}} {
414
{{#root}}string toString() { none() }{{/root}}
515
{{#final}}override string toString() { result = "{{name}}" }{{/final}}

misc/codegen/templates/ql_ipa_types.mustache

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
1+
/**
2+
* INTERNAL: Do not use.
3+
* This module defines the IPA layer on top of raw DB entities, and the conversions between the two
4+
* layers.
5+
*/
6+
17
private import {{import_prefix}}.SynthConstructors
28
private import {{import_prefix}}.Raw
39

410
cached module Synth {
11+
/**
12+
* INTERNAL: Do not use.
13+
* The synthesized type of all elements.
14+
*/
515
cached newtype T{{root}} =
616
{{#final_classes}}
717
{{^first}}
818
or
919
{{/first}}
20+
/**
21+
* INTERNAL: Do not use.
22+
*/
1023
T{{name}}({{#params}}{{^first}}, {{/first}}{{type}} {{param}}{{/params}}){{#has_params}} { construct{{name}}({{#params}}{{^first}}, {{/first}}{{param}}{{/params}}) }{{/has_params}}
1124
{{/final_classes}}
1225

1326
{{#non_final_classes}}
1427
{{^root}}
28+
/**
29+
* INTERNAL: Do not use.
30+
*/
1531
class T{{name}} = {{#derived}}{{^first}} or {{/first}}T{{name}}{{/derived}};
1632
{{/root}}
1733
{{/non_final_classes}}
1834

1935
{{#final_classes}}
36+
/**
37+
* INTERNAL: Do not use.
38+
* Converts a raw element to a synthesized `T{{name}}`, if possible.
39+
*/
2040
cached T{{name}} convert{{name}}FromRaw(Raw::Element e) {
2141
{{^is_fresh_ipa}}
2242
result = T{{name}}(e)
@@ -28,6 +48,10 @@ cached module Synth {
2848
{{/final_classes}}
2949

3050
{{#non_final_classes}}
51+
/**
52+
* INTERNAL: Do not use.
53+
* Converts a raw DB element to a synthesized `T{{name}}`, if possible.
54+
*/
3155
cached T{{name}} convert{{name}}FromRaw(Raw::Element e) {
3256
{{#derived}}
3357
{{^first}}
@@ -39,6 +63,10 @@ cached module Synth {
3963
{{/non_final_classes}}
4064

4165
{{#final_classes}}
66+
/**
67+
* INTERNAL: Do not use.
68+
* Converts a synthesized `T{{name}}` to a raw DB element, if possible.
69+
*/
4270
cached Raw::Element convert{{name}}ToRaw(T{{name}} e) {
4371
{{^is_fresh_ipa}}
4472
e = T{{name}}(result)
@@ -50,6 +78,10 @@ cached module Synth {
5078
{{/final_classes}}
5179

5280
{{#non_final_classes}}
81+
/**
82+
* INTERNAL: Do not use.
83+
* Converts a synthesized `T{{name}}` to a raw DB element, if possible.
84+
*/
5385
cached Raw::Element convert{{name}}ToRaw(T{{name}} e) {
5486
{{#derived}}
5587
{{^first}}

swift/ql/.generated.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ ql/lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0
386386
ql/lib/codeql/swift/generated/ParentChild.qll 3998d73048297cf2df42176b0060c025e57d409d56f3fbfab9c202bd46c07b5e 425b01328baf38bd5e46403e11b25b0e17cd5bc40731dbf64a46e01604611e15
387387
ql/lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0
388388
ql/lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
389-
ql/lib/codeql/swift/generated/Raw.qll 16ef0c379f1b3ceb73df393a34b8d2c5c4fb180e337fb3b8f33078fa9d827b7e 4b608cd9fc3f425fc568322ae17036e6407a54d0a6a30ff03fe04942f4ef897f
390-
ql/lib/codeql/swift/generated/Synth.qll 1b60c8eab214c8f9a3a1fb39a8785979bc3d86f2615ba0a580c35e17fd496851 052940a87ffb32214b1b3c774bc643aa5d4f31c484d3121b4da384c2839cb10b
389+
ql/lib/codeql/swift/generated/Raw.qll cda40b44e2b72ceb32a3c03d2f16028fc4db723c8cdc0a9638693794f4f07411 eb4b59f4dbd2159f59132994e6d1840a1273e5c316232b8439ddc0cc08ef8736
390+
ql/lib/codeql/swift/generated/Synth.qll e26debaea7feaabbdd4180983a03fa406584e2a0dc4902520d5549d106770fee a448e51acba628d63fc4ae59aa23efa7cd5b567230ae24749d31d2a4ad51baf9
391391
ql/lib/codeql/swift/generated/SynthConstructors.qll bb0c69cea79a06ec3cc0e176fc6e63cfe125107a45373e41083fc4de056133b8 bb0c69cea79a06ec3cc0e176fc6e63cfe125107a45373e41083fc4de056133b8
392392
ql/lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
393393
ql/lib/codeql/swift/generated/UnknownLocation.qll e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882 e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882

0 commit comments

Comments
 (0)