diff --git a/src/main/java/pascal/taie/analysis/pta/plugin/natives/NativeModeller.java b/src/main/java/pascal/taie/analysis/pta/plugin/natives/NativeModeller.java index 13b20248b..ea4edb64b 100644 --- a/src/main/java/pascal/taie/analysis/pta/plugin/natives/NativeModeller.java +++ b/src/main/java/pascal/taie/analysis/pta/plugin/natives/NativeModeller.java @@ -36,6 +36,7 @@ public void setSolver(Solver solver) { addPlugin(new ArrayModel.AnalysisModel(solver), new ArrayModel.IRModel(solver), new UnsafeModel(solver), - new DoPriviledgedModel(solver)); + new DoPriviledgedModel(solver), + new ObjectCloneModel(solver)); } } diff --git a/src/main/java/pascal/taie/analysis/pta/plugin/natives/ObjectCloneModel.java b/src/main/java/pascal/taie/analysis/pta/plugin/natives/ObjectCloneModel.java new file mode 100644 index 000000000..ee22e9088 --- /dev/null +++ b/src/main/java/pascal/taie/analysis/pta/plugin/natives/ObjectCloneModel.java @@ -0,0 +1,48 @@ +/* + * Tai-e: A Static Analysis Framework for Java + * + * Copyright (C) 2022 Tian Tan + * Copyright (C) 2022 Yue Li + * + * This file is part of Tai-e. + * + * Tai-e is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Tai-e is distributed in the hope that it will be useful,but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Tai-e. If not, see . + */ + +package pascal.taie.analysis.pta.plugin.natives; + +import pascal.taie.analysis.pta.core.solver.Solver; +import pascal.taie.analysis.pta.plugin.util.IRModelPlugin; +import pascal.taie.analysis.pta.plugin.util.InvokeHandler; +import pascal.taie.analysis.pta.plugin.util.InvokeUtils; +import pascal.taie.ir.exp.Var; +import pascal.taie.ir.stmt.Copy; +import pascal.taie.ir.stmt.Invoke; +import pascal.taie.ir.stmt.Stmt; + +import java.util.List; + +public class ObjectCloneModel extends IRModelPlugin { + ObjectCloneModel(Solver solver) { + super(solver); + } + + @InvokeHandler(signature = "") + public List objectClone(Invoke invoke) { + Var result = invoke.getResult(); + return result != null + ? List.of(new Copy(result, InvokeUtils.getVar(invoke, InvokeUtils.BASE))) + : List.of(); + } +}