mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
JS: Remove ContentSet#asArrayIndex()
For ContentSet it is ambiguous whether asArrayIndex() should get a singleton content set, or the KnownArrayElement content set. The user will now have to choose between asSingleton().asArrayIndex() or ContentSet::arrayElementKnown.
This commit is contained in:
@@ -257,9 +257,6 @@ module Public {
|
||||
/** Gets the property name to be accessed, provided that this is a singleton content set. */
|
||||
PropertyName asPropertyName() { result = this.asSingleton().asPropertyName() }
|
||||
|
||||
/** Gets the array index to be accessed. */
|
||||
int asArrayIndex() { result = this.asSingleton().asArrayIndex() }
|
||||
|
||||
/**
|
||||
* Gets a string representation of this content set.
|
||||
*/
|
||||
|
||||
@@ -1162,7 +1162,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
|
||||
node2 = TRestParameterStoreNode(function, content)
|
||||
|
|
||||
// shift known array indices
|
||||
c.asArrayIndex() = content.asArrayIndex() + restIndex
|
||||
c.asSingleton().asArrayIndex() = content.asArrayIndex() + restIndex
|
||||
or
|
||||
content.isUnknownArrayElement() and // TODO: don't read unknown array elements from static array
|
||||
c = ContentSet::arrayElementUnknown()
|
||||
@@ -1179,7 +1179,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
|
||||
c = ContentSet::arrayElement() and // unknown start index when not the first spread operator
|
||||
storeContent.isUnknownArrayElement()
|
||||
else (
|
||||
storeContent.asArrayIndex() = n + c.asArrayIndex()
|
||||
storeContent.asArrayIndex() = n + c.asSingleton().asArrayIndex()
|
||||
or
|
||||
storeContent.isUnknownArrayElement() and c.asSingleton() = storeContent
|
||||
)
|
||||
@@ -1190,7 +1190,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
|
||||
node1 = TFlowSummaryDynamicParameterArrayNode(parameter.getSummarizedCallable()) and
|
||||
node2 = parameter and
|
||||
(
|
||||
c.asArrayIndex() = pos.asPositional()
|
||||
c.asSingleton().asArrayIndex() = pos.asPositional()
|
||||
or
|
||||
c = ContentSet::arrayElementLowerBound(pos.asPositionalLowerBound())
|
||||
)
|
||||
@@ -1261,7 +1261,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
|
||||
exists(InvokeExpr invoke, int n |
|
||||
node1 = TValueNode(invoke.getArgument(n)) and
|
||||
node2 = TStaticArgumentArrayNode(invoke) and
|
||||
c.asArrayIndex() = n and
|
||||
c.asSingleton().asArrayIndex() = n and
|
||||
not n >= firstSpreadArgumentIndex(invoke)
|
||||
)
|
||||
or
|
||||
|
||||
@@ -48,10 +48,10 @@ class ForOfLoopStep extends AdditionalFlowInternal {
|
||||
) {
|
||||
exists(ForOfStmt stmt |
|
||||
pred = getSynthesizedNode(stmt, "for-of-map-key") and
|
||||
contents.asArrayIndex() = 0
|
||||
contents.asSingleton().asArrayIndex() = 0
|
||||
or
|
||||
pred = getSynthesizedNode(stmt, "for-of-map-value") and
|
||||
contents.asArrayIndex() = 1
|
||||
contents.asSingleton().asArrayIndex() = 1
|
||||
|
|
||||
succ = DataFlow::lvalueNode(stmt.getLValue())
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user