Static Value-Flow Analysis
Loading...
Searching...
No Matches
cfl.cpp
Go to the documentation of this file.
1//===- cfl.cpp -- A driver of CFL Reachability Analysis-------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===-----------------------------------------------------------------------===//
22
23/*
24 // A driver of CFL Reachability Analysis
25 //
26 // Author: Yulei Sui,
27 */
28
29// This file is a driver for Context-Free Language (CFL) Reachability Analysis. The code
30// processes command-line arguments, sets up the analysis based on these arguments, and
31// then runs the analysis.
32
33#include "SVF-LLVM/LLVMUtil.h"
35#include "CFL/CFLAlias.h"
36#include "CFL/CFLVF.h"
37
38
39using namespace llvm;
40using namespace SVF;
41
42int main(int argc, char ** argv)
43{
44 // Parses command-line arguments and stores any module names in moduleNameVec
45 std::vector<std::string> moduleNameVec;
47 argc, argv, "CFL Reachability Analysis", "[options] <input-bitcode...>"
48 );
49
50 // If the WriteAnder option is set to "ir_annotator", pre-processes the bytecodes of the modules
51 if (Options::WriteAnder() == "ir_annotator")
52 {
54 }
55
56 // Pointer to the SVF Intermediate Representation (IR) of the module
57 SVFIR* svfir = nullptr;
58
59 // If no CFLGraph option is specified, the SVFIR is built from the .bc (bytecode) files of the modules
60 if (Options::CFLGraph().empty())
61 {
63 SVFIRBuilder builder(svfModule);
64 svfir = builder.build();
65 } // if no dot form CFLGraph is specified, we use svfir from .bc.
66
67 // The CFLBase pointer that will be used to run the analysis
68 std::unique_ptr<CFLBase> cfl;
69
70 // Determines which type of analysis to run based on the options and sets up cfl accordingly
71 if (Options::CFLSVFG())
72 cfl = std::make_unique<CFLVF>(svfir);
73 else if (Options::POCRHybrid())
74 cfl = std::make_unique<POCRHybrid>(svfir);
75 else if (Options::POCRAlias())
76 cfl = std::make_unique<POCRAlias>(svfir);
77 else
78 cfl = std::make_unique<CFLAlias>(svfir); // if no svfg is specified, we use CFLAlias as the default one.
79
80 // Runs the analysis
81 cfl->analyze();
82
83 // Releases the SVFIR and the LLVMModuleSet to free memory
86
87
88 return 0;
89
90}
91
int main(int argc, char **argv)
Definition cfl.cpp:42
static std::vector< std::string > parseOptions(int argc, char *argv[], std::string description, std::string callFormat)
Definition CommandLine.h:75
static void releaseLLVMModuleSet()
Definition LLVMModule.h:129
static void preProcessBCs(std::vector< std::string > &moduleNameVec)
static SVFModule * buildSVFModule(Module &mod)
static const Option< bool > POCRAlias
Definition Options.h:237
static const Option< bool > POCRHybrid
Definition Options.h:238
static const Option< bool > CFLSVFG
Definition Options.h:236
static const Option< std::string > CFLGraph
Definition Options.h:232
static const Option< std::string > WriteAnder
Definition Options.h:212
static void releaseSVFIR()
Definition SVFIR.h:124
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74