Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SuperReference #6910

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
import org.checkerframework.dataflow.expression.JavaExpression;
import org.checkerframework.dataflow.expression.LocalVariable;
import org.checkerframework.dataflow.expression.MethodCall;
import org.checkerframework.dataflow.expression.SuperReference;
import org.checkerframework.dataflow.expression.ThisReference;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.MonotonicQualifier;
@@ -494,6 +495,7 @@ protected void insertOrRefine(
public static boolean canInsertJavaExpression(JavaExpression expr) {
if (expr instanceof FieldAccess
|| expr instanceof ThisReference
|| expr instanceof SuperReference
|| expr instanceof LocalVariable
|| expr instanceof MethodCall
|| expr instanceof ArrayAccess
@@ -660,9 +662,8 @@ protected void computeNewValueAndInsert(
arrayValues.put(arrayAccess, newValue);
}
}
} else if (expr instanceof ThisReference) {
ThisReference thisRef = (ThisReference) expr;
if (sequentialSemantics || !thisRef.isAssignableByOtherCode()) {
} else if (expr instanceof ThisReference || expr instanceof SuperReference) {
if (sequentialSemantics || !expr.isAssignableByOtherCode()) {
V oldValue = thisValue;
V newValue = merger.apply(oldValue, value);
if (newValue != null) {
@@ -790,7 +791,7 @@ public void clearValue(JavaExpression expr) {
if (expr instanceof LocalVariable) {
LocalVariable localVar = (LocalVariable) expr;
return localVariableValues.get(localVar);
} else if (expr instanceof ThisReference) {
} else if (expr instanceof ThisReference || expr instanceof SuperReference) {
return thisValue;
} else if (expr instanceof FieldAccess) {
FieldAccess fieldAcc = (FieldAccess) expr;
@@ -823,7 +824,7 @@ public void clearValue(JavaExpression expr) {
return fieldValues.get((FieldAccess) je);
} else if (je instanceof ClassName) {
return classValues.get((ClassName) je);
} else if (je instanceof ThisReference) {
} else if (je instanceof ThisReference || je instanceof SuperReference) {
// "return thisValue" is wrong, because the node refers to an outer this.
// So, return null for now. TODO: improve.
return null;