Rust: fix QL compilation errors after renames

This commit is contained in:
Paolo Tranquilli
2025-03-27 16:20:08 +01:00
parent 394f3eb1be
commit ece2f03f0f
18 changed files with 32 additions and 32 deletions

View File

@@ -329,7 +329,7 @@ module ExprTrees {
}
class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr {
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }
override AstNode getChildNode(int i) { i = 0 and result = super.getContainer() }
}
class IfExprTree extends PostOrderTree instanceof IfExpr {

View File

@@ -150,7 +150,7 @@ final class TuplePositionContent extends FieldContent, TTuplePositionContent {
override FieldExprCfgNode getAnAccess() {
// TODO: limit to tuple types
result.getNameRef().getText().toInt() = pos
result.getIdentifier().getText().toInt() = pos
}
override string toString() { result = "tuple." + pos.toString() }
@@ -262,7 +262,7 @@ newtype TContent =
TTuplePositionContent(int pos) {
pos in [0 .. max([
any(TuplePat pat).getNumberOfFields(),
any(FieldExpr access).getNameRef().getText().toInt()
any(FieldExpr access).getIdentifier().getText().toInt()
]
)]
} or

View File

@@ -688,7 +688,7 @@ module RustDataFlow implements InputSig<Location> {
node1.asPat().(RefPatCfgNode).getPat() = node2.asPat()
or
exists(FieldExprCfgNode access |
node1.asExpr() = access.getExpr() and
node1.asExpr() = access.getContainer() and
node2.asExpr() = access and
access = c.(FieldContent).getAnAccess()
)
@@ -771,7 +771,7 @@ module RustDataFlow implements InputSig<Location> {
exists(AssignmentExprCfgNode assignment, FieldExprCfgNode access |
assignment.getLhs() = access and
node1.asExpr() = assignment.getRhs() and
node2.asExpr() = access.getExpr() and
node2.asExpr() = access.getContainer() and
access = c.getAnAccess()
)
}

View File

@@ -47,7 +47,7 @@ module Input implements InputSig<Location, RustDataFlow> {
private class MethodCallExprNameRef extends SourceBase, SinkBase {
private MethodCallExpr call;
MethodCallExprNameRef() { this = call.getNameRef() }
MethodCallExprNameRef() { this = call.getIdentifier() }
override MethodCallExpr getCall() { result = call }
}

View File

@@ -464,7 +464,7 @@ newtype TNode =
e =
[
any(IndexExprCfgNode i).getBase(), //
any(FieldExprCfgNode access).getExpr(), //
any(FieldExprCfgNode access).getContainer(), //
any(TryExprCfgNode try).getExpr(), //
any(PrefixExprCfgNode pe | pe.getOperatorName() = "*").getExpr(), //
any(AwaitExprCfgNode a).getExpr(), any(MethodCallExprCfgNode mc).getReceiver(), //

View File

@@ -30,8 +30,8 @@ module Impl {
override string toStringImpl() {
exists(string abbr, string name |
abbr = this.getExpr().toAbbreviatedString() and
name = this.getNameRef().getText() and
abbr = this.getContainer().toAbbreviatedString() and
name = this.getIdentifier().getText() and
if abbr = "..." then result = "... ." + name else result = abbr + "." + name
)
}

View File

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

View File

@@ -39,7 +39,7 @@ module Impl {
* Gets the text of this path, if it exists.
*/
pragma[nomagic]
string getText() { result = this.getSegment().getNameRef().getText() }
string getText() { result = this.getSegment().getIdentifier().getText() }
}
/** A simple identifier path. */
@@ -54,7 +54,7 @@ module Impl {
not ps.hasParenthesizedArgList() and
not ps.hasTypeRepr() and
not ps.hasReturnTypeSyntax() and
name = ps.getNameRef().getText()
name = ps.getIdentifier().getText()
)
}

View File

@@ -24,7 +24,7 @@ module Impl {
private string toAbbreviatedStringPart(int index) {
index = 0 and
if this.hasTypeRepr() then result = "<...>" else result = this.getNameRef().getText()
if this.hasTypeRepr() then result = "<...>" else result = this.getIdentifier().getText()
or
index = 1 and result = this.getGenericArgList().toAbbreviatedString()
}

View File

@@ -25,9 +25,9 @@ module Impl {
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()
index = 0 and result = this.getIdentifier().getText()
or
index = 1 and this.hasNameRef() and result = ": "
index = 1 and this.hasIdentifier() and result = ": "
or
index = 2 and
result = this.getExpr().toAbbreviatedString()
@@ -44,9 +44,9 @@ module Impl {
* ```
*/
string getFieldName() {
result = this.getNameRef().getText()
result = this.getIdentifier().getText()
or
not this.hasNameRef() and
not this.hasIdentifier() and
result = this.getExpr().(PathExpr).getPath().(PathImpl::IdentPath).getName()
}
}

View File

@@ -25,7 +25,7 @@ module Impl {
/** Gets the record field named `name`, if any. */
pragma[nomagic]
StructField getStructField(string name) {
result = this.getFieldList().(RecordFieldList).getAField() and
result = this.getFieldList().(StructFieldList).getAField() and
result.getName().getText() = name
}

View File

@@ -24,9 +24,9 @@ module Impl {
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()
index = 0 and result = this.getIdentifier().getText()
or
index = 1 and this.hasNameRef() and result = ": "
index = 1 and this.hasIdentifier() and result = ": "
or
index = 2 and
result = this.getPat().toAbbreviatedString()
@@ -43,9 +43,9 @@ module Impl {
* ```
*/
string getFieldName() {
result = this.getNameRef().getText()
result = this.getIdentifier().getText()
or
not this.hasNameRef() and
not this.hasIdentifier() and
result = this.getPat().(IdentPat).getName().getText()
}
}

View File

@@ -25,7 +25,7 @@ module Impl {
/** Gets the record field named `name`, if any. */
pragma[nomagic]
StructField getStructField(string name) {
result = this.getFieldList().(RecordFieldList).getAField() and
result = this.getFieldList().(StructFieldList).getAField() and
result.getName().getText() = name
}

View File

@@ -39,7 +39,7 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
.(PathTypeRepr)
.getPath()
.getSegment()
.getNameRef()
.getIdentifier()
.getText()
) and
algorithmName = simplifyAlgorithmName(rawAlgorithmName)

View File

@@ -9,7 +9,7 @@ final class CloneCallable extends SummarizedCallable::Range {
// NOTE: The function target may not exist in the database, so we base this
// on method calls.
exists(MethodCallExpr c |
c.getNameRef().getText() = "clone" and
c.getIdentifier().getText() = "clone" and
c.getArgList().getNumberOfArgs() = 0 and
this = c.getResolvedCrateOrigin() + "::_::" + c.getResolvedPath()
)

View File

@@ -312,7 +312,7 @@ private class VariantItemNode extends ItemNode instanceof Variant {
override string getName() { result = Variant.super.getName().getText() }
override Namespace getNamespace() {
if super.getFieldList() instanceof RecordFieldList then result.isType() else result.isValue()
if super.getFieldList() instanceof StructFieldList then result.isType() else result.isValue()
}
override TypeParam getTypeParam(int i) {
@@ -471,7 +471,7 @@ private class StructItemNode extends ItemNode instanceof Struct {
override Namespace getNamespace() {
result.isType() // the struct itself
or
not super.getFieldList() instanceof RecordFieldList and
not super.getFieldList() instanceof StructFieldList and
result.isValue() // the constructor
}

View File

@@ -764,7 +764,7 @@ private module FieldExprMatchingInput implements MatchingInputSig {
Type getTypeArgument(TypeArgumentPosition apos, TypePath path) { none() }
AstNode getNodeAt(AccessPosition apos) {
result = this.getExpr() and
result = this.getContainer() and
apos.isSelf()
or
result = this and
@@ -903,7 +903,7 @@ private module Cached {
pragma[nomagic]
private Type getMethodCallExprLookupType(MethodCallExpr mce, string name) {
result = getLookupType(mce.getReceiver()) and
name = mce.getNameRef().getText()
name = mce.getIdentifier().getText()
}
/**
@@ -916,8 +916,8 @@ private module Cached {
pragma[nomagic]
private Type getFieldExprLookupType(FieldExpr fe, string name) {
result = getLookupType(fe.getExpr()) and
name = fe.getNameRef().getText()
result = getLookupType(fe.getContainer()) and
name = fe.getIdentifier().getText()
}
/**

View File

@@ -64,7 +64,7 @@ private class RegexInjectionDefaultBarrier extends RegexInjectionBarrier {
.(PathExpr)
.getPath()
.getSegment()
.getNameRef()
.getIdentifier()
.getText() = "escape"
}
}