From e3815b963654b52fa1dc26ad2945ca7ad2c5ca6e Mon Sep 17 00:00:00 2001 From: Luca Negrini Date: Fri, 8 Sep 2023 12:28:57 +0200 Subject: [PATCH] Using DefaultConfiguration for defaults #268 --- .../it/unive/lisa/DefaultConfiguration.java | 56 ++++ .../main/java/it/unive/lisa/LiSAFactory.java | 275 +++------------- .../lisa/analysis/SimpleAbstractState.java | 18 +- .../lisa/analysis/heap/MonolithicHeap.java | 13 +- .../unive/lisa/analysis/numeric/Interval.java | 2 - .../lisa/analysis/types/InferredTypes.java | 13 +- .../ModularWorstCaseAnalysis.java | 14 +- .../callgraph/RTACallGraph.java | 7 +- .../context/ContextBasedAnalysis.java | 2 - .../java/it/unive/lisa/CronConfiguration.java | 2 +- .../java/it/unive/lisa/LiSAFactoryTest.java | 121 ------- .../dataflow/AvailableExpressionsTest.java | 16 +- .../dataflow/ConstantPropagationDFTest.java | 16 +- .../dataflow/ReachingDefinitionsTest.java | 16 +- .../lisa/cron/descending/DescendingTest.java | 21 +- .../lisa/cron/heap/PointBasedHeapTest.java | 19 +- .../lisa/cron/heap/TypeBasedHeapTest.java | 13 +- .../ContextSensitiveAnalysisTest.java | 53 ++-- .../ModularWorstCaseAnalysisTest.java | 24 +- .../cron/interprocedural/RecursionsTest.java | 300 +++++++++--------- .../nonRedundantSet/NonRedundantSetTest.java | 16 +- .../cron/numeric/NumericAnalysesTest.java | 34 +- .../lisa/cron/string/BricksAnalysisTest.java | 36 --- .../string/CharInclusionAnalysisTest.java | 27 -- .../it/unive/lisa/cron/string/FSATest.java | 27 -- .../lisa/cron/string/PrefixAnalysisTest.java | 27 -- .../lisa/cron/string/StringAnalysesTest.java | 105 ++++++ .../lisa/cron/string/SuffixAnalysisTest.java | 27 -- .../it/unive/lisa/cron/string/TarsisTest.java | 28 -- .../lisa/cron/taint/TaintAnalysesTest.java | 20 +- .../cron/traces/TracePartitioningTest.java | 16 +- .../typeInference/TypesCollectionTest.java | 13 +- .../cron/visualization/VisualizationTest.java | 21 +- .../it/unive/lisa/DefaultImplementation.java | 21 -- .../java/it/unive/lisa/DefaultParameters.java | 29 -- .../it/unive/lisa/FallbackImplementation.java | 21 -- .../src/main/java/it/unive/lisa/LiSA.java | 37 +-- .../it/unive/lisa/conf/LiSAConfiguration.java | 1 - 38 files changed, 522 insertions(+), 985 deletions(-) create mode 100644 lisa/lisa-analyses/src/main/java/it/unive/lisa/DefaultConfiguration.java rename lisa/{lisa-sdk => lisa-analyses}/src/main/java/it/unive/lisa/LiSAFactory.java (52%) delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/LiSAFactoryTest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/BricksAnalysisTest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/CharInclusionAnalysisTest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/FSATest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/PrefixAnalysisTest.java create mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/StringAnalysesTest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/SuffixAnalysisTest.java delete mode 100644 lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/TarsisTest.java delete mode 100644 lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultImplementation.java delete mode 100644 lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultParameters.java delete mode 100644 lisa/lisa-sdk/src/main/java/it/unive/lisa/FallbackImplementation.java diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/DefaultConfiguration.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/DefaultConfiguration.java new file mode 100644 index 000000000..66461db8c --- /dev/null +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/DefaultConfiguration.java @@ -0,0 +1,56 @@ +package it.unive.lisa; + +import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.analysis.SimpleAbstractState; +import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.analysis.heap.MonolithicHeap; +import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; +import it.unive.lisa.analysis.numeric.Interval; +import it.unive.lisa.analysis.types.InferredTypes; +import it.unive.lisa.analysis.value.TypeDomain; +import it.unive.lisa.analysis.value.ValueDomain; +import it.unive.lisa.conf.LiSAConfiguration; +import it.unive.lisa.interprocedural.ModularWorstCaseAnalysis; +import it.unive.lisa.interprocedural.callgraph.RTACallGraph; + +public class DefaultConfiguration extends LiSAConfiguration { + + public static RTACallGraph defaultCallGraph() { + return new RTACallGraph(); + } + + public static > ModularWorstCaseAnalysis defaultInterproceduralAnalysis() { + return new ModularWorstCaseAnalysis<>(); + } + + public static TypeEnvironment defaultTypeDomain() { + return new TypeEnvironment<>(new InferredTypes()); + } + + public static ValueEnvironment defaultValueDomain() { + return new ValueEnvironment<>(new Interval()); + } + + public static MonolithicHeap defaultHeapDomain() { + return new MonolithicHeap(); + } + + public static , + V extends ValueDomain, + T extends TypeDomain> SimpleAbstractState simpleState(H heap, V value, T type) { + return new SimpleAbstractState<>(heap, value, type); + } + + public static SimpleAbstractState< + MonolithicHeap, + ValueEnvironment, + TypeEnvironment> defaultAbstractState() { + return simpleState(defaultHeapDomain(), defaultValueDomain(), defaultTypeDomain()); + } + + public DefaultConfiguration() { + this.callGraph = defaultCallGraph(); + this.interproceduralAnalysis = defaultInterproceduralAnalysis(); + } +} diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSAFactory.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/LiSAFactory.java similarity index 52% rename from lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSAFactory.java rename to lisa/lisa-analyses/src/main/java/it/unive/lisa/LiSAFactory.java index e05095c17..e9d0167e1 100644 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSAFactory.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/LiSAFactory.java @@ -1,22 +1,5 @@ package it.unive.lisa; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.dataflow.DataflowElement; -import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain; -import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.heap.HeapEnvironment; -import it.unive.lisa.analysis.nonrelational.heap.NonRelationalHeapDomain; -import it.unive.lisa.analysis.nonrelational.inference.InferenceSystem; -import it.unive.lisa.analysis.nonrelational.inference.InferredValue; -import it.unive.lisa.analysis.nonrelational.value.NonRelationalTypeDomain; -import it.unive.lisa.analysis.nonrelational.value.NonRelationalValueDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; -import it.unive.lisa.analysis.value.TypeDomain; -import it.unive.lisa.analysis.value.ValueDomain; -import it.unive.lisa.interprocedural.InterproceduralAnalysis; -import it.unive.lisa.interprocedural.callgraph.CallGraph; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -26,70 +9,46 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; + import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; +import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.analysis.dataflow.DataflowElement; +import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain; +import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain; +import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.analysis.nonrelational.heap.HeapEnvironment; +import it.unive.lisa.analysis.nonrelational.heap.NonRelationalHeapDomain; +import it.unive.lisa.analysis.nonrelational.inference.InferenceSystem; +import it.unive.lisa.analysis.nonrelational.inference.InferredValue; +import it.unive.lisa.analysis.nonrelational.value.NonRelationalTypeDomain; +import it.unive.lisa.analysis.nonrelational.value.NonRelationalValueDomain; +import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; +import it.unive.lisa.analysis.value.TypeDomain; +import it.unive.lisa.analysis.value.ValueDomain; +import it.unive.lisa.interprocedural.InterproceduralAnalysis; +import it.unive.lisa.interprocedural.callgraph.CallGraph; + /** * An utility class for instantiating analysis components, that is, modular - * pieces of the analysis that have several implementations. The default - * instance for a component can be retrieved through - * {@link #getDefaultFor(Class, Object...)}, while a specific instance can be - * retrieved through {@link #getInstance(Class, Object...)}. Note that custom - * defaults for each component can be defined by using - * {@link DefaultImplementation}, or by modifying - * {@link #DEFAULT_IMPLEMENTATIONS} and {@link #DEFAULT_PARAMETERS}. + * pieces of the analysis that have several implementations. A specific instance + * can be retrieved through {@link #getInstance(Class, Object...)}. Moreover, + * {@link #configurableComponents()} yields a list of each modular LiSA + * component. * * @author Luca Negrini */ public final class LiSAFactory { - /** - * Default implementation for analysis components. Keys of this map are the - * class objects of the analysis components while values are the key's - * default implementation's class object. - */ - public static final Map, Class> DEFAULT_IMPLEMENTATIONS = new HashMap<>(); - - /** - * Default parameters types for analysis components' implementations. Keys - * of this map are the class objects of the analysis components while values - * are arrays containing the key's default parameters' class objects. - */ - public static final Map, Class[]> DEFAULT_PARAMETERS = new HashMap<>(); - - static { - for (ConfigurableComponent component : configurableComponents()) { - if (component.defaultInstance != null) - DEFAULT_IMPLEMENTATIONS.put(component.component, component.defaultInstance); - - if (component.defaultParameters != null && component.defaultParameters.length > 0) - DEFAULT_PARAMETERS.put(component.component, component.defaultParameters); - - for (Entry, Class[]> alt : component.alternatives.entrySet()) - if (alt.getValue().length > 0) - DEFAULT_PARAMETERS.put(alt.getKey(), alt.getValue()); - } - - // wrapped defaults - DEFAULT_IMPLEMENTATIONS.putIfAbsent(HeapDomain.class, - DEFAULT_IMPLEMENTATIONS.get(NonRelationalHeapDomain.class)); - DEFAULT_IMPLEMENTATIONS.putIfAbsent(TypeDomain.class, - DEFAULT_IMPLEMENTATIONS.get(NonRelationalTypeDomain.class)); - DEFAULT_IMPLEMENTATIONS.putIfAbsent(ValueDomain.class, - DEFAULT_IMPLEMENTATIONS.get(NonRelationalValueDomain.class)); - DEFAULT_IMPLEMENTATIONS.putIfAbsent(ValueDomain.class, DEFAULT_IMPLEMENTATIONS.get(InferredValue.class)); - DEFAULT_IMPLEMENTATIONS.putIfAbsent(ValueDomain.class, DEFAULT_IMPLEMENTATIONS.get(DataflowElement.class)); - } - private LiSAFactory() { // this class is just a static holder } @@ -202,11 +161,8 @@ else if (((ParameterizedType) domain).getRawType() == DefiniteForwardDataflowDom /** * Creates an instance of the given {@code component}. If {@code params} are * provided, a suitable (and not ambiguous) constructor must exist in - * {@code component}'s class. If no {@code params} have been provided but - * the type has default parameters (that is, if it has been annotated with - * {@link DefaultParameters}), {@link #getInstance(Class, Object...)} will - * be used to create such parameters and those will be used. Otherwise, the - * nullary constructor of {@code component} is invoked. + * {@code component}'s class. Otherwise, the nullary constructor of + * {@code component} is invoked. * * @param the type of the component * @param component the component to instantiate @@ -221,74 +177,7 @@ public static T getInstance(Class component, Object... params) throws Ana if (params != null && params.length != 0) return construct(component, findConstructorSignature(component, params), params); - Class[] defaultParams; - if (!DEFAULT_PARAMETERS.containsKey(component) - || (defaultParams = DEFAULT_PARAMETERS.get(component)) == null - || defaultParams.length == 0) - return construct(component, ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY); - - Object[] defaults = new Object[defaultParams.length]; - for (int i = 0; i < defaults.length; i++) - defaults[i] = getInstance(defaultParams[i]); - - return construct(component, findConstructorSignature(component, defaults), defaults); - } catch (NullPointerException e) { - throw new AnalysisSetupException("Unable to instantiate default " + component.getSimpleName(), e); - } - } - - /** - * Builds the default instance of the specified analysis component. The - * instance to create is retrieved by first looking into the custom defaults - * (subtypes annotated with {@link DefaultImplementation}). If no entry for - * {@code component} is found, then the instance is looked up in the - * predefined defaults (subtypes annotated with - * {@link FallbackImplementation}). If {@code component} does not have a - * predefined default, then an {@link AnalysisSetupException} is thrown. - * Then, {@link #getInstance(Class, Object...)} is invoked on the retrieved - * instance, using the given {@code params}. If no {@code params} have been - * provided but the type has default parameters (that is, if it has been - * annotated with {@link DefaultParameters}), - * {@link #getInstance(Class, Object...)} will be used to create such - * parameters and those will be used. Note that some types are automatically - * wrapped before being returned. - *
    - *
  • {@link NonRelationalHeapDomain} is wrapped into a - * {@link HeapEnvironment}.
  • - *
  • {@link NonRelationalValueDomain} is wrapped into a - * {@link ValueEnvironment}.
  • - *
  • {@link NonRelationalTypeDomain} is wrapped into a - * {@link TypeEnvironment}.
  • - *
  • {@link InferredValue} is wrapped into a {@link InferenceSystem}.
  • - *
