Skip to content

Commit

Permalink
fix: implemented TODO targeting InvokeInst
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Oct 23, 2024
1 parent 492e9aa commit 44d96a5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions DiscoPoP/static_analysis/createCUs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,9 @@ void DiscoPoP::createCUs(Region *TopRegion, set<string> &globalVariablesSet, vec
cu->readPhaseLineNumbers.insert(lid);
}
}
} else if (isa<CallInst>(instruction)) {
} else if (isa<CallInst>(instruction) || isa<InvokeInst>(instruction)) {
// get the name of the called function and check if a FileIO function
// is called
CallInst *ci = cast<CallInst>(instruction);
set<string> IOFunctions{
"fopen", "fopen_s", "freopen", "freopen_s", "fclose", "fflush", "setbuf",
"setvbuf", "fwide", "fread", "fwrite", "fgetc", "getc", "fgets",
Expand All @@ -223,6 +222,8 @@ void DiscoPoP::createCUs(Region *TopRegion, set<string> &globalVariablesSet, vec
"vswprintf_s", "vsnwprintf_s", "ftell", "fgetpos", "fseek", "fsetpos", "rewind",
"clearerr", "feof", "ferror", "perror", "remove", "rename", "tmpfile",
"tmpfile_s", "tmpnam", "tmpnam_s", "__isoc99_fscanf"};

CallBase *ci = cast<CallBase>(instruction);
if (ci) {
if (ci->getCalledFunction()) {
if (ci->getCalledFunction()->hasName()) {
Expand Down Expand Up @@ -255,10 +256,17 @@ void DiscoPoP::createCUs(Region *TopRegion, set<string> &globalVariablesSet, vec
// Note: Don't create nodes for library functions (c++/llvm).
LID lid = getLID(&*instruction, fileID);
if (lid > 0) {
if (isa<CallInst>(instruction)) {
CallInst *ci = cast<CallInst>(instruction);
Function *f = ci->getCalledFunction();
// TODO: DO the same for Invoke inst
if (isa<CallInst>(instruction) || isa<InvokeInst>(instruction)) {
Function *f;

if(isa<CallInst>(instruction)){
CallInst *ci = cast<CallInst>(instruction);
f = ci->getCalledFunction();
}
else if(isa<InvokeInst>(instruction)){
InvokeInst *ci = cast<InvokeInst>(instruction);
f = ci->getCalledFunction();
}

string lid;
if (f) {
Expand Down

0 comments on commit 44d96a5

Please sign in to comment.