Rust: Cache Element.toString

This commit is contained in:
Tom Hvitved
2025-03-11 10:54:06 +01:00
parent 9a8cb1a55b
commit d1ad65ae09
76 changed files with 117 additions and 84 deletions

View File

@@ -29,7 +29,15 @@ module Generated {
/**
* Gets the string representation of this element.
*/
string toString() { none() } // overridden by subclasses
cached
final string toString() { result = this.toStringImpl() }
/**
* INTERNAL: Do not use.
*
* Gets the string representation of this element.
*/
abstract string toStringImpl();
/**
* Gets the name of a primary CodeQL class to which this element belongs.

View File

@@ -504,7 +504,7 @@ lib/codeql/rust/elements/internal/generated/ConstParam.qll 310342603959a4d521418
lib/codeql/rust/elements/internal/generated/ContinueExpr.qll e2010feb14fb6edeb83a991d9357e50edb770172ddfde2e8670b0d3e68169f28 48d09d661e1443002f6d22b8710e22c9c36d9daa9cde09c6366a61e960d717cb
lib/codeql/rust/elements/internal/generated/Crate.qll 6d28f07d4ddaf077119590a007a8cfad0c86cf0efabbde689fb4092577b883df d43013163916aa83f281314a72d02d7566e1f505aa36cfd8060a760b06b02683
lib/codeql/rust/elements/internal/generated/DynTraitTypeRepr.qll a9d540717af1f00dbea1c683fd6b846cddfb2968c7f3e021863276f123337787 1972efb9bca7aae9a9708ca6dcf398e5e8c6d2416a07d525dba1649b80fbe4d1
lib/codeql/rust/elements/internal/generated/Element.qll fb483b636180c699181c8aff83bc471b2c416206694f7028c671015918547663 542d1b9ae80c997974c94db3655887186df3921a8fa3f565eaf292dcfdac3c4c
lib/codeql/rust/elements/internal/generated/Element.qll 69ce882811f2bef7e0a93c0a24494dd16120a108ba4180d455344e29144a98c4 7781bc5c69b5b08775902fcb97cb23f85359ef2303545afe9d44301b19024b3a
lib/codeql/rust/elements/internal/generated/Enum.qll 4f4cbc9cd758c20d476bc767b916c62ba434d1750067d0ffb63e0821bb95ec86 3da735d54022add50cec0217bbf8ec4cf29b47f4851ee327628bcdd6454989d0
lib/codeql/rust/elements/internal/generated/Expr.qll 5fa34f2ed21829a1509417440dae42d416234ff43433002974328e7aabb8f30f 46f3972c7413b7db28a3ea8acb5a50a74b6dd9b658e8725f6953a8829ac912f8
lib/codeql/rust/elements/internal/generated/ExprStmt.qll d1112230015fbeb216b43407a268dc2ccd0f9e0836ab2dca4800c51b38fa1d7d 4a80562dcc55efa5e72c6c3b1d6747ab44fe494e76faff2b8f6e9f10a4b08b5b

View File

@@ -22,6 +22,6 @@ module Impl {
* ```
*/
class ArrayListExpr extends Generated::ArrayListExpr {
override string toString() { result = "[...]" }
override string toStringImpl() { result = "[...]" }
}
}

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class ArrayRepeatExpr extends Generated::ArrayRepeatExpr {
override string toString() {
override string toStringImpl() {
result =
"[" + this.getRepeatOperand().toAbbreviatedString() + "; " +
this.getRepeatLength().toAbbreviatedString() + "]"

View File

@@ -22,6 +22,6 @@ module Impl {
* ```
*/
class AwaitExpr extends Generated::AwaitExpr {
override string toString() { result = "await " + this.getExpr().toAbbreviatedString() }
override string toStringImpl() { result = "await " + this.getExpr().toAbbreviatedString() }
}
}

View File

@@ -25,6 +25,6 @@ module Impl {
* ```
*/
class BecomeExpr extends Generated::BecomeExpr {
override string toString() { result = "become " + this.getExpr().toAbbreviatedString() }
override string toStringImpl() { result = "become " + this.getExpr().toAbbreviatedString() }
}
}

View File

@@ -23,6 +23,6 @@ module Impl {
* ```
*/
class BinaryExpr extends Generated::BinaryExpr {
override string toString() { result = "... " + this.getOperatorName() + " ..." }
override string toStringImpl() { result = "... " + this.getOperatorName() + " ..." }
}
}

View File

@@ -22,6 +22,6 @@ module Impl {
* ```
*/
class BoxPat extends Generated::BoxPat {
override string toString() { result = "box " + this.getPat().toAbbreviatedString() }
override string toStringImpl() { result = "box " + this.getPat().toAbbreviatedString() }
}
}

View File

@@ -104,14 +104,14 @@ module Impl {
)
}
override string toString() {
override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
}
private string toStringPart(int index) {
index = 0 and result = "break"
or
index = 1 and result = this.getLifetime().toString()
index = 1 and result = this.getLifetime().toStringImpl()
or
index = 2 and result = this.getExpr().toAbbreviatedString()
}

View File

@@ -34,7 +34,7 @@ module Impl {
* ```
*/
class CallExpr extends Generated::CallExpr {
override string toString() { result = this.getFunction().toAbbreviatedString() + "(...)" }
override string toStringImpl() { result = this.getFunction().toAbbreviatedString() + "(...)" }
override Callable getStaticTarget() { result = getResolvedFunction(this) }

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class CastExpr extends Generated::CastExpr {
override string toString() {
override string toStringImpl() {
result =
this.getExpr().toAbbreviatedString() + " as " + this.getTypeRepr().toAbbreviatedString()
}

View File

@@ -25,6 +25,6 @@ module Impl {
* ```
*/
class ClosureExpr extends Generated::ClosureExpr {
override string toString() { result = "|...| " + this.getBody().toAbbreviatedString() }
override string toStringImpl() { result = "|...| " + this.getBody().toAbbreviatedString() }
}
}

View File

@@ -20,7 +20,7 @@ module Impl {
* ```
*/
class Comment extends Generated::Comment {
override string toString() {
override string toStringImpl() {
result = this.getCommentMarker() + "..." + this.getCommentEndMarker()
}

View File

@@ -49,7 +49,7 @@ module Impl {
* ```
*/
class ContinueExpr extends Generated::ContinueExpr {
override string toString() {
override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
}

View File

@@ -12,7 +12,9 @@ private import codeql.rust.elements.internal.generated.Crate
*/
module Impl {
class Crate extends Generated::Crate {
override string toString() { result = strictconcat(int i | | this.toStringPart(i) order by i) }
override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i) order by i)
}
private string toStringPart(int i) {
i = 0 and result = "Crate("

View File

@@ -12,13 +12,13 @@ private import codeql.rust.elements.internal.generated.Element
*/
module Impl {
class Element extends Generated::Element {
override string toString() { result = this.getAPrimaryQlClass() }
override string toStringImpl() { result = this.getAPrimaryQlClass() }
/**
* INTERNAL: Do not use.
*
* Returns a string suitable to be inserted into the name of the parent. Typically `"..."`,
* but may be overridden by subclasses.
*
* INTERNAL: Do not use.
*/
string toAbbreviatedString() { result = "..." }

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class Enum extends Generated::Enum {
override string toString() { result = "enum " + this.getName().getText() }
override string toStringImpl() { result = "enum " + this.getName().getText() }
}
}

View File

@@ -12,7 +12,7 @@ private import codeql.rust.elements.internal.generated.ExtractorStep
*/
module Impl {
class ExtractorStep extends Generated::ExtractorStep {
override string toString() {
override string toStringImpl() {
result = this.getAction() + "(" + this.getFile().getAbsolutePath() + ")"
or
not this.hasFile() and result = this.getAction()

View File

@@ -28,7 +28,7 @@ module Impl {
/** Gets the tuple field that this access references, if any. */
TupleField getTupleField() { result = TypeInference::resolveTupleFieldExpr(this) }
override string toString() {
override string toStringImpl() {
exists(string abbr, string name |
abbr = this.getExpr().toAbbreviatedString() and
name = this.getNameRef().getText() and

View File

@@ -36,7 +36,7 @@ module Impl {
FormatArgument() { this = Synth::TFormatArgument(parent, index, kind, name, _, offset) }
override string toString() { result = name }
override string toStringImpl() { result = name }
override Format getParent() { result = Synth::TFormat(parent, index, _, _) }

View File

@@ -36,7 +36,7 @@ module Impl {
Format() { this = Synth::TFormat(parent, index, text, offset) }
override string toString() { result = text }
override string toStringImpl() { result = text }
override FormatArgsExpr getParent() { result = Synth::convertFormatArgsExprFromRaw(parent) }

View File

@@ -29,7 +29,7 @@ module Impl {
override Location getLocation() { result = argument.getLocation() }
override string toString() { result = this.getName() }
override string toStringImpl() { result = this.getName() }
/** Gets the name of the variable */
string getName() { result = argument.getName() }

View File

@@ -25,6 +25,6 @@ module Impl {
* ```
*/
class Function extends Generated::Function {
override string toString() { result = "fn " + this.getName().getText() }
override string toStringImpl() { result = "fn " + this.getName().getText() }
}
}

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class GenericArgList extends Generated::GenericArgList {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "<...>" }

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class GenericParamList extends Generated::GenericParamList {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "<...>" }

View File

@@ -28,7 +28,7 @@ module Impl {
* ```
*/
class IdentPat extends Generated::IdentPat {
override string toString() {
override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
}

View File

@@ -28,7 +28,9 @@ module Impl {
* ```
*/
class IfExpr extends Generated::IfExpr {
override string toString() { result = concat(int i | | this.toStringPart(i), " " order by i) }
override string toStringImpl() {
result = concat(int i | | this.toStringPart(i), " " order by i)
}
private string toStringPart(int index) {
index = 0 and result = "if"

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class Impl extends Generated::Impl {
override string toString() {
override string toStringImpl() {
exists(string trait |
(
trait = this.getTrait().toAbbreviatedString() + " for "

View File

@@ -20,7 +20,7 @@ module Impl {
* ```
*/
class IndexExpr extends Generated::IndexExpr {
override string toString() {
override string toStringImpl() {
result =
this.getBase().toAbbreviatedString() + "[" + this.getIndex().toAbbreviatedString() + "]"
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class InferTypeRepr extends Generated::InferTypeRepr {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "_" }
}

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class Label extends Generated::Label {
override string toString() { result = this.getText() }
override string toStringImpl() { result = this.getText() }
override string toAbbreviatedString() { result = this.getText() }

View File

@@ -16,7 +16,7 @@ module Impl {
* The base class for expressions that can be labeled (`LoopExpr`, `ForExpr`, `WhileExpr` or `BlockExpr`).
*/
class LabelableExpr extends Generated::LabelableExpr {
final override string toString() {
final override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class LetElse extends Generated::LetElse {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "else {...}" }
}

View File

@@ -21,7 +21,9 @@ module Impl {
* ```
*/
class LetExpr extends Generated::LetExpr {
override string toString() { result = concat(int i | | this.toStringPart(i), " " order by i) }
override string toStringImpl() {
result = concat(int i | | this.toStringPart(i), " " order by i)
}
private string toStringPart(int index) {
index = 0 and result = "let"

View File

@@ -26,7 +26,7 @@ module Impl {
* ```
*/
class LetStmt extends Generated::LetStmt {
override string toString() {
override string toStringImpl() {
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class Lifetime extends Generated::Lifetime {
override string toString() {
override string toStringImpl() {
result = "'" + this.getText()
or
not this.hasText() and result = "'_"

View File

@@ -26,7 +26,7 @@ module Impl {
* ```
*/
class LiteralExpr extends Generated::LiteralExpr {
override string toString() { result = this.getTrimmedText() }
override string toStringImpl() { result = this.getTrimmedText() }
override string toAbbreviatedString() { result = this.getTrimmedText() }

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class LiteralPat extends Generated::LiteralPat {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = this.getLiteral().getTrimmedText() }
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class MacroCall extends Generated::MacroCall {
override string toString() { result = this.getPath().toAbbreviatedString() + "!..." }
override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "!..." }
}
}

View File

@@ -28,7 +28,9 @@ module Impl {
* ```
*/
class MatchArm extends Generated::MatchArm {
override string toString() { result = concat(int i | | this.toStringPart(i), " " order by i) }
override string toStringImpl() {
result = concat(int i | | this.toStringPart(i), " " order by i)
}
private string toStringPart(int index) {
index = 0 and result = this.getPat().toAbbreviatedString()

View File

@@ -28,7 +28,7 @@ module Impl {
* ```
*/
class MatchExpr extends Generated::MatchExpr {
override string toString() {
override string toStringImpl() {
result = "match " + this.getScrutinee().toAbbreviatedString() + " { ... }"
}

View File

@@ -42,11 +42,11 @@ module Impl {
)
}
override string toString() {
override string toStringImpl() {
exists(string base, string separator |
base = this.getReceiver().toAbbreviatedString() and
(if base = "..." then separator = " ." else separator = ".") and
result = base + separator + this.getNameRef().toString() + "(...)"
result = base + separator + this.getNameRef().toStringImpl() + "(...)"
)
}
}

View File

@@ -24,6 +24,6 @@ module Impl {
* ```
*/
class Module extends Generated::Module {
override string toString() { result = "mod " + this.getName() }
override string toStringImpl() { result = "mod " + this.getName() }
}
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class Name extends Generated::Name {
override string toString() { result = this.getText() }
override string toStringImpl() { result = this.getText() }
}
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class NameRef extends Generated::NameRef {
override string toString() { result = this.getText() }
override string toStringImpl() { result = this.getText() }
}
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class NeverTypeRepr extends Generated::NeverTypeRepr {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "!" }
}

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class OrPat extends Generated::OrPat {
override string toString() {
override string toStringImpl() {
result = concat(int i | | this.getPat(i).toAbbreviatedString(), " | " order by i)
}

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class Param extends Generated::Param {
override string toString() { result = concat(int i | | this.toStringPart(i) order by i) }
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) {
index = 0 and result = this.getPat().toAbbreviatedString()

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class ParenExpr extends Generated::ParenExpr {
override string toString() { result = "(" + this.getExpr().toAbbreviatedString() + ")" }
override string toStringImpl() { result = "(" + this.getExpr().toAbbreviatedString() + ")" }
}
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class ParenPat extends Generated::ParenPat {
override string toString() { result = "(" + this.getPat().toAbbreviatedString() + ")" }
override string toStringImpl() { result = "(" + this.getPat().toAbbreviatedString() + ")" }
}
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class ParenTypeRepr extends Generated::ParenTypeRepr {
override string toString() { result = "(" + this.getTypeRepr().toAbbreviatedString() + ")" }
override string toStringImpl() { result = "(" + this.getTypeRepr().toAbbreviatedString() + ")" }
}
}

View File

@@ -22,8 +22,8 @@ module Impl {
* ```
*/
class PathExpr extends Generated::PathExpr {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = this.getPath().toString() }
override string toAbbreviatedString() { result = this.getPath().toStringImpl() }
}
}

View File

@@ -20,12 +20,19 @@ module Impl {
* ```
*/
class Path extends Generated::Path {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() {
if this.hasQualifier()
then result = "...::" + this.getPart().toAbbreviatedString()
else result = this.getPart().toAbbreviatedString()
result = strictconcat(int i | | this.toAbbreviatedStringPart(i) order by i)
}
private string toAbbreviatedStringPart(int index) {
index = 0 and
this.hasQualifier() and
result = "...::"
or
index = 1 and
result = this.getPart().toAbbreviatedString()
}
/**

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class PathPat extends Generated::PathPat {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = this.getPath().toAbbreviatedString() }
}

View File

@@ -16,7 +16,7 @@ module Impl {
* A path segment, which is one part of a whole path.
*/
class PathSegment extends Generated::PathSegment {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() {
result = strictconcat(int i | | this.toAbbreviatedStringPart(i), "::" order by i)

View File

@@ -20,7 +20,7 @@ module Impl {
* ```
*/
class PathTypeRepr extends Generated::PathTypeRepr {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = this.getPath().toAbbreviatedString() }
}

View File

@@ -21,6 +21,6 @@ module Impl {
* ```
*/
class PrefixExpr extends Generated::PrefixExpr {
override string toString() { result = this.getOperatorName() + " ..." }
override string toStringImpl() { result = this.getOperatorName() + " ..." }
}
}

View File

@@ -24,7 +24,7 @@ module Impl {
* ```
*/
class RangeExpr extends Generated::RangeExpr {
override string toString() { result = concat(int i | | this.toStringPart(i) order by i) }
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) {
index = 0 and result = this.getStartAbbreviation()

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class RecordExprField extends Generated::RecordExprField {
override string toString() { result = concat(int i | | this.toStringPart(i) order by i) }
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) {
index = 0 and result = this.getNameRef().getText()

View File

@@ -25,7 +25,7 @@ module Impl {
* ```
*/
class RecordExpr extends Generated::RecordExpr {
override string toString() { result = this.getPath().toString() + " {...}" }
override string toStringImpl() { result = this.getPath().toStringImpl() + " {...}" }
/** Gets the record expression for the field `name`. */
pragma[nomagic]

View File

@@ -21,7 +21,7 @@ module Impl {
* ```
*/
class RecordPatField extends Generated::RecordPatField {
override string toString() { result = concat(int i | | this.toStringPart(i) order by i) }
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) {
index = 0 and result = this.getNameRef().getText()

View File

@@ -25,7 +25,7 @@ module Impl {
* ```
*/
class RecordPat extends Generated::RecordPat {
override string toString() { result = this.getPath().toAbbreviatedString() + " {...}" }
override string toStringImpl() { result = this.getPath().toAbbreviatedString() + " {...}" }
pragma[nomagic]
private PathResolution::ItemNode getResolvedPath(string name) {

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class RefExpr extends Generated::RefExpr {
override string toString() {
override string toStringImpl() {
result = "&" + concat(int i | | this.getSpecPart(i), " " order by i)
}

View File

@@ -22,7 +22,7 @@ module Impl {
* ```
*/
class RefPat extends Generated::RefPat {
override string toString() {
override string toStringImpl() {
result = "&" + concat(int i | | this.getSpecPart(i), " " order by i)
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class RestPat extends Generated::RestPat {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = ".." }
}

View File

@@ -26,7 +26,9 @@ module Impl {
* ```
*/
class ReturnExpr extends Generated::ReturnExpr {
override string toString() { result = concat(int i | | this.toStringPart(i), " " order by i) }
override string toStringImpl() {
result = concat(int i | | this.toStringPart(i), " " order by i)
}
private string toStringPart(int index) {
index = 0 and result = "return"

View File

@@ -20,7 +20,7 @@ module Impl {
* ```
*/
class Struct extends Generated::Struct {
override string toString() { result = "struct " + this.getName().getText() }
override string toStringImpl() { result = "struct " + this.getName().getText() }
/** Gets the record field named `name`, if any. */
pragma[nomagic]

View File

@@ -25,6 +25,6 @@ module Impl {
* ```
*/
class Trait extends Generated::Trait {
override string toString() { result = "trait " + this.getName().getText() }
override string toStringImpl() { result = "trait " + this.getName().getText() }
}
}

View File

@@ -26,7 +26,7 @@ module Impl {
* ```
*/
class TupleStructPat extends Generated::TupleStructPat {
override string toString() { result = this.getPath().toAbbreviatedString() + "(...)" }
override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "(...)" }
pragma[nomagic]
private PathResolution::ItemNode getResolvedPath(int pos) {

View File

@@ -26,6 +26,6 @@ module Impl {
override string toAbbreviatedString() { result = this.getName().getText() }
override string toString() { result = this.getName().getText() }
override string toStringImpl() { result = this.getName().getText() }
}
}

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class UnderscoreExpr extends Generated::UnderscoreExpr {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "_" }
}

View File

@@ -19,6 +19,6 @@ module Impl {
* ```
*/
class Union extends Generated::Union {
override string toString() { result = "union " + this.getName().getText() }
override string toStringImpl() { result = "union " + this.getName().getText() }
}
}

View File

@@ -594,7 +594,7 @@ module Impl {
/** Holds if this access is a capture. */
predicate isCapture() { this.getEnclosingCfgScope() != v.getEnclosingCfgScope() }
override string toString() { result = name }
override string toStringImpl() { result = name }
override string getAPrimaryQlClass() { result = "VariableAccess" }
}

View File

@@ -20,7 +20,7 @@ module Impl {
* ```
*/
class Variant extends Generated::Variant {
override string toString() { result = this.getName().getText() }
override string toStringImpl() { result = this.getName().getText() }
/** Gets the record field named `name`, if any. */
pragma[nomagic]

View File

@@ -19,7 +19,7 @@ module Impl {
* ```
*/
class WildcardPat extends Generated::WildcardPat {
override string toString() { result = this.toAbbreviatedString() }
override string toStringImpl() { result = this.toAbbreviatedString() }
override string toAbbreviatedString() { result = "_" }
}

View File

@@ -23,7 +23,15 @@ module Generated {
/**
* Gets the string representation of this element.
*/
string toString() { none() } // overridden by subclasses
cached
final string toString() { result = this.toStringImpl() }
/**
* INTERNAL: Do not use.
*
* Gets the string representation of this element.
*/
abstract string toStringImpl();
/**
* Gets the name of a primary CodeQL class to which this element belongs.