Skip to content

Commit 5cea75f

Browse files
committed
Fix get calls for the case the function is not a vertex.
For these two functions, the function (or the function of the corresponding instruction) may not be part of the callgraph. In the original code this resulted in an exception being thrown. With the modification an empty set is returned instead.
1 parent 3350ebc commit 5cea75f

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)