Skip to content

Commit ece2f03

Browse files
author
Paolo Tranquilli
committed
Rust: fix QL compilation errors after renames
1 parent 394f3eb commit ece2f03

18 files changed

+32
-32
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ module ExprTrees {
329329
}
330330

331331
class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr {
332-
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }
332+
override AstNode getChildNode(int i) { i = 0 and result = super.getContainer() }
333333
}
334334

335335
class IfExprTree extends PostOrderTree instanceof IfExpr {

rust/ql/lib/codeql/rust/dataflow/internal/Content.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ final class TuplePositionContent extends FieldContent, TTuplePositionContent {
150150

151151
override FieldExprCfgNode getAnAccess() {
152152
// TODO: limit to tuple types
153-
result.getNameRef().getText().toInt() = pos
153+
result.getIdentifier().getText().toInt() = pos
154154
}
155155

156156
override string toString() { result = "tuple." + pos.toString() }
@@ -262,7 +262,7 @@ newtype TContent =
262262
TTuplePositionContent(int pos) {
263263
pos in [0 .. max([
264264
any(TuplePat pat).getNumberOfFields(),
265-
any(FieldExpr access).getNameRef().getText().toInt()
265+
any(FieldExpr access).getIdentifier().getText().toInt()
266266
]
267267
)]
268268
} or

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ module RustDataFlow implements InputSig<Location> {
688688
node1.asPat().(RefPatCfgNode).getPat() = node2.asPat()
689689
or
690690
exists(FieldExprCfgNode access |
691-
node1.asExpr() = access.getExpr() and
691+
node1.asExpr() = access.getContainer() and
692692
node2.asExpr() = access and
693693
access = c.(FieldContent).getAnAccess()
694694
)
@@ -771,7 +771,7 @@ module RustDataFlow implements InputSig<Location> {
771771
exists(AssignmentExprCfgNode assignment, FieldExprCfgNode access |
772772
assignment.getLhs() = access and
773773
node1.asExpr() = assignment.getRhs() and
774-
node2.asExpr() = access.getExpr() and
774+
node2.asExpr() = access.getContainer() and
775775
access = c.getAnAccess()
776776
)
777777
}

rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module Input implements InputSig<Location, RustDataFlow> {
4747
private class MethodCallExprNameRef extends SourceBase, SinkBase {
4848
private MethodCallExpr call;
4949

50-
MethodCallExprNameRef() { this = call.getNameRef() }
50+
MethodCallExprNameRef() { this = call.getIdentifier() }
5151

5252
override MethodCallExpr getCall() { result = call }
5353
}

rust/ql/lib/codeql/rust/dataflow/internal/Node.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ newtype TNode =
464464
e =
465465
[
466466
any(IndexExprCfgNode i).getBase(), //
467-
any(FieldExprCfgNode access).getExpr(), //
467+
any(FieldExprCfgNode access).getContainer(), //
468468
any(TryExprCfgNode try).getExpr(), //
469469
any(PrefixExprCfgNode pe | pe.getOperatorName() = "*").getExpr(), //
470470
any(AwaitExprCfgNode a).getExpr(), any(MethodCallExprCfgNode mc).getReceiver(), //

rust/ql/lib/codeql/rust/elements/internal/FieldExprImpl.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ module Impl {
3030

3131
override string toStringImpl() {
3232
exists(string abbr, string name |
33-
abbr = this.getExpr().toAbbreviatedString() and
34-
name = this.getNameRef().getText() and
33+
abbr = this.getContainer().toAbbreviatedString() and
34+
name = this.getIdentifier().getText() and
3535
if abbr = "..." then result = "... ." + name else result = abbr + "." + name
3636
)
3737
}

rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module Impl {
4646
exists(string base, string separator |
4747
base = this.getReceiver().toAbbreviatedString() and
4848
(if base = "..." then separator = " ." else separator = ".") and
49-
result = base + separator + this.getNameRef().toStringImpl() + "(...)"
49+
result = base + separator + this.getIdentifier().toStringImpl() + "(...)"
5050
)
5151
}
5252
}

rust/ql/lib/codeql/rust/elements/internal/PathImpl.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module Impl {
3939
* Gets the text of this path, if it exists.
4040
*/
4141
pragma[nomagic]
42-
string getText() { result = this.getSegment().getNameRef().getText() }
42+
string getText() { result = this.getSegment().getIdentifier().getText() }
4343
}
4444

4545
/** A simple identifier path. */
@@ -54,7 +54,7 @@ module Impl {
5454
not ps.hasParenthesizedArgList() and
5555
not ps.hasTypeRepr() and
5656
not ps.hasReturnTypeSyntax() and
57-
name = ps.getNameRef().getText()
57+
name = ps.getIdentifier().getText()
5858
)
5959
}
6060

rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Impl {
2424

2525
private string toAbbreviatedStringPart(int index) {
2626
index = 0 and
27-
if this.hasTypeRepr() then result = "<...>" else result = this.getNameRef().getText()
27+
if this.hasTypeRepr() then result = "<...>" else result = this.getIdentifier().getText()
2828
or
2929
index = 1 and result = this.getGenericArgList().toAbbreviatedString()
3030
}

rust/ql/lib/codeql/rust/elements/internal/StructExprFieldImpl.qll

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ module Impl {
2525
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
2626

2727
private string toStringPart(int index) {
28-
index = 0 and result = this.getNameRef().getText()
28+
index = 0 and result = this.getIdentifier().getText()
2929
or
30-
index = 1 and this.hasNameRef() and result = ": "
30+
index = 1 and this.hasIdentifier() and result = ": "
3131
or
3232
index = 2 and
3333
result = this.getExpr().toAbbreviatedString()
@@ -44,9 +44,9 @@ module Impl {
4444
* ```
4545
*/
4646
string getFieldName() {
47-
result = this.getNameRef().getText()
47+
result = this.getIdentifier().getText()
4848
or
49-
not this.hasNameRef() and
49+
not this.hasIdentifier() and
5050
result = this.getExpr().(PathExpr).getPath().(PathImpl::IdentPath).getName()
5151
}
5252
}

rust/ql/lib/codeql/rust/elements/internal/StructImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Impl {
2525
/** Gets the record field named `name`, if any. */
2626
pragma[nomagic]
2727
StructField getStructField(string name) {
28-
result = this.getFieldList().(RecordFieldList).getAField() and
28+
result = this.getFieldList().(StructFieldList).getAField() and
2929
result.getName().getText() = name
3030
}
3131

rust/ql/lib/codeql/rust/elements/internal/StructPatFieldImpl.qll

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ module Impl {
2424
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
2525

2626
private string toStringPart(int index) {
27-
index = 0 and result = this.getNameRef().getText()
27+
index = 0 and result = this.getIdentifier().getText()
2828
or
29-
index = 1 and this.hasNameRef() and result = ": "
29+
index = 1 and this.hasIdentifier() and result = ": "
3030
or
3131
index = 2 and
3232
result = this.getPat().toAbbreviatedString()
@@ -43,9 +43,9 @@ module Impl {
4343
* ```
4444
*/
4545
string getFieldName() {
46-
result = this.getNameRef().getText()
46+
result = this.getIdentifier().getText()
4747
or
48-
not this.hasNameRef() and
48+
not this.hasIdentifier() and
4949
result = this.getPat().(IdentPat).getName().getText()
5050
}
5151
}

rust/ql/lib/codeql/rust/elements/internal/VariantImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Impl {
2525
/** Gets the record field named `name`, if any. */
2626
pragma[nomagic]
2727
StructField getStructField(string name) {
28-
result = this.getFieldList().(RecordFieldList).getAField() and
28+
result = this.getFieldList().(StructFieldList).getAField() and
2929
result.getName().getText() = name
3030
}
3131

rust/ql/lib/codeql/rust/frameworks/rustcrypto/RustCrypto.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
3939
.(PathTypeRepr)
4040
.getPath()
4141
.getSegment()
42-
.getNameRef()
42+
.getIdentifier()
4343
.getText()
4444
) and
4545
algorithmName = simplifyAlgorithmName(rawAlgorithmName)

rust/ql/lib/codeql/rust/frameworks/stdlib/Clone.qll

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

rust/ql/lib/codeql/rust/internal/PathResolution.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private class VariantItemNode extends ItemNode instanceof Variant {
312312
override string getName() { result = Variant.super.getName().getText() }
313313

314314
override Namespace getNamespace() {
315-
if super.getFieldList() instanceof RecordFieldList then result.isType() else result.isValue()
315+
if super.getFieldList() instanceof StructFieldList then result.isType() else result.isValue()
316316
}
317317

318318
override TypeParam getTypeParam(int i) {
@@ -471,7 +471,7 @@ private class StructItemNode extends ItemNode instanceof Struct {
471471
override Namespace getNamespace() {
472472
result.isType() // the struct itself
473473
or
474-
not super.getFieldList() instanceof RecordFieldList and
474+
not super.getFieldList() instanceof StructFieldList and
475475
result.isValue() // the constructor
476476
}
477477

rust/ql/lib/codeql/rust/internal/TypeInference.qll

+4-4
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ private module FieldExprMatchingInput implements MatchingInputSig {
764764
Type getTypeArgument(TypeArgumentPosition apos, TypePath path) { none() }
765765

766766
AstNode getNodeAt(AccessPosition apos) {
767-
result = this.getExpr() and
767+
result = this.getContainer() and
768768
apos.isSelf()
769769
or
770770
result = this and
@@ -903,7 +903,7 @@ private module Cached {
903903
pragma[nomagic]
904904
private Type getMethodCallExprLookupType(MethodCallExpr mce, string name) {
905905
result = getLookupType(mce.getReceiver()) and
906-
name = mce.getNameRef().getText()
906+
name = mce.getIdentifier().getText()
907907
}
908908

909909
/**
@@ -916,8 +916,8 @@ private module Cached {
916916

917917
pragma[nomagic]
918918
private Type getFieldExprLookupType(FieldExpr fe, string name) {
919-
result = getLookupType(fe.getExpr()) and
920-
name = fe.getNameRef().getText()
919+
result = getLookupType(fe.getContainer()) and
920+
name = fe.getIdentifier().getText()
921921
}
922922

923923
/**

rust/ql/lib/codeql/rust/security/regex/RegexInjectionExtensions.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private class RegexInjectionDefaultBarrier extends RegexInjectionBarrier {
6464
.(PathExpr)
6565
.getPath()
6666
.getSegment()
67-
.getNameRef()
67+
.getIdentifier()
6868
.getText() = "escape"
6969
}
7070
}

0 commit comments

Comments
 (0)