Skip to content

Commit 215b8fa

Browse files
authored
Merge pull request #82 from ddiepo-pjr/fixCallgraphGet
Fix get calls for the case the function is not a vertex.
2 parents 3350ebc + 5cea75f commit 215b8fa

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lib/PhasarLLVM/ControlFlow/LLVMBasedICFG.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,13 @@ set<const llvm::Function *>
281281
LLVMBasedICFG::getCalleesOfCallAt(const llvm::Instruction *n) const {
282282
if (llvm::isa<llvm::CallInst>(n) || llvm::isa<llvm::InvokeInst>(n)) {
283283
set<const llvm::Function *> Callees;
284-
auto Caller = n->getFunction();
284+
auto mapEntry = FunctionVertexMap.find(n->getFunction());
285+
if (mapEntry == FunctionVertexMap.end()) {
286+
return Callees;
287+
}
285288
out_edge_iterator ei, ei_end;
286289
for (boost::tie(ei, ei_end) =
287-
boost::out_edges(FunctionVertexMap.at(Caller), CallGraph);
290+
boost::out_edges(mapEntry->second, CallGraph);
288291
ei != ei_end; ++ei) {
289292
auto source = boost::source(*ei, CallGraph);
290293
auto edge = CallGraph[*ei];
@@ -305,9 +308,13 @@ LLVMBasedICFG::getCalleesOfCallAt(const llvm::Instruction *n) const {
305308
set<const llvm::Instruction *>
306309
LLVMBasedICFG::getCallersOf(const llvm::Function *F) const {
307310
set<const llvm::Instruction *> CallersOf;
311+
auto mapEntry = FunctionVertexMap.find(F);
312+
if (mapEntry == FunctionVertexMap.end()) {
313+
return CallersOf;
314+
}
308315
in_edge_iterator ei, ei_end;
309316
for (boost::tie(ei, ei_end) =
310-
boost::in_edges(FunctionVertexMap.at(F), CallGraph);
317+
boost::in_edges(mapEntry->second, CallGraph);
311318
ei != ei_end; ++ei) {
312319
auto source = boost::source(*ei, CallGraph);
313320
auto edge = CallGraph[*ei];

0 commit comments

Comments
 (0)