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 // Pointer to the SVF Intermediate Representation (IR) of the module
51 SVFIR* svfir = nullptr;
52
53 // If no CFLGraph option is specified, the SVFIR is built from the .bc (bytecode) files of the modules
54 if (Options::CFLGraph().empty())
55 {
58 svfir = builder.build();
59 } // if no dot form CFLGraph is specified, we use svfir from .bc.
60
61 // The CFLBase pointer that will be used to run the analysis
62 std::unique_ptr<CFLBase> cfl;
63
64 // Determines which type of analysis to run based on the options and sets up cfl accordingly
65 if (Options::CFLSVFG())
66 cfl = std::make_unique<CFLVF>(svfir);
67 else if (Options::POCRHybrid())
68 cfl = std::make_unique<POCRHybrid>(svfir);
69 else if (Options::POCRAlias())
70 cfl = std::make_unique<POCRAlias>(svfir);
71 else
72 cfl = std::make_unique<CFLAlias>(svfir); // if no svfg is specified, we use CFLAlias as the default one.
73
74 // Runs the analysis
75 cfl->analyze();
76
77 // Releases the SVFIR and the LLVMModuleSet to free memory
80
81
82 return 0;
83
84}
85
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:138
static void buildSVFModule(Module &mod)
static const Option< bool > POCRAlias
Definition Options.h:234
static const Option< bool > POCRHybrid
Definition Options.h:235
static const Option< bool > CFLSVFG
Definition Options.h:233
static const Option< std::string > CFLGraph
Definition Options.h:229
static void releaseSVFIR()
Definition SVFIR.h:122
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74