Skip to content

Commit 3b7295b

Browse files
committed
Swift: unify ArrayContent and CollectionContent
1 parent ecf1d98 commit 3b7295b

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,6 @@ predicate parseContent(AccessPathToken component, Content content) {
497497
or
498498
parseEnum(component, content)
499499
or
500-
component.getName() = "ArrayElement" and
501-
content instanceof Content::ArrayContent
502-
or
503500
component.getName() = "CollectionElement" and
504501
content instanceof Content::CollectionContent
505502
}

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ private module Cached {
297297
TFieldContent(FieldDecl f) or
298298
TTupleContent(int index) { exists(any(TupleExpr te).getElement(index)) } or
299299
TEnumContent(ParamDecl f) { exists(EnumElementDecl d | d.getAParam() = f) } or
300-
TArrayContent() or
301300
TCollectionContent()
302301
}
303302

@@ -842,7 +841,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
842841
exists(ArrayExpr arr |
843842
node1.asExpr() = arr.getAnElement() and
844843
node2.asExpr() = arr and
845-
c.isSingleton(any(Content::ArrayContent ac))
844+
c.isSingleton(any(Content::CollectionContent ac))
846845
)
847846
or
848847
// array assignment `a[n] = x`
@@ -851,7 +850,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
851850
node2.(PostUpdateNode).getPreUpdateNode().asExpr() = subscript.getBase() and
852851
subscript = assign.getDest() and
853852
subscript.getBase().getType() instanceof ArrayType and
854-
c.isSingleton(any(Content::ArrayContent ac))
853+
c.isSingleton(any(Content::CollectionContent ac))
855854
)
856855
or
857856
// creation of an optional via implicit wrapping keypath component
@@ -948,7 +947,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
948947
(
949948
c.isSingleton(any(Content::FieldContent ct | ct.getField() = component.getDeclRef()))
950949
or
951-
c.isSingleton(any(Content::ArrayContent ac)) and
950+
c.isSingleton(any(Content::CollectionContent ac)) and
952951
component.isSubscript()
953952
or
954953
c instanceof OptionalSomeContentSet and
@@ -971,12 +970,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
971970
exists(SubscriptExpr subscript |
972971
subscript.getBase() = node1.asExpr() and
973972
subscript = node2.asExpr() and
974-
(
975-
subscript.getBase().getType() instanceof ArrayType and
976-
c.isSingleton(any(Content::ArrayContent ac))
977-
or
978973
c.isSingleton(any(Content::CollectionContent ac))
979-
)
980974
)
981975
or
982976
// read of a dictionary value via subscript operator
@@ -1099,7 +1093,7 @@ class DataFlowExpr = Expr;
10991093
* precision. This disables adaptive access path precision for such access paths.
11001094
*/
11011095
predicate forceHighPrecision(Content c) {
1102-
c instanceof Content::ArrayContent or c instanceof Content::CollectionContent
1096+
c instanceof Content::CollectionContent
11031097
}
11041098

11051099
/**

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPublic.qll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,6 @@ module Content {
220220
override string toString() { result = this.getSignature() }
221221
}
222222

223-
/** An element of an array at an unknown index */
224-
class ArrayContent extends Content, TArrayContent {
225-
override string toString() { result = "Array element" }
226-
}
227-
228223
/**
229224
* An element of a collection. This is a broad class including:
230225
* - elements of collections, such as `Set<Element>`.

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ private string getContentSpecific(ContentSet cs) {
129129
result = "EnumElement[" + c.getSignature() + "]"
130130
)
131131
or
132-
exists(Content::ArrayContent c |
133-
cs.isSingleton(c) and
134-
result = "ArrayElement"
135-
)
136-
or
137132
exists(Content::CollectionContent c |
138133
cs.isSingleton(c) and
139134
result = "CollectionElement"

0 commit comments

Comments
 (0)