Skip to content

Commit a26403b

Browse files
committed
Convert System.Tuple and friends flow to CSV format.
1 parent 348e3b7 commit a26403b

File tree

2 files changed

+381
-86
lines changed

2 files changed

+381
-86
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,6 @@ class CallableFlowSinkArg extends CallableFlowSink, TCallableFlowSinkArg {
243243
}
244244
}
245245

246-
private predicate isCollectionType(ValueOrRefType t) {
247-
t.getABaseType*() instanceof SystemCollectionsIEnumerableInterface and
248-
not t instanceof StringType
249-
}
250-
251-
/** Gets the flow source for argument `i` of callable `callable`. */
252-
private CallableFlowSourceArg getFlowSourceArg(
253-
SourceDeclarationCallable callable, int i, AccessPath ap
254-
) {
255-
i = result.getArgumentIndex() and
256-
exists(Parameter p |
257-
p = callable.getParameter(i) and
258-
if isCollectionType(p.getType()) then ap = AccessPath::element() else ap = AccessPath::empty()
259-
)
260-
}
261-
262246
/** Gets the flow source for argument `i` of delegate `callable`. */
263247
private CallableFlowSourceDelegateArg getDelegateFlowSourceArg(
264248
SourceDeclarationCallable callable, int i
@@ -1295,76 +1279,6 @@ class IDictionaryFlow extends LibraryTypeDataFlow, RefType {
12951279
}
12961280
}
12971281

1298-
/** Data flow for `System.[Value]Tuple<,...,>`. */
1299-
class SystemTupleFlow extends LibraryTypeDataFlow, ValueOrRefType {
1300-
SystemTupleFlow() {
1301-
this.getNamespace() instanceof SystemNamespace and
1302-
this.getName().regexpMatch("(Value)?Tuple(<,*>)?")
1303-
or
1304-
this instanceof TupleType
1305-
}
1306-
1307-
private AccessPath getItemAccessPath(int i) {
1308-
result =
1309-
unique(AccessPath ap |
1310-
i in [1 .. count(this.getAMember())] and
1311-
ap in [
1312-
AccessPath::field(this.getField("Item" + i)),
1313-
AccessPath::property(this.getProperty("Item" + i))
1314-
]
1315-
|
1316-
ap
1317-
)
1318-
}
1319-
1320-
override predicate callableFlow(
1321-
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
1322-
SourceDeclarationCallable c, boolean preservesValue
1323-
) {
1324-
preservesValue = true and
1325-
(
1326-
exists(SystemTupleFlow t, int i |
1327-
source = getFlowSourceArg(c, i - 1, _) and
1328-
sourceAp = AccessPath::empty() and
1329-
sink = TCallableFlowSinkReturn() and
1330-
sinkAp = t.getItemAccessPath(i)
1331-
|
1332-
c.(Constructor).getDeclaringType() = this and
1333-
t = this
1334-
or
1335-
exists(ValueOrRefType namedType |
1336-
namedType = this or namedType = this.(TupleType).getUnderlyingType()
1337-
|
1338-
c = namedType.getAMethod(any(string name | name.regexpMatch("Create(<,*>)?"))) and
1339-
(
1340-
t = c.getReturnType().getUnboundDeclaration() or
1341-
t = c.getReturnType().(TupleType).getUnderlyingType().getUnboundDeclaration()
1342-
)
1343-
)
1344-
)
1345-
or
1346-
c =
1347-
any(ExtensionMethod m |
1348-
m.hasUndecoratedName("Deconstruct") and
1349-
this = m.getExtendedType().getUnboundDeclaration() and
1350-
exists(int i |
1351-
m.getParameter(i).isOut() and
1352-
source = getFlowSourceArg(c, 0, _) and
1353-
sourceAp = this.getItemAccessPath(i) and
1354-
sink = TCallableFlowSinkArg(i) and
1355-
sinkAp = AccessPath::empty()
1356-
)
1357-
)
1358-
or
1359-
c = this.getAnIndexer().getGetter() and
1360-
source = TCallableFlowSourceQualifier() and
1361-
sourceAp = this.getItemAccessPath(_) and
1362-
sink = TCallableFlowSinkReturn() and
1363-
sinkAp = AccessPath::empty()
1364-
)
1365-
}
1366-
}
1367-
13681282
abstract private class SyntheticTaskField extends SyntheticField {
13691283
bindingset[this]
13701284
SyntheticTaskField() { any() }

0 commit comments

Comments
 (0)