Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: implemented TODO targeting InvokeInst #653

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading