Java: Make a flow summary for Set.clear using WithoutElement and introduce appropriate tests.

This commit is contained in:
Michael Nebel
2023-08-07 09:50:30 +02:00
parent d3eb9c1325
commit 0ed724eb13
3 changed files with 13 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ public class B {
static void sink(Object obj) { }
static Object[] storeArrayElement(Object obj) { return new Object[] {obj}; }
static Set storeSetElement(Object obj) { return Set.of(obj); }
static Object readArrayElement(Object[] obj) { return obj[0]; }
static boolean readArrayElement(boolean[] obj) { return obj[0]; }
@@ -1232,6 +1233,16 @@ public class B {
Map out = null;
Object[] in = storeArrayElement(storeMapValue(source())); out = Map.ofEntries((Map.Entry[])in); sink(readMapValue(out)); // $ hasValueFlow
}
{
// "java.util;Set;true;clear;;;Argument[this].WithoutElement;Argument[this];value;manual"
Set out = null;
Set in = storeSetElement(source()); out = in; out.clear(); sink(readElement(out)); // No flow
}
{
// "java.util;Set;true;clear;;;Argument[this].WithoutElement;Argument[this];value;manual"
Set out = null;
Set in = (Set)source(); out = in; out.clear(); sink(out); // $ hasValueFlow
}
{
// "java.util;Set;false;copyOf;(Collection);;Argument[0].Element;ReturnValue.Element;value;manual",
Set out = null;

View File

@@ -13,7 +13,7 @@
| java.time | 0 | 0 | 0 | 17 | 17 | 0.0 | 0.0 | 0.0 | NaN | NaN | 1.0 |
| java.time.chrono | 0 | 0 | 0 | 1 | 1 | 0.0 | 0.0 | 0.0 | NaN | NaN | 1.0 |
| java.time.format | 0 | 0 | 0 | 2 | 2 | 0.0 | 0.0 | 0.0 | NaN | NaN | 1.0 |
| java.util | 0 | 0 | 85 | 67 | 152 | 0.5592105263157895 | 0.0 | 0.5592105263157895 | 0.0 | NaN | 0.4407894736842105 |
| java.util | 0 | 0 | 86 | 66 | 152 | 0.5657894736842105 | 0.0 | 0.5657894736842105 | 0.0 | NaN | 0.4342105263157895 |
| java.util.concurrent | 0 | 0 | 9 | 9 | 18 | 0.5 | 0.0 | 0.5 | 0.0 | NaN | 0.5 |
| java.util.concurrent.atomic | 0 | 0 | 2 | 11 | 13 | 0.15384615384615385 | 0.0 | 0.15384615384615385 | 0.0 | NaN | 0.8461538461538461 |
| java.util.concurrent.locks | 0 | 0 | 0 | 2 | 2 | 0.0 | 0.0 | 0.0 | NaN | NaN | 1.0 |