MCPcopy Create free account
hub / github.com/LFYSec/MScan / CSCallGraph

Class CSCallGraph

src/main/java/pascal/taie/analysis/pta/core/cs/CSCallGraph.java:45–145  ·  view source on GitHub ↗

Represents context-sensitive call graph.

Source from the content-addressed store, hash-verified

43 * Represents context-sensitive call graph.
44 */
45public class CSCallGraph extends AbstractCallGraph<CSCallSite, CSMethod> {
46
47 private final CSManager csManager;
48
49 public CSCallGraph(CSManager csManager) {
50 this.csManager = csManager;
51 }
52
53 /**
54 * Adds an entry method to this call graph.
55 */
56 public void addEntryMethod(CSMethod entryMethod) {
57 entryMethods.add(entryMethod);
58 }
59
60 /**
61 * Adds a reachable method to this call graph.
62 *
63 * @return true if this call graph changed as a result of the call,
64 * otherwise false.
65 */
66 public boolean addReachableMethod(CSMethod csMethod) {
67 return reachableMethods.add(csMethod);
68 }
69
70 /**
71 * Adds a new call graph edge to this call graph.
72 *
73 * @param edge the call edge to be added
74 * @return true if the call graph changed as a result of the call,
75 * otherwise false.
76 */
77 public boolean addEdge(Edge<CSCallSite, CSMethod> edge) {
78 if (edge.getCallSite().addEdge(edge)) {
79 edge.getCallee().addEdge(edge);
80 return true;
81 } else {
82 return false;
83 }
84 }
85
86 @Override
87 public Set<CSCallSite> getCallersOf(CSMethod callee) {
88 return Views.toMappedSet(callee.getEdges(), Edge::getCallSite);
89 }
90
91 @Override
92 public Set<CSMethod> getCalleesOf(CSCallSite csCallSite) {
93 return Views.toMappedSet(csCallSite.getEdges(), Edge::getCallee);
94 }
95
96 @Override
97 public CSMethod getContainerOf(CSCallSite csCallSite) {
98 return csCallSite.getContainer();
99 }
100
101 @Override
102 public Set<CSCallSite> getCallSitesIn(CSMethod csMethod) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected