Java/C++/C#: Fix Java Content.getType and getContainerType to match C# and fix C# tests.

This commit is contained in:
Anders Schack-Mulligen
2019-12-17 11:51:58 +01:00
parent a97e7bd3b2
commit ca08097b56
22 changed files with 250 additions and 49 deletions

View File

@@ -531,7 +531,7 @@ private predicate parameterFlow(
read(mid, f, node) and
readStoreCand1(f, unbind(config)) and
summary = midsum.readStep(f) and
t1 = getErasedRepr(f.getType()) and
t1 = f.getType() and
t1 = t2
)
or
@@ -581,7 +581,7 @@ private predicate parameterFlowReturn(
not exists(int pos | kind.(ParamUpdateReturnKind).getPosition() = pos and p.isParameterOf(_, pos))
}
pragma[noinline]
pragma[nomagic]
private predicate argumentFlowsThrough0(
DataFlowCall call, ArgumentNode arg, ReturnKindExt kind, DataFlowType t1, DataFlowType t2,
Summary summary, Configuration config

View File

@@ -531,7 +531,7 @@ private predicate parameterFlow(
read(mid, f, node) and
readStoreCand1(f, unbind(config)) and
summary = midsum.readStep(f) and
t1 = getErasedRepr(f.getType()) and
t1 = f.getType() and
t1 = t2
)
or
@@ -581,7 +581,7 @@ private predicate parameterFlowReturn(
not exists(int pos | kind.(ParamUpdateReturnKind).getPosition() = pos and p.isParameterOf(_, pos))
}
pragma[noinline]
pragma[nomagic]
private predicate argumentFlowsThrough0(
DataFlowCall call, ArgumentNode arg, ReturnKindExt kind, DataFlowType t1, DataFlowType t2,
Summary summary, Configuration config

View File

@@ -531,7 +531,7 @@ private predicate parameterFlow(
read(mid, f, node) and
readStoreCand1(f, unbind(config)) and
summary = midsum.readStep(f) and
t1 = getErasedRepr(f.getType()) and
t1 = f.getType() and
t1 = t2
)
or
@@ -581,7 +581,7 @@ private predicate parameterFlowReturn(
not exists(int pos | kind.(ParamUpdateReturnKind).getPosition() = pos and p.isParameterOf(_, pos))
}
pragma[noinline]
pragma[nomagic]
private predicate argumentFlowsThrough0(
DataFlowCall call, ArgumentNode arg, ReturnKindExt kind, DataFlowType t1, DataFlowType t2,
Summary summary, Configuration config

View File

@@ -531,7 +531,7 @@ private predicate parameterFlow(
read(mid, f, node) and
readStoreCand1(f, unbind(config)) and
summary = midsum.readStep(f) and
t1 = getErasedRepr(f.getType()) and
t1 = f.getType() and
t1 = t2
)
or
@@ -581,7 +581,7 @@ private predicate parameterFlowReturn(
not exists(int pos | kind.(ParamUpdateReturnKind).getPosition() = pos and p.isParameterOf(_, pos))
}
pragma[noinline]
pragma[nomagic]
private predicate argumentFlowsThrough0(
DataFlowCall call, ArgumentNode arg, ReturnKindExt kind, DataFlowType t1, DataFlowType t2,
Summary summary, Configuration config

View File

@@ -531,7 +531,7 @@ private predicate parameterFlow(
read(mid, f, node) and
readStoreCand1(f, unbind(config)) and
summary = midsum.readStep(f) and
t1 = getErasedRepr(f.getType()) and
t1 = f.getType() and
t1 = t2
)
or
@@ -581,7 +581,7 @@ private predicate parameterFlowReturn(
not exists(int pos | kind.(ParamUpdateReturnKind).getPosition() = pos and p.isParameterOf(_, pos))
}
pragma[noinline]
pragma[nomagic]
private predicate argumentFlowsThrough0(
DataFlowCall call, ArgumentNode arg, ReturnKindExt kind, DataFlowType t1, DataFlowType t2,
Summary summary, Configuration config

View File

@@ -154,11 +154,11 @@ class Content extends TContent {
path = "" and sl = 0 and sc = 0 and el = 0 and ec = 0
}
/** Gets the type of the object containing this content. */
abstract RefType getContainerType();
/** Gets the erased type of the object containing this content. */
abstract DataFlowType getContainerType();
/** Gets the type of this content. */
abstract Type getType();
/** Gets the erased type of this content. */
abstract DataFlowType getType();
}
private class FieldContent extends Content, TFieldContent {
@@ -174,25 +174,25 @@ private class FieldContent extends Content, TFieldContent {
f.getLocation().hasLocationInfo(path, sl, sc, el, ec)
}
override RefType getContainerType() { result = f.getDeclaringType() }
override DataFlowType getContainerType() { result = getErasedRepr(f.getDeclaringType()) }
override Type getType() { result = getFieldTypeBound(f) }
override DataFlowType getType() { result = getErasedRepr(getFieldTypeBound(f)) }
}
private class CollectionContent extends Content, TCollectionContent {
override string toString() { result = "collection" }
override RefType getContainerType() { none() }
override DataFlowType getContainerType() { none() }
override Type getType() { none() }
override DataFlowType getType() { none() }
}
private class ArrayContent extends Content, TArrayContent {
override string toString() { result = "array" }
override RefType getContainerType() { none() }
override DataFlowType getContainerType() { none() }
override Type getType() { none() }
override DataFlowType getType() { none() }
}
/**
@@ -226,7 +226,7 @@ predicate readStep(Node node1, Content f, Node node2) {
* possible flow. A single type is used for all numeric types to account for
* numeric conversions, and otherwise the erasure is used.
*/
RefType getErasedRepr(Type t) {
DataFlowType getErasedRepr(Type t) {
exists(Type e | e = t.getErasure() |
if e instanceof NumericOrCharType
then result.(BoxedType).getPrimitiveType().getName() = "double"