Skip to content

Commit b92cd40

Browse files
committed
Model Object.clone() in PTA for better precision
1 parent 5dc8ae3 commit b92cd40

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

src/main/java/pascal/taie/analysis/pta/plugin/natives/NativeModeller.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void setSolver(Solver solver) {
3636
addPlugin(new ArrayModel.AnalysisModel(solver),
3737
new ArrayModel.IRModel(solver),
3838
new UnsafeModel(solver),
39-
new DoPriviledgedModel(solver));
39+
new DoPriviledgedModel(solver),
40+
new ObjectModel(solver));
4041
}
4142
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)