Skip to content

Commit 725d816

Browse files
Merge pull request #158 from UniVE-SSV/native-calls-removal
Native calls removal
2 parents 943c8e5 + 523cd61 commit 725d816

File tree

74 files changed

+1446
-1355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1446
-1355
lines changed

lisa/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,13 @@ buildscript {
5858
classpath 'org.ajoberstar.grgit:grgit-core:4.0.2'
5959
classpath 'org.ajoberstar.grgit:grgit-gradle:4.0.2'
6060

61-
classpath 'com.github.roroche:plantuml-gradle-plugin:1.0.2'
62-
classpath 'gradle.plugin.org.fmiw:plantuml-gradle-plugin:0.1'
63-
6461
classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.15.0'
6562
}
6663
}
6764

6865
subprojects {
6966
apply plugin: 'java-library'
7067
apply plugin: 'eclipse'
71-
apply plugin: 'com.github.roroche.plantuml' // generation of plantuml from source code (visualization: https://www.planttext.com/)
72-
apply plugin: 'org.fmiw.plantuml' // plantuml to png
7368
apply plugin: 'org.ajoberstar.grgit' // parse git information during the build
7469
apply plugin: 'com.diffplug.spotless' // code formatting task
7570
apply plugin: 'checkstyle' // javadoc checking - coding conventions
@@ -78,7 +73,6 @@ subprojects {
7873
apply plugin: 'jacoco' // coverage reports
7974

8075
apply from: "${project.rootDir}/code-style.gradle"
81-
apply from: "${project.rootDir}/doc-extra.gradle"
8276
apply from: "${project.rootDir}/java.gradle"
8377
apply from: "${project.rootDir}/publishing.gradle"
8478
}

lisa/doc-extra.gradle

Lines changed: 0 additions & 50 deletions
This file was deleted.

lisa/lisa-core/src/main/java/it/unive/lisa/interprocedural/ModularWorstCaseAnalysis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Collection<CFGWithAnalysisResults<A, H, V>> getAnalysisResultsOf(CFG cfg)
103103
@Override
104104
public AnalysisState<A, H, V> getAbstractResultOf(CFGCall call, AnalysisState<A, H, V> entryState,
105105
ExpressionSet<SymbolicExpression>[] parameters) throws SemanticException {
106-
OpenCall open = new OpenCall(call.getCFG(), call.getLocation(), call.getQualifiedName(),
106+
OpenCall open = new OpenCall(call.getCFG(), call.getLocation(), call.getTargetName(),
107107
call.getStaticType(), call.getParameters());
108108
return getAbstractResultOf(open, entryState, parameters);
109109
}

lisa/lisa-core/src/test/java/it/unive/lisa/EqualityContractVerificationTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure;
4646
import it.unive.lisa.program.cfg.edge.Edge;
4747
import it.unive.lisa.program.cfg.statement.Expression;
48+
import it.unive.lisa.program.cfg.statement.NaryExpression;
4849
import it.unive.lisa.program.cfg.statement.PluggableStatement;
4950
import it.unive.lisa.program.cfg.statement.Ret;
5051
import it.unive.lisa.program.cfg.statement.Statement;
@@ -272,6 +273,8 @@ public void testStatements() {
272273
extra.add("originating");
273274
if (Call.class.isAssignableFrom(st))
274275
extra.add("source");
276+
if (NaryExpression.class.isAssignableFrom(st))
277+
extra.add("order");
275278
verify(st,
276279
verifier -> verifier
277280
.withIgnoredFields(ListUtils.union(expressionFields, extra).toArray(String[]::new)),

lisa/lisa-imp/src/main/java/it/unive/lisa/imp/expressions/IMPAddOrConcat.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import it.unive.lisa.program.SourceCodeLocation;
1212
import it.unive.lisa.program.cfg.CFG;
1313
import it.unive.lisa.program.cfg.statement.Expression;
14-
import it.unive.lisa.program.cfg.statement.call.BinaryNativeCall;
1514
import it.unive.lisa.symbolic.SymbolicExpression;
1615
import it.unive.lisa.symbolic.value.BinaryExpression;
1716
import it.unive.lisa.symbolic.value.operator.binary.BinaryOperator;
@@ -35,7 +34,7 @@
3534
*
3635
* @author <a href="mailto:[email protected]">Luca Negrini</a>
3736
*/
38-
public class IMPAddOrConcat extends BinaryNativeCall {
37+
public class IMPAddOrConcat extends it.unive.lisa.program.cfg.statement.BinaryExpression {
3938

4039
/**
4140
* Builds the addition.
@@ -55,14 +54,12 @@ public IMPAddOrConcat(CFG cfg, String sourceFile, int line, int col, Expression
5554
protected <A extends AbstractState<A, H, V>,
5655
H extends HeapDomain<H>,
5756
V extends ValueDomain<V>> AnalysisState<A, H, V> binarySemantics(
58-
AnalysisState<A, H, V> entryState,
5957
InterproceduralAnalysis<A, H, V> interprocedural,
60-
AnalysisState<A, H, V> leftState,
58+
AnalysisState<A, H, V> state,
6159
SymbolicExpression left,
62-
AnalysisState<A, H, V> rightState,
6360
SymbolicExpression right)
6461
throws SemanticException {
65-
AnalysisState<A, H, V> result = entryState.bottom();
62+
AnalysisState<A, H, V> result = state.bottom();
6663
BinaryOperator op;
6764

6865
for (Type tleft : left.getTypes())
@@ -92,7 +89,7 @@ else if (tright.isNumericType() || tright.isUntyped())
9289
if (op == null)
9390
continue;
9491

95-
result = result.lub(rightState.smallStepSemantics(
92+
result = result.lub(state.smallStepSemantics(
9693
new BinaryExpression(
9794
op == StringConcat.INSTANCE
9895
? Caches.types().mkSingletonSet(StringType.INSTANCE)

lisa/lisa-imp/src/main/java/it/unive/lisa/imp/expressions/IMPArrayAccess.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import it.unive.lisa.interprocedural.InterproceduralAnalysis;
99
import it.unive.lisa.program.SourceCodeLocation;
1010
import it.unive.lisa.program.cfg.CFG;
11+
import it.unive.lisa.program.cfg.statement.BinaryExpression;
1112
import it.unive.lisa.program.cfg.statement.Expression;
12-
import it.unive.lisa.program.cfg.statement.call.BinaryNativeCall;
1313
import it.unive.lisa.symbolic.SymbolicExpression;
1414
import it.unive.lisa.symbolic.heap.AccessChild;
1515
import it.unive.lisa.symbolic.heap.HeapDereference;
@@ -21,7 +21,7 @@
2121
*
2222
* @author <a href="mailto:[email protected]">Luca Negrini</a>
2323
*/
24-
public class IMPArrayAccess extends BinaryNativeCall {
24+
public class IMPArrayAccess extends BinaryExpression {
2525

2626
/**
2727
* Builds the array access.
@@ -42,20 +42,19 @@ public IMPArrayAccess(CFG cfg, String sourceFile, int line, int col, Expression
4242
protected <A extends AbstractState<A, H, V>,
4343
H extends HeapDomain<H>,
4444
V extends ValueDomain<V>> AnalysisState<A, H, V> binarySemantics(
45-
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural,
46-
AnalysisState<A, H, V> leftState,
45+
InterproceduralAnalysis<A, H, V> interprocedural,
46+
AnalysisState<A, H, V> state,
4747
SymbolicExpression left,
48-
AnalysisState<A, H, V> rightState,
4948
SymbolicExpression right)
50-
5149
throws SemanticException {
50+
5251
if (!left.getDynamicType().isArrayType() && !left.getDynamicType().isUntyped())
53-
return entryState.bottom();
52+
return state.bottom();
5453
// it is not possible to detect the correct type of the field without
5554
// resolving it. we rely on the rewriting that will happen inside heap
5655
// domain to translate this into a variable that will have its correct
5756
// type
5857
HeapDereference deref = new HeapDereference(getRuntimeTypes(), left, getLocation());
59-
return rightState.smallStepSemantics(new AccessChild(getRuntimeTypes(), deref, right, getLocation()), this);
58+
return state.smallStepSemantics(new AccessChild(getRuntimeTypes(), deref, right, getLocation()), this);
6059
}
6160
}

lisa/lisa-imp/src/main/java/it/unive/lisa/imp/expressions/IMPNewArray.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import it.unive.lisa.program.SourceCodeLocation;
1212
import it.unive.lisa.program.cfg.CFG;
1313
import it.unive.lisa.program.cfg.statement.Expression;
14-
import it.unive.lisa.program.cfg.statement.call.NativeCall;
14+
import it.unive.lisa.program.cfg.statement.NaryExpression;
1515
import it.unive.lisa.symbolic.SymbolicExpression;
1616
import it.unive.lisa.symbolic.heap.HeapAllocation;
1717
import it.unive.lisa.symbolic.heap.HeapReference;
@@ -25,7 +25,7 @@
2525
*
2626
* @author <a href="mailto:[email protected]">Luca Negrini</a>
2727
*/
28-
public class IMPNewArray extends NativeCall {
28+
public class IMPNewArray extends NaryExpression {
2929

3030
/**
3131
* Builds the array allocation.
@@ -39,31 +39,24 @@ public class IMPNewArray extends NativeCall {
3939
*/
4040
public IMPNewArray(CFG cfg, String sourceFile, int line, int col, Type type, Expression[] dimensions) {
4141
super(cfg, new SourceCodeLocation(sourceFile, line, col), "new " + type + "[]",
42-
ArrayType.lookup(type, dimensions.length),
43-
dimensions);
42+
ArrayType.lookup(type, dimensions.length), dimensions);
4443
}
4544

4645
@Override
4746
public <A extends AbstractState<A, H, V>,
4847
H extends HeapDomain<H>,
49-
V extends ValueDomain<V>> AnalysisState<A, H, V> callSemantics(
50-
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural,
51-
AnalysisState<A, H, V>[] computedStates,
48+
V extends ValueDomain<V>> AnalysisState<A, H, V> expressionSemantics(
49+
InterproceduralAnalysis<A, H, V> interprocedural,
50+
AnalysisState<A, H, V> state,
5251
ExpressionSet<SymbolicExpression>[] params)
5352
throws SemanticException {
54-
// it corresponds to the analysis state after the evaluation of all the
55-
// parameters of this call
56-
// (the semantics of this call does not need information about the
57-
// intermediate analysis states)
58-
AnalysisState<A, H,
59-
V> lastPostState = computedStates.length == 0 ? entryState : computedStates[computedStates.length - 1];
60-
AnalysisState<A, H,
61-
V> sem = lastPostState.smallStepSemantics(new HeapAllocation(getRuntimeTypes(), getLocation()), this);
53+
HeapAllocation alloc = new HeapAllocation(getRuntimeTypes(), getLocation());
54+
AnalysisState<A, H, V> sem = state.smallStepSemantics(alloc, this);
6255

63-
AnalysisState<A, H, V> result = entryState.bottom();
56+
AnalysisState<A, H, V> result = state.bottom();
6457
for (SymbolicExpression loc : sem.getComputedExpressions()) {
65-
AnalysisState<A, H,
66-
V> refSem = sem.smallStepSemantics(new HeapReference(loc.getTypes(), loc, getLocation()), this);
58+
HeapReference ref = new HeapReference(loc.getTypes(), loc, getLocation());
59+
AnalysisState<A, H, V> refSem = sem.smallStepSemantics(ref, this);
6760
result = result.lub(refSem);
6861
}
6962

lisa/lisa-imp/src/main/java/it/unive/lisa/imp/expressions/IMPNewObj.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import it.unive.lisa.program.SourceCodeLocation;
1212
import it.unive.lisa.program.cfg.CFG;
1313
import it.unive.lisa.program.cfg.statement.Expression;
14+
import it.unive.lisa.program.cfg.statement.NaryExpression;
1415
import it.unive.lisa.program.cfg.statement.VariableRef;
15-
import it.unive.lisa.program.cfg.statement.call.NativeCall;
1616
import it.unive.lisa.program.cfg.statement.call.UnresolvedCall;
1717
import it.unive.lisa.symbolic.SymbolicExpression;
1818
import it.unive.lisa.symbolic.heap.HeapAllocation;
@@ -32,7 +32,7 @@
3232
*
3333
* @author <a href="mailto:[email protected]">Luca Negrini</a>
3434
*/
35-
public class IMPNewObj extends NativeCall {
35+
public class IMPNewObj extends NaryExpression {
3636

3737
/**
3838
* Builds the object allocation and initialization.
@@ -51,30 +51,29 @@ public IMPNewObj(CFG cfg, String sourceFile, int line, int col, Type type, Expre
5151
@Override
5252
public <A extends AbstractState<A, H, V>,
5353
H extends HeapDomain<H>,
54-
V extends ValueDomain<V>> AnalysisState<A, H, V> callSemantics(
55-
AnalysisState<A, H, V> entryState, InterproceduralAnalysis<A, H, V> interprocedural,
56-
AnalysisState<A, H, V>[] computedStates,
54+
V extends ValueDomain<V>> AnalysisState<A, H, V> expressionSemantics(
55+
InterproceduralAnalysis<A, H, V> interprocedural,
56+
AnalysisState<A, H, V> state,
5757
ExpressionSet<SymbolicExpression>[] params)
5858
throws SemanticException {
5959
HeapAllocation created = new HeapAllocation(getRuntimeTypes(), getLocation());
6060

6161
// we need to add the receiver to the parameters
62-
VariableRef paramThis = new VariableRef(getCFG(), getLocation(), "this",
63-
getStaticType());
64-
Expression[] fullExpressions = ArrayUtils.insert(0, getParameters(), paramThis);
62+
VariableRef paramThis = new VariableRef(getCFG(), getLocation(), "this", getStaticType());
63+
Expression[] fullExpressions = ArrayUtils.insert(0, getSubExpressions(), paramThis);
6564
ExpressionSet<SymbolicExpression>[] fullParams = ArrayUtils.insert(0, params, new ExpressionSet<>(created));
6665

6766
UnresolvedCall call = new UnresolvedCall(getCFG(), getLocation(),
6867
IMPFrontend.CALL_STRATEGY, true, getStaticType().toString(), fullExpressions);
69-
call.inheritRuntimeTypesFrom(this);
70-
AnalysisState<A, H, V> sem = call.callSemantics(entryState, interprocedural, computedStates, fullParams);
68+
call.setRuntimeTypes(getRuntimeTypes());
69+
AnalysisState<A, H, V> sem = call.expressionSemantics(interprocedural, state, fullParams);
7170

7271
if (!call.getMetaVariables().isEmpty())
7372
sem = sem.forgetIdentifiers(call.getMetaVariables());
7473

7574
sem = sem.smallStepSemantics(created, this);
7675

77-
AnalysisState<A, H, V> result = entryState.bottom();
76+
AnalysisState<A, H, V> result = state.bottom();
7877
for (SymbolicExpression loc : sem.getComputedExpressions())
7978
result = result.lub(sem.smallStepSemantics(new HeapReference(loc.getTypes(), loc, getLocation()), call));
8079

lisa/lisa-sdk/src/main/java/it/unive/lisa/checks/warnings/WarningWithLocation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package it.unive.lisa.checks.warnings;
22

33
import it.unive.lisa.program.cfg.CodeLocation;
4+
import java.util.Objects;
45

56
/**
67
* A warning reported by LiSA on the program under analysis. This warning is
@@ -17,12 +18,12 @@ public abstract class WarningWithLocation extends Warning {
1718
/**
1819
* Builds the warning.
1920
*
20-
* @param location the location in the source file where this warning is
21-
* located. If unknown, use {@code, null}
21+
* @param location the location in the program where this warning is located
2222
* @param message the message of this warning
2323
*/
2424
protected WarningWithLocation(CodeLocation location, String message) {
2525
super(message);
26+
Objects.requireNonNull(location, "The location of a warning with location cannot be null");
2627
this.location = location;
2728
}
2829

lisa/lisa-sdk/src/main/java/it/unive/lisa/program/CodeElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
public interface CodeElement {
1313

1414
/**
15-
* Yields the location where this code element appears in the source file.
15+
* Yields the location where this code element appears in the program.
1616
*
17-
* @return the location where this code element apperars in the source file
17+
* @return the location where this code element apperars in the program
1818
*/
1919
CodeLocation getLocation();
2020
}

0 commit comments

Comments
 (0)