mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Add subclasses for Array
This commit is contained in:
2
rust/ql/lib/codeql/rust/elements.qll
generated
2
rust/ql/lib/codeql/rust/elements.qll
generated
@@ -25,6 +25,7 @@ import codeql.rust.elements.DbFile
|
||||
import codeql.rust.elements.DbLocation
|
||||
import codeql.rust.elements.Declaration
|
||||
import codeql.rust.elements.Element
|
||||
import codeql.rust.elements.ElementList
|
||||
import codeql.rust.elements.Expr
|
||||
import codeql.rust.elements.ExprStmt
|
||||
import codeql.rust.elements.Field
|
||||
@@ -59,6 +60,7 @@ import codeql.rust.elements.RecordLit
|
||||
import codeql.rust.elements.RecordPat
|
||||
import codeql.rust.elements.Ref
|
||||
import codeql.rust.elements.RefPat
|
||||
import codeql.rust.elements.Repeat
|
||||
import codeql.rust.elements.Return
|
||||
import codeql.rust.elements.SlicePat
|
||||
import codeql.rust.elements.Stmt
|
||||
|
||||
8
rust/ql/lib/codeql/rust/elements/ElementList.qll
generated
Normal file
8
rust/ql/lib/codeql/rust/elements/ElementList.qll
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
// generated by codegen, remove this comment if you wish to edit this file
|
||||
/**
|
||||
* This module provides a hand-modifiable wrapper around the generated class `ElementList`.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.ElementList
|
||||
|
||||
class ElementList extends Generated::ElementList { }
|
||||
14
rust/ql/lib/codeql/rust/elements/ElementListConstructor.qll
generated
Normal file
14
rust/ql/lib/codeql/rust/elements/ElementListConstructor.qll
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
// generated by codegen, remove this comment if you wish to edit this file
|
||||
/**
|
||||
* This module defines the hook used internally to tweak the characteristic predicate of
|
||||
* `ElementList` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.Raw
|
||||
|
||||
/**
|
||||
* The characteristic predicate of `ElementList` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
predicate constructElementList(Raw::ElementList id) { any() }
|
||||
8
rust/ql/lib/codeql/rust/elements/Repeat.qll
generated
Normal file
8
rust/ql/lib/codeql/rust/elements/Repeat.qll
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
// generated by codegen, remove this comment if you wish to edit this file
|
||||
/**
|
||||
* This module provides a hand-modifiable wrapper around the generated class `Repeat`.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.Repeat
|
||||
|
||||
class Repeat extends Generated::Repeat { }
|
||||
@@ -1,14 +1,14 @@
|
||||
// generated by codegen, remove this comment if you wish to edit this file
|
||||
/**
|
||||
* This module defines the hook used internally to tweak the characteristic predicate of
|
||||
* `Array` synthesized instances.
|
||||
* `Repeat` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.Raw
|
||||
|
||||
/**
|
||||
* The characteristic predicate of `Array` synthesized instances.
|
||||
* The characteristic predicate of `Repeat` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
predicate constructArray(Raw::Array id) { any() }
|
||||
predicate constructRepeat(Raw::Repeat id) { any() }
|
||||
4
rust/ql/lib/codeql/rust/generated/Array.qll
generated
4
rust/ql/lib/codeql/rust/generated/Array.qll
generated
@@ -17,7 +17,5 @@ module Generated {
|
||||
* INTERNAL: Do not reference the `Generated::Array` class directly.
|
||||
* Use the subclass `Array`, where the following predicates are available.
|
||||
*/
|
||||
class Array extends Synth::TArray, Expr {
|
||||
override string getAPrimaryQlClass() { result = "Array" }
|
||||
}
|
||||
class Array extends Synth::TArray, Expr { }
|
||||
}
|
||||
|
||||
51
rust/ql/lib/codeql/rust/generated/ElementList.qll
generated
Normal file
51
rust/ql/lib/codeql/rust/generated/ElementList.qll
generated
Normal file
@@ -0,0 +1,51 @@
|
||||
// generated by codegen
|
||||
/**
|
||||
* This module provides the generated definition of `ElementList`.
|
||||
* INTERNAL: Do not import directly.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.Synth
|
||||
private import codeql.rust.generated.Raw
|
||||
import codeql.rust.elements.Array
|
||||
import codeql.rust.elements.Expr
|
||||
|
||||
/**
|
||||
* INTERNAL: This module contains the fully generated definition of `ElementList` and should not
|
||||
* be referenced directly.
|
||||
*/
|
||||
module Generated {
|
||||
/**
|
||||
* INTERNAL: Do not reference the `Generated::ElementList` class directly.
|
||||
* Use the subclass `ElementList`, where the following predicates are available.
|
||||
*/
|
||||
class ElementList extends Synth::TElementList, Array {
|
||||
override string getAPrimaryQlClass() { result = "ElementList" }
|
||||
|
||||
/**
|
||||
* Gets the `index`th element of this element list (0-based).
|
||||
*/
|
||||
Expr getElement(int index) {
|
||||
result =
|
||||
Synth::convertExprFromRaw(Synth::convertElementListToRaw(this)
|
||||
.(Raw::ElementList)
|
||||
.getElement(index))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets any of the elements of this element list.
|
||||
*/
|
||||
final Expr getAnElement() { result = this.getElement(_) }
|
||||
|
||||
/**
|
||||
* Gets the number of elements of this element list.
|
||||
*/
|
||||
final int getNumberOfElements() { result = count(int i | exists(this.getElement(i))) }
|
||||
|
||||
/**
|
||||
* Holds if this element list is assignee expression.
|
||||
*/
|
||||
predicate isAssigneeExpr() {
|
||||
Synth::convertElementListToRaw(this).(Raw::ElementList).isAssigneeExpr()
|
||||
}
|
||||
}
|
||||
}
|
||||
34
rust/ql/lib/codeql/rust/generated/ParentChild.qll
generated
34
rust/ql/lib/codeql/rust/generated/ParentChild.qll
generated
@@ -925,6 +925,34 @@ private module Impl {
|
||||
)
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfElementList(
|
||||
ElementList e, int index, string partialPredicateCall
|
||||
) {
|
||||
exists(int b, int bArray, int n |
|
||||
b = 0 and
|
||||
bArray = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArray(e, i, _)) | i) and
|
||||
n = bArray and
|
||||
(
|
||||
none()
|
||||
or
|
||||
result = getImmediateChildOfArray(e, index - b, partialPredicateCall)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfRepeat(Repeat e, int index, string partialPredicateCall) {
|
||||
exists(int b, int bArray, int n |
|
||||
b = 0 and
|
||||
bArray = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArray(e, i, _)) | i) and
|
||||
n = bArray and
|
||||
(
|
||||
none()
|
||||
or
|
||||
result = getImmediateChildOfArray(e, index - b, partialPredicateCall)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfUnsafeBlock(
|
||||
UnsafeBlock e, int index, string partialPredicateCall
|
||||
) {
|
||||
@@ -960,8 +988,6 @@ private module Impl {
|
||||
or
|
||||
result = getImmediateChildOfTypeRef(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfArray(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfAwait(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfBecome(e, index, partialAccessor)
|
||||
@@ -1066,6 +1092,10 @@ private module Impl {
|
||||
or
|
||||
result = getImmediateChildOfBlock(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfElementList(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfRepeat(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfUnsafeBlock(e, index, partialAccessor)
|
||||
}
|
||||
}
|
||||
|
||||
38
rust/ql/lib/codeql/rust/generated/Raw.qll
generated
38
rust/ql/lib/codeql/rust/generated/Raw.qll
generated
@@ -143,9 +143,7 @@ module Raw {
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
class Array extends @array, Expr {
|
||||
override string toString() { result = "Array" }
|
||||
}
|
||||
class Array extends @array, Expr { }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
@@ -901,6 +899,40 @@ module Raw {
|
||||
Label getLabel() { block_labels(this, result) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
class ElementList extends @element_list, Array {
|
||||
override string toString() { result = "ElementList" }
|
||||
|
||||
/**
|
||||
* Gets the `index`th element of this element list (0-based).
|
||||
*/
|
||||
Expr getElement(int index) { element_list_elements(this, index, result) }
|
||||
|
||||
/**
|
||||
* Holds if this element list is assignee expression.
|
||||
*/
|
||||
predicate isAssigneeExpr() { element_list_is_assignee_expr(this) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
class Repeat extends @repeat, Array {
|
||||
override string toString() { result = "Repeat" }
|
||||
|
||||
/**
|
||||
* Gets the initializer of this repeat.
|
||||
*/
|
||||
Expr getInitializer() { repeats(this, result, _) }
|
||||
|
||||
/**
|
||||
* Gets the repeat of this repeat.
|
||||
*/
|
||||
Expr getRepeat() { repeats(this, _, result) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
||||
39
rust/ql/lib/codeql/rust/generated/Repeat.qll
generated
Normal file
39
rust/ql/lib/codeql/rust/generated/Repeat.qll
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
// generated by codegen
|
||||
/**
|
||||
* This module provides the generated definition of `Repeat`.
|
||||
* INTERNAL: Do not import directly.
|
||||
*/
|
||||
|
||||
private import codeql.rust.generated.Synth
|
||||
private import codeql.rust.generated.Raw
|
||||
import codeql.rust.elements.Array
|
||||
import codeql.rust.elements.Expr
|
||||
|
||||
/**
|
||||
* INTERNAL: This module contains the fully generated definition of `Repeat` and should not
|
||||
* be referenced directly.
|
||||
*/
|
||||
module Generated {
|
||||
/**
|
||||
* INTERNAL: Do not reference the `Generated::Repeat` class directly.
|
||||
* Use the subclass `Repeat`, where the following predicates are available.
|
||||
*/
|
||||
class Repeat extends Synth::TRepeat, Array {
|
||||
override string getAPrimaryQlClass() { result = "Repeat" }
|
||||
|
||||
/**
|
||||
* Gets the initializer of this repeat.
|
||||
*/
|
||||
Expr getInitializer() {
|
||||
result =
|
||||
Synth::convertExprFromRaw(Synth::convertRepeatToRaw(this).(Raw::Repeat).getInitializer())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repeat of this repeat.
|
||||
*/
|
||||
Expr getRepeat() {
|
||||
result = Synth::convertExprFromRaw(Synth::convertRepeatToRaw(this).(Raw::Repeat).getRepeat())
|
||||
}
|
||||
}
|
||||
}
|
||||
81
rust/ql/lib/codeql/rust/generated/Synth.qll
generated
81
rust/ql/lib/codeql/rust/generated/Synth.qll
generated
@@ -15,10 +15,6 @@ module Synth {
|
||||
*/
|
||||
cached
|
||||
newtype TElement =
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TArray(Raw::Array id) { constructArray(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
@@ -87,6 +83,10 @@ module Synth {
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TDbLocation(Raw::DbLocation id) { constructDbLocation(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TElementList(Raw::ElementList id) { constructElementList(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
@@ -203,6 +203,10 @@ module Synth {
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TRefPat(Raw::RefPat id) { constructRefPat(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TRepeat(Raw::Repeat id) { constructRepeat(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
@@ -260,6 +264,11 @@ module Synth {
|
||||
*/
|
||||
TYield(Raw::Yield id) { constructYield(id) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
class TArray = TElementList or TRepeat;
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
@@ -312,13 +321,6 @@ module Synth {
|
||||
*/
|
||||
class TStmt = TExprStmt or TIfLet or TItemStmt;
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TArray`, if possible.
|
||||
*/
|
||||
cached
|
||||
TArray convertArrayFromRaw(Raw::Element e) { result = TArray(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TAsyncBlock`, if possible.
|
||||
@@ -438,6 +440,13 @@ module Synth {
|
||||
cached
|
||||
TDbLocation convertDbLocationFromRaw(Raw::Element e) { result = TDbLocation(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TElementList`, if possible.
|
||||
*/
|
||||
cached
|
||||
TElementList convertElementListFromRaw(Raw::Element e) { result = TElementList(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TExprStmt`, if possible.
|
||||
@@ -641,6 +650,13 @@ module Synth {
|
||||
cached
|
||||
TRefPat convertRefPatFromRaw(Raw::Element e) { result = TRefPat(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TRepeat`, if possible.
|
||||
*/
|
||||
cached
|
||||
TRepeat convertRepeatFromRaw(Raw::Element e) { result = TRepeat(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TReturn`, if possible.
|
||||
@@ -739,6 +755,17 @@ module Synth {
|
||||
cached
|
||||
TYield convertYieldFromRaw(Raw::Element e) { result = TYield(e) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw DB element to a synthesized `TArray`, if possible.
|
||||
*/
|
||||
cached
|
||||
TArray convertArrayFromRaw(Raw::Element e) {
|
||||
result = convertElementListFromRaw(e)
|
||||
or
|
||||
result = convertRepeatFromRaw(e)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw DB element to a synthesized `TAstNode`, if possible.
|
||||
@@ -947,13 +974,6 @@ module Synth {
|
||||
result = convertItemStmtFromRaw(e)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TArray` to a raw DB element, if possible.
|
||||
*/
|
||||
cached
|
||||
Raw::Element convertArrayToRaw(TArray e) { e = TArray(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TAsyncBlock` to a raw DB element, if possible.
|
||||
@@ -1073,6 +1093,13 @@ module Synth {
|
||||
cached
|
||||
Raw::Element convertDbLocationToRaw(TDbLocation e) { e = TDbLocation(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TElementList` to a raw DB element, if possible.
|
||||
*/
|
||||
cached
|
||||
Raw::Element convertElementListToRaw(TElementList e) { e = TElementList(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TExprStmt` to a raw DB element, if possible.
|
||||
@@ -1276,6 +1303,13 @@ module Synth {
|
||||
cached
|
||||
Raw::Element convertRefPatToRaw(TRefPat e) { e = TRefPat(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TRepeat` to a raw DB element, if possible.
|
||||
*/
|
||||
cached
|
||||
Raw::Element convertRepeatToRaw(TRepeat e) { e = TRepeat(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TReturn` to a raw DB element, if possible.
|
||||
@@ -1374,6 +1408,17 @@ module Synth {
|
||||
cached
|
||||
Raw::Element convertYieldToRaw(TYield e) { e = TYield(result) }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TArray` to a raw DB element, if possible.
|
||||
*/
|
||||
cached
|
||||
Raw::Element convertArrayToRaw(TArray e) {
|
||||
result = convertElementListToRaw(e)
|
||||
or
|
||||
result = convertRepeatToRaw(e)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TAstNode` to a raw DB element, if possible.
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This module exports all modules providing `Element` subclasses.
|
||||
*/
|
||||
|
||||
import codeql.rust.elements.ArrayConstructor
|
||||
import codeql.rust.elements.AsyncBlockConstructor
|
||||
import codeql.rust.elements.AwaitConstructor
|
||||
import codeql.rust.elements.BecomeConstructor
|
||||
@@ -21,6 +20,7 @@ import codeql.rust.elements.ConstBlockPatConstructor
|
||||
import codeql.rust.elements.ContinueConstructor
|
||||
import codeql.rust.elements.DbFileConstructor
|
||||
import codeql.rust.elements.DbLocationConstructor
|
||||
import codeql.rust.elements.ElementListConstructor
|
||||
import codeql.rust.elements.ExprStmtConstructor
|
||||
import codeql.rust.elements.FieldConstructor
|
||||
import codeql.rust.elements.FunctionConstructor
|
||||
@@ -50,6 +50,7 @@ import codeql.rust.elements.RecordLitConstructor
|
||||
import codeql.rust.elements.RecordPatConstructor
|
||||
import codeql.rust.elements.RefConstructor
|
||||
import codeql.rust.elements.RefPatConstructor
|
||||
import codeql.rust.elements.RepeatConstructor
|
||||
import codeql.rust.elements.ReturnConstructor
|
||||
import codeql.rust.elements.SlicePatConstructor
|
||||
import codeql.rust.elements.TupleConstructor
|
||||
|
||||
Reference in New Issue
Block a user