From f98501e8d2439e60d4c3acca7801f42cb2331ee1 Mon Sep 17 00:00:00 2001 From: jumormt Date: Thu, 10 Oct 2024 10:37:25 +1100 Subject: [PATCH] refactor icfg builder --- svf-llvm/include/SVF-LLVM/ICFGBuilder.h | 4 ++-- svf-llvm/lib/ICFGBuilder.cpp | 3 ++- svf-llvm/lib/LLVMModule.cpp | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/svf-llvm/include/SVF-LLVM/ICFGBuilder.h b/svf-llvm/include/SVF-LLVM/ICFGBuilder.h index d8ab4b562..3f79ac767 100644 --- a/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +++ b/svf-llvm/include/SVF-LLVM/ICFGBuilder.h @@ -58,11 +58,11 @@ class ICFGBuilder public: typedef FIFOWorkList WorkList; - ICFGBuilder(ICFG* i): icfg(i) + ICFGBuilder(): icfg(new ICFG()) { } - void build(); + ICFG* build(); private: diff --git a/svf-llvm/lib/ICFGBuilder.cpp b/svf-llvm/lib/ICFGBuilder.cpp index ebafa4eca..7ac7d9614 100644 --- a/svf-llvm/lib/ICFGBuilder.cpp +++ b/svf-llvm/lib/ICFGBuilder.cpp @@ -40,7 +40,7 @@ using namespace SVFUtil; /*! * Create ICFG nodes and edges */ -void ICFGBuilder::build() +ICFG* ICFGBuilder::build() { DBOUT(DGENERAL, outs() << pasMsg("\t Building ICFG ...\n")); // Add the unique global ICFGNode at the entry of a program (before the main method). @@ -78,6 +78,7 @@ void ICFGBuilder::build() } connectGlobalToProgEntry(); + return icfg; } void ICFGBuilder::checkICFGNodesVisited(const Function* fun) diff --git a/svf-llvm/lib/LLVMModule.cpp b/svf-llvm/lib/LLVMModule.cpp index a5e1172e3..d520dc514 100644 --- a/svf-llvm/lib/LLVMModule.cpp +++ b/svf-llvm/lib/LLVMModule.cpp @@ -167,9 +167,8 @@ void LLVMModuleSet::build() createSVFDataStructure(); initSVFFunction(); - icfg = new ICFG(); - ICFGBuilder icfgbuilder(icfg); - icfgbuilder.build(); + ICFGBuilder icfgbuilder; + icfg = icfgbuilder.build(); } void LLVMModuleSet::createSVFDataStructure()