From 44d96a5be23e64e5c361cd4c3a41249c094d9dab Mon Sep 17 00:00:00 2001 From: Lukas Rothenberger Date: Mon, 12 Aug 2024 16:03:19 +0200 Subject: [PATCH] fix: implemented TODO targeting InvokeInst --- DiscoPoP/static_analysis/createCUs.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/DiscoPoP/static_analysis/createCUs.cpp b/DiscoPoP/static_analysis/createCUs.cpp index 3f972fc5f..fcf09a27d 100644 --- a/DiscoPoP/static_analysis/createCUs.cpp +++ b/DiscoPoP/static_analysis/createCUs.cpp @@ -203,10 +203,9 @@ void DiscoPoP::createCUs(Region *TopRegion, set &globalVariablesSet, vec cu->readPhaseLineNumbers.insert(lid); } } - } else if (isa(instruction)) { + } else if (isa(instruction) || isa(instruction)) { // get the name of the called function and check if a FileIO function // is called - CallInst *ci = cast(instruction); set IOFunctions{ "fopen", "fopen_s", "freopen", "freopen_s", "fclose", "fflush", "setbuf", "setvbuf", "fwide", "fread", "fwrite", "fgetc", "getc", "fgets", @@ -223,6 +222,8 @@ void DiscoPoP::createCUs(Region *TopRegion, set &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(instruction); if (ci) { if (ci->getCalledFunction()) { if (ci->getCalledFunction()->hasName()) { @@ -255,10 +256,17 @@ void DiscoPoP::createCUs(Region *TopRegion, set &globalVariablesSet, vec // Note: Don't create nodes for library functions (c++/llvm). LID lid = getLID(&*instruction, fileID); if (lid > 0) { - if (isa(instruction)) { - CallInst *ci = cast(instruction); - Function *f = ci->getCalledFunction(); - // TODO: DO the same for Invoke inst + if (isa(instruction) || isa(instruction)) { + Function *f; + + if(isa(instruction)){ + CallInst *ci = cast(instruction); + f = ci->getCalledFunction(); + } + else if(isa(instruction)){ + InvokeInst *ci = cast(instruction); + f = ci->getCalledFunction(); + } string lid; if (f) {