- * - * @param the type of the component - * @param component the component to instantiate - * @param params the parameters for the creation of the default instance - * - * @return an instance of the default implementation of the given component - * - * @throws AnalysisSetupException if the default implementation cannot be - * created - */ - @SuppressWarnings("unchecked") - public static T getDefaultFor(Class component, Object... params) throws AnalysisSetupException { - try { - Class def = DEFAULT_IMPLEMENTATIONS.get(component); - if (def == null) - throw new AnalysisSetupException("No registered default for " + component); - - Class[] defParams = DEFAULT_PARAMETERS.getOrDefault(def, ArrayUtils.EMPTY_CLASS_ARRAY); - if (params.length == 0 && defParams.length > 0) { - params = new Object[defParams.length]; - for (int i = 0; i < params.length; i++) - params[i] = getInstance(defParams[i]); - } - - if (needsWrapping(def, component)) - return (T) wrapParam(getInstance(def, params)); - else - return (T) getInstance(def, params); + return construct(component, ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY); } catch (NullPointerException e) { throw new AnalysisSetupException("Unable to instantiate default " + component.getSimpleName(), e); } @@ -298,16 +187,13 @@ public static T getDefaultFor(Class component, Object... params) throws A * An analysis component that can be configured, that is, it has more than * one implementation that can be modularly integrated into the analysis. * {@link #getComponent()} yields the component itself, i.e. the interface - * or abstract class that defines the analysis components. - * {@link #getDefaultInstance()} yields the default implementation of the - * component that will be used if no specific implementation is requested. + * or abstract class that defines the analysis component. * {@link #getAlternatives()} yields all the concrete implementations of the - * components.
+ * component.
*
* Note that all information present in instances of this class reflect the - * static information known to LiSA, that is, what is present inside the - * classpath. Any customization performed through {@link LiSAFactory} (i.e., - * changing the defaults) will not have any effect on the components. + * information known to LiSA when this component is created, that is, what + * is present inside the classpath and already loaded by the JVM. * * @author Luca Negrini */ @@ -315,50 +201,21 @@ public static final class ConfigurableComponent { private static final Reflections scanner = new Reflections("", new SubTypesScanner()); private final Class component; - private final Class defaultInstance; - private final Class[] defaultParameters; - private final Map, Class[]> alternatives; + private final Set> alternatives; private ConfigurableComponent(Class component) { this.component = component; - this.alternatives = new HashMap<>(); - this.defaultParameters = component.isAnnotationPresent(DefaultParameters.class) - ? component.getAnnotation(DefaultParameters.class).value() - : ArrayUtils.EMPTY_CLASS_ARRAY; + this.alternatives = new HashSet<>(); @SuppressWarnings("rawtypes") Set subtypes = scanner.getSubTypesOf(component); - Set> fallbacks = new HashSet<>(); - Set> defaults = new HashSet<>(); for (Object sub : subtypes) { Class subtype = (Class) sub; if (Modifier.isAbstract(subtype.getModifiers()) || subtype.isInterface()) continue; - Class[] defaultParams = subtype.isAnnotationPresent(DefaultParameters.class) - ? subtype.getAnnotation(DefaultParameters.class).value() - : ArrayUtils.EMPTY_CLASS_ARRAY; - alternatives.put(subtype, defaultParams); - - if (subtype.isAnnotationPresent(DefaultImplementation.class)) - defaults.add(subtype); - if (subtype.isAnnotationPresent(FallbackImplementation.class)) - fallbacks.add(subtype); + alternatives.add(subtype); } - - if (defaults.size() > 1) - throw new IllegalStateException( - "More than one user-default for " + component.getName() + ": " + defaults); - if (fallbacks.size() > 1) - throw new IllegalStateException( - "More than one LiSA-default for " + component.getName() + ": " + fallbacks); - - if (!defaults.isEmpty()) - defaultInstance = defaults.iterator().next(); - else if (!fallbacks.isEmpty()) - defaultInstance = fallbacks.iterator().next(); - else - defaultInstance = null; } /** @@ -371,33 +228,6 @@ public Class getComponent() { return component; } - /** - * Yields the default implementation for this component, that is, the - * concrete class that implements it and that will be used if the - * component is requested but the user did not specify which - * implementation to use (among the ones offered by - * {@link #getAlternatives()}. Might be {@code null} if no default is - * set. - * - * @return the default implementation for this component - */ - public Class getDefaultInstance() { - return defaultInstance; - } - - /** - * Yields the classes of the parameters passed by-default to the - * constructor of the default implementation for this component. Might - * be {@code null} if no default is set, or might be an empty array if - * the default implementation does not require parameters. - * - * @return the classes of the parameters for the construction of the - * default implementation for this component - */ - public Class[] getDefaultParameters() { - return defaultParameters; - } - /** * Yields the alternatives for this component, that is, the concrete * classes that implements it. Each alternative is mapped to its default @@ -405,7 +235,7 @@ public Class[] getDefaultParameters() { * * @return the alternatives for this component */ - public Map, Class[]> getAlternatives() { + public Set> getAlternatives() { return alternatives; } @@ -415,8 +245,6 @@ public int hashCode() { int result = 1; result = prime * result + ((alternatives == null) ? 0 : alternatives.hashCode()); result = prime * result + ((component == null) ? 0 : component.hashCode()); - result = prime * result + ((defaultInstance == null) ? 0 : defaultInstance.hashCode()); - result = prime * result + ((defaultParameters == null) ? 0 : Arrays.hashCode(defaultParameters)); return result; } @@ -429,25 +257,15 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; ConfigurableComponent other = (ConfigurableComponent) obj; - if (alternatives == null) { - if (other.alternatives != null) - return false; - } else if (!alternatives.equals(other.alternatives)) - return false; if (component == null) { if (other.component != null) return false; } else if (!component.equals(other.component)) return false; - if (defaultInstance == null) { - if (other.defaultInstance != null) - return false; - } else if (!defaultInstance.equals(other.defaultInstance)) - return false; - if (defaultParameters == null) { - if (other.defaultParameters != null) + if (alternatives == null) { + if (other.alternatives != null) return false; - } else if (!Arrays.equals(defaultParameters, other.defaultParameters)) + } else if (!alternatives.equals(other.alternatives)) return false; return true; } @@ -455,17 +273,8 @@ public boolean equals(Object obj) { @Override public String toString() { String result = component.getName(); - if (defaultInstance != null) { - result += " (defaults to: '" + defaultInstance.getName() + "'"; - if (defaultParameters != null && defaultParameters.length != 0) { - String[] paramNames = Arrays.stream(defaultParameters).map(c -> c.getName()).toArray(String[]::new); - result += " with parameters [" + StringUtils.join(paramNames, ", ") + "]"; - } - result += ")"; - } - String[] alternatives = this.alternatives.entrySet().stream() - .map(e -> e.getKey().getName() + (e.getValue().length == 0 ? "" - : " (with default parameters: " + StringUtils.join(e.getValue(), ", ") + ")")) + String[] alternatives = this.alternatives.stream() + .map(e -> e.getName()) .toArray(String[]::new); result += " possible implementations: " + StringUtils.join(alternatives, ", "); return result; @@ -474,7 +283,11 @@ public String toString() { /** * Yields the collection of {@link ConfigurableComponent}s that can be used - * to customize the analysis. + * to customize the analysis.
+ *
+ * Note that all information present in the returned instances reflect the + * information known to LiSA when this component is created, that is, what + * is present inside the classpath and already loaded by the JVM. * * @return the components that can be configured */ diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/SimpleAbstractState.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/SimpleAbstractState.java index 37f2d5fc3..1457be327 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/SimpleAbstractState.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/SimpleAbstractState.java @@ -1,15 +1,16 @@ package it.unive.lisa.analysis; -import it.unive.lisa.DefaultParameters; -import it.unive.lisa.FallbackImplementation; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; + import it.unive.lisa.analysis.heap.HeapDomain; import it.unive.lisa.analysis.heap.HeapSemanticOperation.HeapReplacement; -import it.unive.lisa.analysis.heap.MonolithicHeap; import it.unive.lisa.analysis.lattices.ExpressionSet; -import it.unive.lisa.analysis.numeric.Interval; import it.unive.lisa.analysis.representation.DomainRepresentation; import it.unive.lisa.analysis.representation.ObjectRepresentation; -import it.unive.lisa.analysis.types.InferredTypes; import it.unive.lisa.analysis.value.TypeDomain; import it.unive.lisa.analysis.value.ValueDomain; import it.unive.lisa.program.cfg.ProgramPoint; @@ -19,11 +20,6 @@ import it.unive.lisa.symbolic.value.ValueExpression; import it.unive.lisa.type.Type; import it.unive.lisa.type.Untyped; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; /** * An abstract state of the analysis, composed by a heap state modeling the @@ -42,8 +38,6 @@ * @param the type of {@link ValueDomain} embedded in this state * @param the type of {@link TypeDomain} embedded in this state */ -@FallbackImplementation -@DefaultParameters({ MonolithicHeap.class, Interval.class, InferredTypes.class }) public class SimpleAbstractState, V extends ValueDomain, T extends TypeDomain> diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/heap/MonolithicHeap.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/heap/MonolithicHeap.java index 66276ac52..710e46a32 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/heap/MonolithicHeap.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/heap/MonolithicHeap.java @@ -1,6 +1,11 @@ package it.unive.lisa.analysis.heap; -import it.unive.lisa.FallbackImplementation; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + import it.unive.lisa.analysis.Lattice; import it.unive.lisa.analysis.SemanticException; import it.unive.lisa.analysis.lattices.ExpressionSet; @@ -20,11 +25,6 @@ import it.unive.lisa.type.ReferenceType; import it.unive.lisa.type.Type; import it.unive.lisa.type.Untyped; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; /** * A monolithic heap implementation that abstracts all heap locations to a @@ -32,7 +32,6 @@ * * @author Luca Negrini */ -@FallbackImplementation public class MonolithicHeap implements BaseHeapDomain { private static final MonolithicHeap TOP = new MonolithicHeap(); diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/numeric/Interval.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/numeric/Interval.java index 473837dba..fbc7ca5f4 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/numeric/Interval.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/numeric/Interval.java @@ -1,6 +1,5 @@ package it.unive.lisa.analysis.numeric; -import it.unive.lisa.FallbackImplementation; import it.unive.lisa.analysis.BaseLattice; import it.unive.lisa.analysis.Lattice; import it.unive.lisa.analysis.SemanticDomain.Satisfiability; @@ -44,7 +43,6 @@ * * @author Vincenzo Arceri */ -@FallbackImplementation public class Interval implements BaseNonRelationalValueDomain, Comparable { /** diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/types/InferredTypes.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/types/InferredTypes.java index a7fec734b..4be7341e4 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/types/InferredTypes.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/types/InferredTypes.java @@ -2,7 +2,12 @@ import static org.apache.commons.collections4.CollectionUtils.intersection; -import it.unive.lisa.FallbackImplementation; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + import it.unive.lisa.analysis.Lattice; import it.unive.lisa.analysis.SemanticDomain.Satisfiability; import it.unive.lisa.analysis.SemanticException; @@ -31,11 +36,6 @@ import it.unive.lisa.type.Type; import it.unive.lisa.type.TypeSystem; import it.unive.lisa.type.TypeTokenType; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; /** * An {@link InferredValue} holding a set of {@link Type}s, representing the @@ -43,7 +43,6 @@ * * @author Luca Negrini */ -@FallbackImplementation public class InferredTypes implements BaseNonRelationalTypeDomain { private static final InferredTypes BOTTOM = new InferredTypes(null, Collections.emptySet()); diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/ModularWorstCaseAnalysis.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/ModularWorstCaseAnalysis.java index faf130a74..32d763bae 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/ModularWorstCaseAnalysis.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/ModularWorstCaseAnalysis.java @@ -1,7 +1,13 @@ package it.unive.lisa.interprocedural; +import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.FallbackImplementation; import it.unive.lisa.analysis.AbstractState; import it.unive.lisa.analysis.AnalysisState; import it.unive.lisa.analysis.AnalyzedCFG; @@ -28,18 +34,12 @@ import it.unive.lisa.type.Type; import it.unive.lisa.util.collections.workset.WorkingSet; import it.unive.lisa.util.datastructures.graph.algorithms.FixpointException; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; /** * A worst case modular analysis were all cfg calls are treated as open calls. * * @param the {@link AbstractState} of the analysis */ -@FallbackImplementation public class ModularWorstCaseAnalysis> implements InterproceduralAnalysis { private static final Logger LOG = LogManager.getLogger(ModularWorstCaseAnalysis.class); diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/callgraph/RTACallGraph.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/callgraph/RTACallGraph.java index b0e061eec..534cceb70 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/callgraph/RTACallGraph.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/callgraph/RTACallGraph.java @@ -1,11 +1,11 @@ package it.unive.lisa.interprocedural.callgraph; -import it.unive.lisa.FallbackImplementation; -import it.unive.lisa.program.cfg.statement.Expression; -import it.unive.lisa.type.Type; import java.util.Collection; import java.util.Set; +import it.unive.lisa.program.cfg.statement.Expression; +import it.unive.lisa.type.Type; + /** * A call graph constructed following the Rapid Type Analysis as defined in: * Frank Tip and Jens Palsberg. 2000. Scalable propagation-based call graph @@ -16,7 +16,6 @@ * * @author Pietro Ferrara */ -@FallbackImplementation public class RTACallGraph extends BaseCallGraph { @Override diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/context/ContextBasedAnalysis.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/context/ContextBasedAnalysis.java index 87c1e16b6..5701b8b93 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/context/ContextBasedAnalysis.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/interprocedural/context/ContextBasedAnalysis.java @@ -2,7 +2,6 @@ import it.unive.lisa.AnalysisExecutionException; import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.DefaultParameters; import it.unive.lisa.analysis.AbstractState; import it.unive.lisa.analysis.AnalysisState; import it.unive.lisa.analysis.AnalyzedCFG; @@ -58,7 +57,6 @@ * * @param the {@link AbstractState} of the analysis */ -@DefaultParameters({ FullStackToken.class }) public class ContextBasedAnalysis> extends CallGraphBasedAnalysis { private static final Logger LOG = LogManager.getLogger(ContextBasedAnalysis.class); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/CronConfiguration.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/CronConfiguration.java index 62709df3a..c457f4b56 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/CronConfiguration.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/CronConfiguration.java @@ -9,7 +9,7 @@ * * @author Luca Negrini */ -public class CronConfiguration extends LiSAConfiguration { +public class CronConfiguration extends DefaultConfiguration { /** * The name of the test folder; this is used for searching expected results diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/LiSAFactoryTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/LiSAFactoryTest.java deleted file mode 100644 index 52d0c1ba3..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/LiSAFactoryTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package it.unive.lisa; - -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import it.unive.lisa.LiSAFactory.ConfigurableComponent; -import it.unive.lisa.analysis.nonrelational.heap.HeapEnvironment; -import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; -import it.unive.lisa.analysis.numeric.Sign; -import it.unive.lisa.analysis.value.ValueDomain; -import it.unive.lisa.program.SourceCodeLocation; -import it.unive.lisa.symbolic.value.Variable; -import it.unive.lisa.type.Untyped; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.StringUtils; -import org.junit.Test; - -// This test must live here since the implementations are available only in lisa-analyses -public class LiSAFactoryTest { - - private static final Collection components = LiSAFactory.configurableComponents(); - - @Test - public void ensureDefaultsConsistency() { - Collection getDefault = new ArrayList<>(); - Collection getInstanceOfDefault = new ArrayList<>(); - Map, Class[]> getInstanceWithDefaultParams = new HashMap<>(); - for (ConfigurableComponent comp : components) - if (comp.getDefaultInstance() != null) { - try { - LiSAFactory.getDefaultFor(comp.getComponent()); - } catch (AnalysisSetupException e) { - getDefault.add(comp); - } - - try { - LiSAFactory.getInstance(comp.getDefaultInstance()); - } catch (AnalysisSetupException e) { - getInstanceOfDefault.add(comp); - } - } - - for (Entry, Class[]> impl : LiSAFactory.DEFAULT_PARAMETERS.entrySet()) - try { - LiSAFactory.getInstance(impl.getKey()); - Object[] params = new Object[impl.getValue().length]; - for (int i = 0; i < params.length; i++) - params[i] = LiSAFactory.getInstance(impl.getValue()[i]); - LiSAFactory.getInstance(impl.getKey(), params); - } catch (AnalysisSetupException e) { - getInstanceWithDefaultParams.put(impl.getKey(), impl.getValue()); - } - - if (!getDefault.isEmpty()) { - System.err.println( - "The following default implementations cannot be created through LiSAFactory.getDefaultFor(...): "); - for (ConfigurableComponent comp : getDefault) - System.err.println(" - " + comp.getDefaultInstance().getName() + " (default for: " - + comp.getComponent().getName() + ")"); - } - - if (!getInstanceOfDefault.isEmpty()) { - System.err.println( - "The following default implementations cannot be created through LiSAFactory.getInstance(...): "); - for (ConfigurableComponent comp : getInstanceOfDefault) - System.err.println(" - " + comp.getDefaultInstance().getName() + " (default for: " - + comp.getComponent().getName() + ")"); - } - - if (!getInstanceWithDefaultParams.isEmpty()) { - System.err.println( - "The following implementations have default parameters in LiSAFactory.ANALYSIS_DEFAULTS and cannot be created through LiSAFactory.getInstance(...) using those parameters: "); - for (Class alt : getInstanceWithDefaultParams.keySet()) - System.err.println(" - " + alt.getName() + " (with params: " - + StringUtils.join(getInstanceWithDefaultParams.get(alt), ", ") + ")"); - } - - assertTrue("Problems creating instances", - getDefault.isEmpty() && getInstanceOfDefault.isEmpty() && getInstanceWithDefaultParams.isEmpty()); - } - - @Test - @SuppressWarnings("rawtypes") - public void testCustomDefaults() throws AnalysisSetupException { - Class target = ValueDomain.class; - Class newDefault = Sign.class; - Class oldDefault = removeEnvironment(target); - assertNotEquals("Old and new defaults are the same", oldDefault, newDefault); - - String message = "Setting custom default for " + target.getName() + " to " + newDefault.getName() - + " didn't have any effect on %s"; - LiSAFactory.DEFAULT_IMPLEMENTATIONS.put(target, newDefault); - - assertSame(String.format(message, "LiSAFactory.getDefaultFor(...)"), newDefault, removeEnvironment(target)); - - // we do not check configurable components here, since those only - // contain information from the compiled code - } - - private Class removeEnvironment(Class target) throws AnalysisSetupException { - Object def = LiSAFactory.getDefaultFor(target); - - // by getting top(), we know that whatever variable we ask for, we will - // be getting the top instance of the inner lattice - if (def instanceof ValueEnvironment) - def = ((ValueEnvironment) def).top() - .getState( - new Variable(Untyped.INSTANCE, "foo", new SourceCodeLocation("unknown", 0, 0))); - else if (def instanceof HeapEnvironment) - def = ((HeapEnvironment) def).top() - .getState( - new Variable(Untyped.INSTANCE, "foo", new SourceCodeLocation("unknown", 0, 0))); - - return def.getClass(); - } -} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/AvailableExpressionsTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/AvailableExpressionsTest.java index 76a0dfbd0..5649a8181 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/AvailableExpressionsTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/AvailableExpressionsTest.java @@ -1,15 +1,13 @@ package it.unive.lisa.cron.dataflow; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.dataflow.AvailableExpressions; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; +import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain; public class AvailableExpressionsTest extends AnalysisTestExecutor { @@ -17,10 +15,10 @@ public class AvailableExpressionsTest extends AnalysisTestExecutor { public void testAvailableExpressions() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new AvailableExpressions(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new DefiniteForwardDataflowDomain<>(new AvailableExpressions()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "available-expressions"; conf.programFile = "available-expressions.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ConstantPropagationDFTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ConstantPropagationDFTest.java index 7ecbcf549..ef5b911cd 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ConstantPropagationDFTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ConstantPropagationDFTest.java @@ -1,15 +1,13 @@ package it.unive.lisa.cron.dataflow; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.dataflow.ConstantPropagation; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; +import it.unive.lisa.analysis.dataflow.DefiniteForwardDataflowDomain; public class ConstantPropagationDFTest extends AnalysisTestExecutor { @@ -17,10 +15,10 @@ public class ConstantPropagationDFTest extends AnalysisTestExecutor { public void testConstantPropagation() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new ConstantPropagation(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new DefiniteForwardDataflowDomain<>(new ConstantPropagation()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "constant-propagation-df"; conf.programFile = "constant-propagation.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ReachingDefinitionsTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ReachingDefinitionsTest.java index 0b5c6c684..5bdba362c 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ReachingDefinitionsTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/dataflow/ReachingDefinitionsTest.java @@ -1,15 +1,13 @@ package it.unive.lisa.cron.dataflow; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; +import it.unive.lisa.analysis.dataflow.PossibleForwardDataflowDomain; import it.unive.lisa.analysis.dataflow.ReachingDefinitions; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; public class ReachingDefinitionsTest extends AnalysisTestExecutor { @@ -17,10 +15,10 @@ public class ReachingDefinitionsTest extends AnalysisTestExecutor { public void testReachingDefinitions() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new ReachingDefinitions(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new PossibleForwardDataflowDomain<>(new ReachingDefinitions()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "reaching-definitions"; conf.programFile = "reaching-definitions.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/descending/DescendingTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/descending/DescendingTest.java index 571eab392..86bf06783 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/descending/DescendingTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/descending/DescendingTest.java @@ -1,17 +1,12 @@ package it.unive.lisa.cron.descending; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.numeric.Interval; -import it.unive.lisa.analysis.types.InferredTypes; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.conf.LiSAConfiguration.DescendingPhaseType; -import org.junit.Test; public class DescendingTest extends AnalysisTestExecutor { @@ -19,8 +14,10 @@ public class DescendingTest extends AnalysisTestExecutor { public void testIntervalDescendingWidening() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Interval(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + DefaultConfiguration.defaultValueDomain(), + DefaultConfiguration.defaultTypeDomain()); conf.descendingPhaseType = DescendingPhaseType.NARROWING; conf.testDir = "descending-widening"; conf.programFile = "program.imp"; @@ -31,8 +28,10 @@ public void testIntervalDescendingWidening() throws AnalysisSetupException { public void testIntervalDescendingMaxGlb() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Interval(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + DefaultConfiguration.defaultValueDomain(), + DefaultConfiguration.defaultTypeDomain()); conf.descendingPhaseType = DescendingPhaseType.GLB; conf.glbThreshold = 5; conf.testDir = "descending-maxglb"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/PointBasedHeapTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/PointBasedHeapTest.java index 39b6067ca..56abcedc8 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/PointBasedHeapTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/PointBasedHeapTest.java @@ -1,16 +1,13 @@ package it.unive.lisa.cron.heap; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.heap.pointbased.FieldSensitivePointBasedHeap; import it.unive.lisa.analysis.heap.pointbased.PointBasedHeap; -import it.unive.lisa.analysis.numeric.Interval; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; public class PointBasedHeapTest extends AnalysisTestExecutor { @@ -18,10 +15,10 @@ public class PointBasedHeapTest extends AnalysisTestExecutor { public void fieldInsensitivePointBasedHeapTest() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, + conf.abstractState = DefaultConfiguration.simpleState( new PointBasedHeap(), - new Interval(), - getDefaultFor(TypeDomain.class)); + DefaultConfiguration.defaultValueDomain(), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "heap/point-based-heap/field-insensitive"; conf.programFile = "program.imp"; perform(conf); @@ -31,10 +28,10 @@ public void fieldInsensitivePointBasedHeapTest() throws AnalysisSetupException { public void fieldSensitivePointBasedHeapTest() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, + conf.abstractState = DefaultConfiguration.simpleState( new FieldSensitivePointBasedHeap(), - new Interval(), - getDefaultFor(TypeDomain.class)); + DefaultConfiguration.defaultValueDomain(), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "heap/point-based-heap/field-sensitive"; conf.programFile = "program.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/TypeBasedHeapTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/TypeBasedHeapTest.java index 7fbea21c7..86ae48c4a 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/TypeBasedHeapTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/heap/TypeBasedHeapTest.java @@ -1,15 +1,12 @@ package it.unive.lisa.cron.heap; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.heap.TypeBasedHeap; -import it.unive.lisa.analysis.numeric.Interval; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; public class TypeBasedHeapTest extends AnalysisTestExecutor { @@ -17,10 +14,10 @@ public class TypeBasedHeapTest extends AnalysisTestExecutor { public void testTypeBasedHeap() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, + conf.abstractState = DefaultConfiguration.simpleState( new TypeBasedHeap(), - new Interval(), - getDefaultFor(TypeDomain.class)); + DefaultConfiguration.defaultValueDomain(), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "heap/type-based-heap"; conf.programFile = "program.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ContextSensitiveAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ContextSensitiveAnalysisTest.java index 932fbed0f..bca436388 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ContextSensitiveAnalysisTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ContextSensitiveAnalysisTest.java @@ -1,20 +1,17 @@ package it.unive.lisa.cron.interprocedural; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.heap.pointbased.PointBasedHeap; -import it.unive.lisa.analysis.numeric.Interval; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; import it.unive.lisa.analysis.numeric.Sign; -import it.unive.lisa.analysis.value.TypeDomain; import it.unive.lisa.interprocedural.callgraph.RTACallGraph; import it.unive.lisa.interprocedural.context.ContextBasedAnalysis; import it.unive.lisa.interprocedural.context.FullStackToken; -import org.junit.Test; public class ContextSensitiveAnalysisTest extends AnalysisTestExecutor { @@ -22,10 +19,10 @@ public class ContextSensitiveAnalysisTest extends AnalysisTestExecutor { public void testRTAContextSensitive1() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -38,10 +35,10 @@ public void testRTAContextSensitive1() throws AnalysisSetupException { public void testRTAContextSensitive2() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -54,10 +51,10 @@ public void testRTAContextSensitive2() throws AnalysisSetupException { public void testRTAContextSensitive3() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -70,10 +67,10 @@ public void testRTAContextSensitive3() throws AnalysisSetupException { public void testRTAContextSensitive4() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -86,10 +83,10 @@ public void testRTAContextSensitive4() throws AnalysisSetupException { public void testRTAContextSensitive5() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, + conf.abstractState = DefaultConfiguration.simpleState( new PointBasedHeap(), - new Interval(), - getDefaultFor(TypeDomain.class)); + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -102,10 +99,10 @@ public void testRTAContextSensitive5() throws AnalysisSetupException { public void testRTAContextSensitive6() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, + conf.abstractState = DefaultConfiguration.simpleState( new PointBasedHeap(), - new Interval(), - getDefaultFor(TypeDomain.class)); + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ModularWorstCaseAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ModularWorstCaseAnalysisTest.java index de954a19a..4164b91b4 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ModularWorstCaseAnalysisTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/ModularWorstCaseAnalysisTest.java @@ -1,18 +1,16 @@ package it.unive.lisa.cron.interprocedural; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.DefaultConfiguration; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; import it.unive.lisa.analysis.numeric.Sign; -import it.unive.lisa.analysis.value.TypeDomain; import it.unive.lisa.interprocedural.ModularWorstCaseAnalysis; import it.unive.lisa.interprocedural.callgraph.CHACallGraph; import it.unive.lisa.interprocedural.callgraph.RTACallGraph; -import org.junit.Test; public class ModularWorstCaseAnalysisTest extends AnalysisTestExecutor { @@ -20,10 +18,10 @@ public class ModularWorstCaseAnalysisTest extends AnalysisTestExecutor { public void testCHACallGraph() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ModularWorstCaseAnalysis<>(); conf.callGraph = new CHACallGraph(); conf.testDir = "interprocedural"; @@ -36,10 +34,10 @@ public void testCHACallGraph() throws AnalysisSetupException { public void testRTACallGraph() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Sign(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ModularWorstCaseAnalysis<>(); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/RecursionsTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/RecursionsTest.java index 5a3f3f3dd..59af3bb0c 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/RecursionsTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/interprocedural/RecursionsTest.java @@ -1,23 +1,21 @@ package it.unive.lisa.cron.interprocedural; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.DefaultConfiguration; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; import it.unive.lisa.analysis.numeric.Interval; -import it.unive.lisa.analysis.value.TypeDomain; import it.unive.lisa.interprocedural.callgraph.RTACallGraph; import it.unive.lisa.interprocedural.context.ContextBasedAnalysis; import it.unive.lisa.interprocedural.context.ContextInsensitiveToken; import it.unive.lisa.interprocedural.context.FullStackToken; import it.unive.lisa.interprocedural.context.KDepthToken; import it.unive.lisa.interprocedural.context.LastCallToken; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class RecursionsTest extends AnalysisTestExecutor { @@ -26,10 +24,10 @@ public class RecursionsTest extends AnalysisTestExecutor { public void testFibonacciFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -47,10 +45,10 @@ public void testFibonacciFullStack() throws AnalysisSetupException { public void testFibonacciKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -68,10 +66,10 @@ public void testFibonacciKDepth() throws AnalysisSetupException { public void testFibonacciLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -89,10 +87,10 @@ public void testFibonacciLast() throws AnalysisSetupException { public void testFibonacciInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -110,10 +108,10 @@ public void testFibonacciInsensitive() throws AnalysisSetupException { public void testFactorialLoopFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -126,10 +124,10 @@ public void testFactorialLoopFullStack() throws AnalysisSetupException { public void testFactorialLoopKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -142,10 +140,10 @@ public void testFactorialLoopKDepth() throws AnalysisSetupException { public void testFactorialLoopLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -158,10 +156,10 @@ public void testFactorialLoopLast() throws AnalysisSetupException { public void testFactorialLoopInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -174,10 +172,10 @@ public void testFactorialLoopInsensitive() throws AnalysisSetupException { public void testInfiniteRecursion2FullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -191,10 +189,10 @@ public void testInfiniteRecursion2FullStack() throws AnalysisSetupException { public void testInfiniteRecursion2KDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -208,10 +206,10 @@ public void testInfiniteRecursion2KDepth() throws AnalysisSetupException { public void testInfiniteRecursion2Last() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -225,10 +223,10 @@ public void testInfiniteRecursion2Last() throws AnalysisSetupException { public void testInfiniteRecursion2Insensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -242,10 +240,10 @@ public void testInfiniteRecursion2Insensitive() throws AnalysisSetupException { public void testInfiniteRecursion1FullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -259,10 +257,10 @@ public void testInfiniteRecursion1FullStack() throws AnalysisSetupException { public void testInfiniteRecursion1KDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -276,10 +274,10 @@ public void testInfiniteRecursion1KDepth() throws AnalysisSetupException { public void testInfiniteRecursion1Last() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -293,10 +291,10 @@ public void testInfiniteRecursion1Last() throws AnalysisSetupException { public void testInfiniteRecursion1Insensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -310,10 +308,10 @@ public void testInfiniteRecursion1Insensitive() throws AnalysisSetupException { public void testFactorialFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -326,10 +324,10 @@ public void testFactorialFullStack() throws AnalysisSetupException { public void testFactorialKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -342,10 +340,10 @@ public void testFactorialKDepth() throws AnalysisSetupException { public void testFactorialLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -358,10 +356,10 @@ public void testFactorialLast() throws AnalysisSetupException { public void testFactorialInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -374,10 +372,10 @@ public void testFactorialInsensitive() throws AnalysisSetupException { public void testFactorialInterleavedFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -390,10 +388,10 @@ public void testFactorialInterleavedFullStack() throws AnalysisSetupException { public void testFactorialInterleavedKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -406,10 +404,10 @@ public void testFactorialInterleavedKDepth() throws AnalysisSetupException { public void testFactorialInterleavedLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -422,10 +420,10 @@ public void testFactorialInterleavedLast() throws AnalysisSetupException { public void testFactorialInterleavedInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -438,10 +436,10 @@ public void testFactorialInterleavedInsensitive() throws AnalysisSetupException public void testTwoRecursionsFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -454,10 +452,10 @@ public void testTwoRecursionsFullStack() throws AnalysisSetupException { public void testTwoRecursionsKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -470,10 +468,10 @@ public void testTwoRecursionsKDepth() throws AnalysisSetupException { public void testTwoRecursionsLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -486,10 +484,10 @@ public void testTwoRecursionsLast() throws AnalysisSetupException { public void testTwoRecursionsInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -502,10 +500,10 @@ public void testTwoRecursionsInsensitive() throws AnalysisSetupException { public void testNestedRecursionsFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -518,10 +516,10 @@ public void testNestedRecursionsFullStack() throws AnalysisSetupException { public void testNestedRecursionsKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -534,10 +532,10 @@ public void testNestedRecursionsKDepth() throws AnalysisSetupException { public void testNestedRecursionsLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -550,10 +548,10 @@ public void testNestedRecursionsLast() throws AnalysisSetupException { public void testNestedRecursionsInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -566,10 +564,10 @@ public void testNestedRecursionsInsensitive() throws AnalysisSetupException { public void testUnreachableBaseCaseFullStack() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -582,10 +580,10 @@ public void testUnreachableBaseCaseFullStack() throws AnalysisSetupException { public void testUnreachableBaseCaseKDepth() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(KDepthToken.getSingleton(5)); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -598,10 +596,10 @@ public void testUnreachableBaseCaseKDepth() throws AnalysisSetupException { public void testUnreachableBaseCaseLast() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(LastCallToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; @@ -614,10 +612,10 @@ public void testUnreachableBaseCaseLast() throws AnalysisSetupException { public void testUnreachableBaseCaseInsensitive() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - new Interval(), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(ContextInsensitiveToken.getSingleton()); conf.callGraph = new RTACallGraph(); conf.testDir = "interprocedural"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/nonRedundantSet/NonRedundantSetTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/nonRedundantSet/NonRedundantSetTest.java index 0ca317c4a..e43867218 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/nonRedundantSet/NonRedundantSetTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/nonRedundantSet/NonRedundantSetTest.java @@ -1,17 +1,14 @@ package it.unive.lisa.cron.nonRedundantSet; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.nonRedundantSet.NonRedundantPowersetOfInterval; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.types.InferredTypes; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; import it.unive.lisa.conf.LiSAConfiguration.DescendingPhaseType; -import org.junit.Test; public class NonRedundantSetTest extends AnalysisTestExecutor { @@ -19,9 +16,10 @@ public class NonRedundantSetTest extends AnalysisTestExecutor { public void testNonRedundantSetOfInterval() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), - new NonRedundantPowersetOfInterval(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new NonRedundantPowersetOfInterval()), + DefaultConfiguration.defaultTypeDomain()); conf.descendingPhaseType = DescendingPhaseType.GLB; conf.glbThreshold = 5; conf.testDir = "non-redundant-set-interval"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/numeric/NumericAnalysesTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/numeric/NumericAnalysesTest.java index ca05c02f5..74fffd965 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/numeric/NumericAnalysesTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/numeric/NumericAnalysesTest.java @@ -1,19 +1,16 @@ package it.unive.lisa.cron.numeric; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; +import it.unive.lisa.DefaultConfiguration; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; import it.unive.lisa.analysis.numeric.IntegerConstantPropagation; import it.unive.lisa.analysis.numeric.Interval; import it.unive.lisa.analysis.numeric.Parity; import it.unive.lisa.analysis.numeric.Sign; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; public class NumericAnalysesTest extends AnalysisTestExecutor { @@ -21,8 +18,10 @@ public class NumericAnalysesTest extends AnalysisTestExecutor { public void testSign() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Sign(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Sign()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "sign"; conf.programFile = "program.imp"; perform(conf); @@ -32,8 +31,10 @@ public void testSign() throws AnalysisSetupException { public void testParity() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Parity(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Parity()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "parity"; conf.programFile = "program.imp"; perform(conf); @@ -43,8 +44,10 @@ public void testParity() throws AnalysisSetupException { public void testInterval() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Interval(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Interval()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "interval"; conf.programFile = "program.imp"; perform(conf); @@ -54,9 +57,10 @@ public void testInterval() throws AnalysisSetupException { public void testIntegerConstantPropagation() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), - new IntegerConstantPropagation(), - new TypeEnvironment<>(new InferredTypes())); + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new IntegerConstantPropagation()), + DefaultConfiguration.defaultTypeDomain()); conf.testDir = "int-const"; conf.programFile = "program.imp"; perform(conf); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/BricksAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/BricksAnalysisTest.java deleted file mode 100644 index 5be4e8130..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/BricksAnalysisTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.bricks.Bricks; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class BricksAnalysisTest extends AnalysisTestExecutor { - - @Test - public void testBricks() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Bricks(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "bricks"; - conf.programFile = "program.imp"; - // we disable optimized test because of bricks normalization: without - // optimization, loops that get iterated more than once will have - // poststates of instructions within them built with at least one lub - // invocation between the different iterations, and that will invoke the - // normalization algorithm. Optimized run instead will not iterate - // multiple times, and poststates will be the plain ones returned by - // abstract transformers. Even if they are semantically equivalent, - // comparisons will fail nonetheless - conf.compareWithOptimization = false; - perform(conf); - } -} \ No newline at end of file diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/CharInclusionAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/CharInclusionAnalysisTest.java deleted file mode 100644 index 3d538a368..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/CharInclusionAnalysisTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.CharInclusion; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class CharInclusionAnalysisTest extends AnalysisTestExecutor { - - @Test - public void testCharInclusion() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new CharInclusion(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "char-inclusion"; - conf.programFile = "program.imp"; - perform(conf); - } -} \ No newline at end of file diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/FSATest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/FSATest.java deleted file mode 100644 index 867d61fff..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/FSATest.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.fsa.FSA; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class FSATest extends AnalysisTestExecutor { - - @Test - public void testFSA() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new FSA(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "fsa"; - conf.programFile = "program.imp"; - perform(conf); - } -} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/PrefixAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/PrefixAnalysisTest.java deleted file mode 100644 index b06114194..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/PrefixAnalysisTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.Prefix; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class PrefixAnalysisTest extends AnalysisTestExecutor { - - @Test - public void testPrefix() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Prefix(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "prefix"; - conf.programFile = "program.imp"; - perform(conf); - } -} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/StringAnalysesTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/StringAnalysesTest.java new file mode 100644 index 000000000..98e960fc9 --- /dev/null +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/StringAnalysesTest.java @@ -0,0 +1,105 @@ +package it.unive.lisa.cron.string; + +import org.junit.Test; + +import it.unive.lisa.AnalysisSetupException; +import it.unive.lisa.AnalysisTestExecutor; +import it.unive.lisa.CronConfiguration; +import it.unive.lisa.DefaultConfiguration; +import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; +import it.unive.lisa.analysis.string.CharInclusion; +import it.unive.lisa.analysis.string.Prefix; +import it.unive.lisa.analysis.string.Suffix; +import it.unive.lisa.analysis.string.bricks.Bricks; +import it.unive.lisa.analysis.string.fsa.FSA; +import it.unive.lisa.analysis.string.tarsis.Tarsis; + +public class StringAnalysesTest extends AnalysisTestExecutor { + + @Test + public void testPrefix() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Prefix()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "prefix"; + conf.programFile = "program.imp"; + perform(conf); + } + + @Test + public void testSuffix() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Suffix()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "suffix"; + conf.programFile = "program.imp"; + perform(conf); + } + + @Test + public void testCharInclusion() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new CharInclusion()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "char-inclusion"; + conf.programFile = "program.imp"; + perform(conf); + } + + @Test + public void testBricks() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Bricks()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "bricks"; + conf.programFile = "program.imp"; + // we disable optimized test because of bricks normalization: without + // optimization, loops that get iterated more than once will have + // poststates of instructions within them built with at least one lub + // invocation between the different iterations, and that will invoke the + // normalization algorithm. Optimized run instead will not iterate + // multiple times, and poststates will be the plain ones returned by + // abstract transformers. Even if they are semantically equivalent, + // comparisons will fail nonetheless + conf.compareWithOptimization = false; + perform(conf); + } + + @Test + public void testFSA() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new FSA()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "fsa"; + conf.programFile = "program.imp"; + perform(conf); + } + + @Test + public void testTarsis() throws AnalysisSetupException { + CronConfiguration conf = new CronConfiguration(); + conf.serializeResults = true; + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + new ValueEnvironment<>(new Tarsis()), + DefaultConfiguration.defaultTypeDomain()); + conf.testDir = "tarsis"; + conf.programFile = "program.imp"; + perform(conf); + } +} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/SuffixAnalysisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/SuffixAnalysisTest.java deleted file mode 100644 index c727702dd..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/SuffixAnalysisTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.Suffix; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class SuffixAnalysisTest extends AnalysisTestExecutor { - - @Test - public void testSuffix() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), new Suffix(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "suffix"; - conf.programFile = "program.imp"; - perform(conf); - } -} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/TarsisTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/TarsisTest.java deleted file mode 100644 index b7bf1b602..000000000 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/string/TarsisTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package it.unive.lisa.cron.string; - -import static it.unive.lisa.LiSAFactory.getDefaultFor; - -import it.unive.lisa.AnalysisSetupException; -import it.unive.lisa.AnalysisTestExecutor; -import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; -import it.unive.lisa.analysis.string.tarsis.Tarsis; -import it.unive.lisa.analysis.types.InferredTypes; -import org.junit.Test; - -public class TarsisTest extends AnalysisTestExecutor { - - @Test - public void testTarsis() throws AnalysisSetupException { - CronConfiguration conf = new CronConfiguration(); - conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, getDefaultFor(HeapDomain.class), - new Tarsis(), - new TypeEnvironment<>(new InferredTypes())); - conf.testDir = "tarsis"; - conf.programFile = "program.imp"; - perform(conf); - } -} diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/taint/TaintAnalysesTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/taint/TaintAnalysesTest.java index b532ef610..1ad322ccd 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/taint/TaintAnalysesTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/taint/TaintAnalysesTest.java @@ -1,15 +1,15 @@ package it.unive.lisa.cron.taint; +import org.junit.Test; + import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.LiSAFactory; -import it.unive.lisa.analysis.AbstractState; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.AnalysisState; import it.unive.lisa.analysis.AnalyzedCFG; import it.unive.lisa.analysis.SemanticException; import it.unive.lisa.analysis.SimpleAbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; import it.unive.lisa.analysis.heap.MonolithicHeap; import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; @@ -17,7 +17,6 @@ import it.unive.lisa.analysis.taint.Taint; import it.unive.lisa.analysis.taint.ThreeLevelsTaint; import it.unive.lisa.analysis.types.InferredTypes; -import it.unive.lisa.analysis.value.TypeDomain; import it.unive.lisa.checks.semantic.CheckToolWithAnalysisResults; import it.unive.lisa.checks.semantic.SemanticCheck; import it.unive.lisa.interprocedural.ReturnTopPolicy; @@ -33,17 +32,16 @@ import it.unive.lisa.program.cfg.statement.call.UnresolvedCall; import it.unive.lisa.symbolic.SymbolicExpression; import it.unive.lisa.symbolic.value.ValueExpression; -import org.junit.Test; public class TaintAnalysesTest extends AnalysisTestExecutor { @Test public void testTaint() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); - conf.abstractState = LiSAFactory.getDefaultFor(AbstractState.class, - LiSAFactory.getDefaultFor(HeapDomain.class), + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), new ValueEnvironment<>(new Taint()), - LiSAFactory.getDefaultFor(TypeDomain.class)); + DefaultConfiguration.defaultTypeDomain()); conf.serializeResults = true; conf.openCallPolicy = ReturnTopPolicy.INSTANCE; conf.callGraph = new RTACallGraph(); @@ -59,10 +57,10 @@ public void testTaint() throws AnalysisSetupException { @Test public void testThreeLevelsTaint() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); - conf.abstractState = LiSAFactory.getDefaultFor(AbstractState.class, - LiSAFactory.getDefaultFor(HeapDomain.class), + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), new ValueEnvironment<>(new ThreeLevelsTaint()), - LiSAFactory.getDefaultFor(TypeDomain.class)); + DefaultConfiguration.defaultTypeDomain()); conf.serializeResults = true; conf.openCallPolicy = ReturnTopPolicy.INSTANCE; conf.callGraph = new RTACallGraph(); diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/traces/TracePartitioningTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/traces/TracePartitioningTest.java index eb4ae654b..dc591a870 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/traces/TracePartitioningTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/traces/TracePartitioningTest.java @@ -1,27 +1,19 @@ package it.unive.lisa.cron.traces; +import org.junit.Test; + import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.LiSAFactory; -import it.unive.lisa.analysis.SimpleAbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.nonrelational.value.ValueEnvironment; -import it.unive.lisa.analysis.numeric.Interval; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.traces.TracePartitioning; -import it.unive.lisa.analysis.value.TypeDomain; -import org.junit.Test; public class TracePartitioningTest extends AnalysisTestExecutor { @Test public void testTracePartitioning() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); - conf.abstractState = new TracePartitioning<>( - new SimpleAbstractState<>( - LiSAFactory.getDefaultFor(HeapDomain.class), - new ValueEnvironment<>(new Interval()), - LiSAFactory.getDefaultFor(TypeDomain.class))); + conf.abstractState = new TracePartitioning<>(DefaultConfiguration.defaultAbstractState()); conf.serializeResults = true; int prev = TracePartitioning.MAX_LOOP_ITERATIONS; TracePartitioning.MAX_LOOP_ITERATIONS = 3; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/typeInference/TypesCollectionTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/typeInference/TypesCollectionTest.java index 8f8901f3f..841d34e81 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/typeInference/TypesCollectionTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/typeInference/TypesCollectionTest.java @@ -1,25 +1,22 @@ package it.unive.lisa.cron.typeInference; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import org.junit.Test; import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.analysis.nonrelational.value.TypeEnvironment; import it.unive.lisa.analysis.types.InferredTypes; -import it.unive.lisa.analysis.value.ValueDomain; -import org.junit.Test; public class TypesCollectionTest extends AnalysisTestExecutor { @Test public void testTypesCollection() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); conf.serializeResults = true; - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - getDefaultFor(ValueDomain.class), + conf.abstractState = DefaultConfiguration.simpleState( + DefaultConfiguration.defaultHeapDomain(), + DefaultConfiguration.defaultValueDomain(), new TypeEnvironment<>(new InferredTypes())); conf.testDir = "type-inference"; conf.programFile = "program.imp"; diff --git a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/visualization/VisualizationTest.java b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/visualization/VisualizationTest.java index 9b21fbf12..c510d5aaa 100644 --- a/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/visualization/VisualizationTest.java +++ b/lisa/lisa-analyses/src/test/java/it/unive/lisa/cron/visualization/VisualizationTest.java @@ -1,32 +1,27 @@ package it.unive.lisa.cron.visualization; -import static it.unive.lisa.LiSAFactory.getDefaultFor; import static org.junit.Assert.assertTrue; +import java.util.Collection; +import java.util.HashSet; + +import org.junit.AfterClass; +import org.junit.Test; + import it.unive.lisa.AnalysisSetupException; import it.unive.lisa.AnalysisTestExecutor; import it.unive.lisa.CronConfiguration; -import it.unive.lisa.analysis.AbstractState; -import it.unive.lisa.analysis.heap.HeapDomain; -import it.unive.lisa.analysis.value.TypeDomain; -import it.unive.lisa.analysis.value.ValueDomain; +import it.unive.lisa.DefaultConfiguration; import it.unive.lisa.conf.LiSAConfiguration.GraphType; import it.unive.lisa.interprocedural.callgraph.RTACallGraph; import it.unive.lisa.interprocedural.context.ContextBasedAnalysis; import it.unive.lisa.interprocedural.context.FullStackToken; -import java.util.Collection; -import java.util.HashSet; -import org.junit.AfterClass; -import org.junit.Test; public class VisualizationTest extends AnalysisTestExecutor { private static CronConfiguration config() throws AnalysisSetupException { CronConfiguration conf = new CronConfiguration(); - conf.abstractState = getDefaultFor(AbstractState.class, - getDefaultFor(HeapDomain.class), - getDefaultFor(ValueDomain.class), - getDefaultFor(TypeDomain.class)); + conf.abstractState = DefaultConfiguration.defaultAbstractState(); conf.interproceduralAnalysis = new ContextBasedAnalysis<>(FullStackToken.getSingleton()); conf.callGraph = new RTACallGraph(); return conf; diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultImplementation.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultImplementation.java deleted file mode 100644 index 082e7ec0b..000000000 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultImplementation.java +++ /dev/null @@ -1,21 +0,0 @@ -package it.unive.lisa; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation that lets one define default implementations for analysis - * components. {@link LiSAFactory#getDefaultFor(Class, Object...)} will search - * for subtypes of the given class that are annotated with this annotation to - * create compatible implementations. If none is found, {@link LiSAFactory} will - * instead search for types annotated as {@link FallbackImplementation}, an - * annotation reserved for LiSA to define its own defaults. - * - * @author Luca Negrini - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface DefaultImplementation { -} diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultParameters.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultParameters.java deleted file mode 100644 index 8f110932e..000000000 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/DefaultParameters.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.unive.lisa; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation that lets one define default parameters types for analysis - * components' implementations. Each parameter is specified through it's class - * object. {@link LiSAFactory#getInstance(Class, Object...)} will be used to - * generate objects for each specified parameter, and will pass them to a - * compatible constructor to create the annotated class. - * - * @author Luca Negrini - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface DefaultParameters { - - /** - * The array of types of each parameter needed to construct the annotated - * type. Each of them will be instantiated by - * {@link LiSAFactory#getInstance(Class, Object...)}. - * - * @return the types - */ - Class[] value() default {}; -} diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/FallbackImplementation.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/FallbackImplementation.java deleted file mode 100644 index 3ecaf2ec2..000000000 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/FallbackImplementation.java +++ /dev/null @@ -1,21 +0,0 @@ -package it.unive.lisa; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation reserved for LiSA to define its own default implementations for - * analysis components. {@link LiSAFactory#getDefaultFor(Class, Object...)} will - * search for subtypes of the given class that are annotated with - * {@link DefaultImplementation} to create compatible implementations. If none - * is found, {@link LiSAFactory} will instead search for types annotated with - * this annotation. - * - * @author Luca Negrini - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface FallbackImplementation { -} diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSA.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSA.java index 4285495ab..fc1998b6e 100644 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSA.java +++ b/lisa/lisa-sdk/src/main/java/it/unive/lisa/LiSA.java @@ -1,21 +1,19 @@ package it.unive.lisa; -import static it.unive.lisa.LiSAFactory.getDefaultFor; +import java.io.IOException; +import java.util.Collection; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.joda.time.DateTime; import it.unive.lisa.checks.warnings.Warning; import it.unive.lisa.conf.LiSAConfiguration; -import it.unive.lisa.interprocedural.InterproceduralAnalysis; -import it.unive.lisa.interprocedural.callgraph.CallGraph; import it.unive.lisa.logging.TimerLogger; import it.unive.lisa.outputs.json.JsonReport; import it.unive.lisa.program.Application; import it.unive.lisa.program.Program; import it.unive.lisa.util.file.FileManager; -import java.io.IOException; -import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.joda.time.DateTime; /** * This is the central class of the LiSA library. While LiSA's functionalities @@ -70,28 +68,7 @@ public LiSAReport run(Program... programs) throws AnalysisException { LOG.info(conf.toString()); DateTime start = new DateTime(); - - CallGraph callGraph; - try { - callGraph = conf.callGraph == null ? getDefaultFor(CallGraph.class) : conf.callGraph; - if (conf.callGraph == null) - LOG.warn("No call graph set for this analysis, defaulting to {}", callGraph.getClass().getSimpleName()); - } catch (AnalysisSetupException e) { - throw new AnalysisExecutionException("Unable to create default call graph", e); - } - - InterproceduralAnalysis interproc; - try { - interproc = conf.interproceduralAnalysis == null ? getDefaultFor(InterproceduralAnalysis.class) - : conf.interproceduralAnalysis; - if (conf.interproceduralAnalysis == null) - LOG.warn("No interprocedural analysis set for this analysis, defaulting to {}", - interproc.getClass().getSimpleName()); - } catch (AnalysisSetupException e) { - throw new AnalysisExecutionException("Unable to create default interprocedural analysis", e); - } - - LiSARunner runner = new LiSARunner(conf, interproc, callGraph, conf.abstractState); + LiSARunner runner = new LiSARunner(conf, conf.interproceduralAnalysis, conf.callGraph, conf.abstractState); Application app = new Application(programs); Collection warnings; diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/conf/LiSAConfiguration.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/conf/LiSAConfiguration.java index 5f4a2923f..677690d05 100644 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/conf/LiSAConfiguration.java +++ b/lisa/lisa-sdk/src/main/java/it/unive/lisa/conf/LiSAConfiguration.java @@ -1,7 +1,6 @@ package it.unive.lisa.conf; import it.unive.lisa.LiSA; -import it.unive.lisa.LiSAFactory; import it.unive.lisa.analysis.AbstractState; import it.unive.lisa.analysis.Lattice; import it.unive.lisa.checks.semantic.SemanticCheck;