|
| 1 | +/* |
| 2 | + * Tai-e: A Static Analysis Framework for Java |
| 3 | + * |
| 4 | + * Copyright (C) 2022 Tian Tan <tiantan@nju.edu.cn> |
| 5 | + * Copyright (C) 2022 Yue Li <yueli@nju.edu.cn> |
| 6 | + * |
| 7 | + * This file is part of Tai-e. |
| 8 | + * |
| 9 | + * Tai-e is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License |
| 11 | + * as published by the Free Software Foundation, either version 3 |
| 12 | + * of the License, or (at your option) any later version. |
| 13 | + * |
| 14 | + * Tai-e is distributed in the hope that it will be useful,but WITHOUT |
| 15 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General |
| 17 | + * Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Lesser General Public |
| 20 | + * License along with Tai-e. If not, see <https://www.gnu.org/licenses/>. |
| 21 | + */ |
| 22 | + |
| 23 | +package pascal.taie.analysis.pta.plugin.natives; |
| 24 | + |
| 25 | +import pascal.taie.analysis.pta.core.solver.Solver; |
| 26 | +import pascal.taie.analysis.pta.plugin.util.IRModelPlugin; |
| 27 | +import pascal.taie.analysis.pta.plugin.util.InvokeHandler; |
| 28 | +import pascal.taie.analysis.pta.plugin.util.InvokeUtils; |
| 29 | +import pascal.taie.ir.exp.Var; |
| 30 | +import pascal.taie.ir.stmt.Copy; |
| 31 | +import pascal.taie.ir.stmt.Invoke; |
| 32 | +import pascal.taie.ir.stmt.Stmt; |
| 33 | + |
| 34 | +import java.util.List; |
| 35 | + |
| 36 | +public class ObjectModel extends IRModelPlugin { |
| 37 | + ObjectModel(Solver solver) { |
| 38 | + super(solver); |
| 39 | + } |
| 40 | + |
| 41 | + @InvokeHandler(signature = "<java.lang.Object: java.lang.Object clone()>") |
| 42 | + public List<Stmt> objectClone(Invoke invoke) { |
| 43 | + Var result = invoke.getResult(); |
| 44 | + return result != null |
| 45 | + ? List.of(new Copy(result, InvokeUtils.getVar(invoke, InvokeUtils.BASE))) |
| 46 | + : List.of(); |
| 47 | + } |
| 48 | +} |
0 commit comments