Skip to content

Commit 683ecc3

Browse files
committed
Rust: Adjust some generated Impl files
1 parent 4dd3059 commit 683ecc3

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

rust/codegen.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# configuration file for Swift code generation default options
1+
# configuration file for Rust code generation default options
22
--generate=dbscheme,rusttest,ql,rust
33
--dbscheme=ql/lib/rust.dbscheme
44
--ql-output=ql/lib/codeql/rust/generated

rust/ql/.generated.list

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/.gitattributes

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/ElementImpl.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `Element`.
43
*
@@ -12,5 +11,9 @@ private import codeql.rust.generated.Element
1211
* be referenced directly.
1312
*/
1413
module Impl {
15-
class Element extends Generated::Element { }
14+
class Element extends Generated::Element {
15+
override string toString() { result = this.getAPrimaryQlClass() }
16+
17+
predicate isUnknown() { none() } // compatibility with test generation, to be fixed
18+
}
1619
}

rust/ql/lib/codeql/rust/elements/FunctionImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `Function`.
43
*
@@ -12,6 +11,7 @@ private import codeql.rust.generated.Function
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A function declaration. For example
1717
* ```
@@ -24,5 +24,7 @@ module Impl {
2424
* }
2525
* ```
2626
*/
27-
class Function extends Generated::Function { }
27+
class Function extends Generated::Function {
28+
override string toString() { result = this.getName() }
29+
}
2830
}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
// generated by codegen, remove this comment if you wish to edit this file
21
/**
32
* This module provides a hand-modifiable wrapper around the generated class `Locatable`.
43
*
54
* INTERNAL: Do not use.
65
*/
76

87
private import codeql.rust.generated.Locatable
8+
import codeql.Locations
9+
private import codeql.rust.generated.Synth
10+
private import codeql.rust.generated.Raw
911

1012
/**
1113
* INTERNAL: This module contains the customizable definition of `Locatable` and should not
1214
* be referenced directly.
1315
*/
1416
module Impl {
15-
class Locatable extends Generated::Locatable { }
17+
class Locatable extends Generated::Locatable {
18+
pragma[nomagic]
19+
final Location getLocation() {
20+
exists(Raw::Locatable raw |
21+
raw = Synth::convertLocatableToRaw(this) and
22+
(
23+
locatable_locations(raw, result)
24+
or
25+
not exists(Location loc | locatable_locations(raw, loc)) and
26+
result instanceof EmptyLocation
27+
)
28+
)
29+
}
30+
31+
/**
32+
* Gets the primary file where this element occurs.
33+
*/
34+
File getFile() { result = this.getLocation().getFile() }
35+
}
1636
}

0 commit comments

Comments
 (0)