diff --git a/base/src/main/java/proguard/analysis/cpa/interfaces/AbstractState.java b/base/src/main/java/proguard/analysis/cpa/interfaces/AbstractState.java index 96cb65c4b..13d9281c6 100644 --- a/base/src/main/java/proguard/analysis/cpa/interfaces/AbstractState.java +++ b/base/src/main/java/proguard/analysis/cpa/interfaces/AbstractState.java @@ -33,14 +33,6 @@ default Precision getPrecision() { /** Creates a copy of itself. */ AbstractState copy(); - /** - * Returns an abstract state for a given {@param name} if the state is composite, returns {@code - * self} otherwise. - */ - default AbstractState getStateByName(String name) { - return this; - } - // overrides for Object @Override diff --git a/base/src/main/java/proguard/analysis/cpa/jvm/domain/memory/JvmMemoryLocationTransferRelation.java b/base/src/main/java/proguard/analysis/cpa/jvm/domain/memory/JvmMemoryLocationTransferRelation.java index c4d341ab3..2bf0ef7d6 100644 --- a/base/src/main/java/proguard/analysis/cpa/jvm/domain/memory/JvmMemoryLocationTransferRelation.java +++ b/base/src/main/java/proguard/analysis/cpa/jvm/domain/memory/JvmMemoryLocationTransferRelation.java @@ -59,7 +59,6 @@ import proguard.analysis.cpa.jvm.witness.JvmMemoryLocation; import proguard.analysis.cpa.jvm.witness.JvmStackLocation; import proguard.analysis.cpa.jvm.witness.JvmStaticFieldLocation; -import proguard.analysis.cpa.util.StateNames; import proguard.analysis.datastructure.callgraph.Call; import proguard.classfile.AccessConstants; import proguard.classfile.Clazz; @@ -254,8 +253,7 @@ public Collection generateAbstractSuccessors( } JvmAbstractState returnJvmAbstractState = - (JvmAbstractState) - returnState.get().getStateByName(StateNames.Jvm); + (JvmAbstractState) returnState.get(); AbstractStateT value = state .getLocationDependentMemoryLocation() @@ -334,8 +332,7 @@ public Collection generateAbstractSuccessors( successors.addAll( getSuccessorsFromMemoryLocations( intraproceduralSuccessorMemoryLocations, - (JvmAbstractState) - intraproceduralParentState.get().getStateByName(StateNames.Jvm), + (JvmAbstractState) intraproceduralParentState.get(), state.getSourceReachedSet(), state.copyStack())); } @@ -366,8 +363,7 @@ public Collection generateAbstractSuccessors( ci -> getSuccessorsFromMemoryLocations( Collections.singletonList(callerMemoryLocation.get()), - (JvmAbstractState) - ci.state.getStateByName(StateNames.Jvm), + (JvmAbstractState) ci.state, ci.reachedSet, new LinkedList<>()) .stream() @@ -380,8 +376,7 @@ public Collection generateAbstractSuccessors( successors.addAll( getSuccessorsFromMemoryLocations( Collections.singletonList(callerMemoryLocation.get()), - (JvmAbstractState) - currentEntry.callerState.getStateByName(StateNames.Jvm), + (JvmAbstractState) currentEntry.callerState, currentEntry.reachedSet, successorStack)); } @@ -834,8 +829,7 @@ public void visitConstantInstruction( memoryLocation, constantInstruction, clazz, - ((JvmAbstractState) parentState.getStateByName(StateNames.Jvm)) - .getProgramLocation())); + ((JvmAbstractState) parentState).getProgramLocation())); break; case Instruction.OP_NEW: case Instruction.OP_NEWARRAY: diff --git a/base/src/main/java/proguard/analysis/cpa/util/StateNames.java b/base/src/main/java/proguard/analysis/cpa/util/StateNames.java deleted file mode 100644 index 2cf8f1606..000000000 --- a/base/src/main/java/proguard/analysis/cpa/util/StateNames.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ProGuardCORE -- library to process Java bytecode. - * - * Copyright (c) 2002-2022 Guardsquare NV - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package proguard.analysis.cpa.util; - -import proguard.analysis.cpa.interfaces.AbstractState; - -/** - * Names of abstract states used for state extraction with {@link - * AbstractState#getStateByName(String)}. - * - * @author Dmitry Ivanov - */ -public interface StateNames { - - String Jvm = "Jvm"; - String Reference = "Reference"; -} diff --git a/base/src/main/java/proguard/analysis/cpa/util/TaintAnalyzerResult.java b/base/src/main/java/proguard/analysis/cpa/util/TaintAnalyzerResult.java index b6cf33feb..af2703879 100644 --- a/base/src/main/java/proguard/analysis/cpa/util/TaintAnalyzerResult.java +++ b/base/src/main/java/proguard/analysis/cpa/util/TaintAnalyzerResult.java @@ -217,8 +217,7 @@ public BamCache getTaintResultCache() { .asCollection() .forEach( state -> - ((JvmAbstractState>) - state.getStateByName(StateNames.Jvm)) + ((JvmAbstractState>) state) .getProgramLocation() .getLeavingEdges() .forEach( @@ -267,8 +266,7 @@ private void createEndpointsForEdgeIfTainted( .filter( memoryLocation -> isStateTaintedForMemoryLocation( - (JvmAbstractState>) - state.getStateByName(StateNames.Jvm), + (JvmAbstractState>) state, memoryLocation, sinkToMemoryLocations.getKey())) .forEach( diff --git a/docs/md/releasenotes.md b/docs/md/releasenotes.md index 2b65d8571..864691532 100644 --- a/docs/md/releasenotes.md +++ b/docs/md/releasenotes.md @@ -31,6 +31,7 @@ make its usage easier. This includes: - Remove `JvmTaintMemoryLocationBamCpaRun` in order to simplify the utility code to run the analysis. `TaintAnalyzer` is the direct replacement, this class has the same behavior as `JvmTaintMemoryLocationBamCpaRun`, as long as `analyze` is called only once. - Remove the `CpaRun` infrastructure. - Remove `MapAbstractStateFactory`, `WrapperTransferRelation`, and other classes that were only used with the tree heap model. +- Remove `StateNames` and `getStateByName`. ## Version 9.1.6