mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
This checks in the trapgen script generating trap entries in C++. The codegen suite has been slightly reorganized, moving the templates directory up one level and chopping everything into smaller bazel packages. Running tests is now done via ``` bazel run //swift/codegen/test ``` With respect to the PoC, the nested `codeql::trap` namespace has been dropped in favour of a `Trap` prefix (or suffix in case of entries) within the `codeql` namespace. Also, generated C++ code is not checked in in git any more, and generated during build. Finally, labels get printed in hex in the trap file. `TrapLabel` is for the moment only default-constructible, so only one single label is possible. `TrapArena`, that is responsible for creating disjoint labels will come in a later commit.
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
// generated by {{generator}}
|
|
{{#imports}}
|
|
import {{.}}
|
|
{{/imports}}
|
|
|
|
class {{name}}Base extends {{db_id}}{{#bases}}, {{.}}{{/bases}} {
|
|
{{#root}}
|
|
string toString() { none() } // overridden by subclasses
|
|
|
|
{{name}}Base getResolveStep() { none() } // overridden by subclasses
|
|
|
|
{{name}}Base resolve() {
|
|
not exists(getResolveStep()) and result = this
|
|
or
|
|
result = getResolveStep().resolve()
|
|
}
|
|
{{/root}}
|
|
{{#final}}
|
|
override string toString() { result = "{{name}}" }
|
|
{{/final}}
|
|
{{#properties}}
|
|
|
|
{{#type_is_class}}
|
|
{{type}} get{{singular}}({{#params}}{{^first}}, {{/first}}{{type}} {{param}}{{/params}}) {
|
|
exists({{type}} {{local_var}} |
|
|
{{tablename}}({{#tableparams}}{{^first}}, {{/first}}{{param}}{{/tableparams}})
|
|
and
|
|
result = {{local_var}}.resolve())
|
|
}
|
|
{{/type_is_class}}
|
|
{{^type_is_class}}
|
|
{{type}} get{{singular}}({{#params}}{{^first}}, {{/first}}{{type}} {{param}}{{/params}}) {
|
|
{{tablename}}({{#tableparams}}{{^first}}, {{/first}}{{param}}{{/tableparams}})
|
|
}
|
|
{{/type_is_class}}
|
|
{{#indefinite_article}}
|
|
|
|
{{type}} get{{.}}{{singular}}() {
|
|
result = get{{singular}}({{#params}}{{^first}}, {{/first}}_{{/params}})
|
|
}
|
|
|
|
int getNumberOf{{plural}}() {
|
|
result = count(get{{.}}{{singular}}())
|
|
}
|
|
{{/indefinite_article}}
|
|
{{/properties}}
|
|
}
|