Repository navigation
Expand file tree
/
Copy pathcfl.cpp
More file actions
91 lines (72 loc) · 3 KB
/
Copy pathcfl.cpp
File metadata and controls
91 lines (72 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//===- cfl.cpp -- A driver of CFL Reachability Analysis-------------------------------------//
//
// SVF: Static Value-Flow Analysis
//
// Copyright (C) <2013-> <Yulei Sui>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//===-----------------------------------------------------------------------===//
/*
// A driver of CFL Reachability Analysis
//
// Author: Yulei Sui,
*/
// This file is a driver for Context-Free Language (CFL) Reachability Analysis. The code
// processes command-line arguments, sets up the analysis based on these arguments, and
// then runs the analysis.
#include "SVF-LLVM/LLVMUtil.h"
#include "SVF-LLVM/PAGBuilder.h"
#include "CFL/CFLAlias.h"
#include "CFL/CFLVF.h"
using namespace llvm;
using namespace SVF;
int main(int argc, char ** argv)
{
// Parses command-line arguments and stores any module names in moduleNameVec
std::vector<std::string> moduleNameVec;
moduleNameVec = OptionBase::parseOptions(
argc, argv, "CFL Reachability Analysis", "[options] <input-bitcode...>"
);
// Pointer to the PAG of the module
PAG* pag = nullptr;
// If no CFLGraph option is specified, the PAG is built from the .bc (bytecode) files of the modules
if (Options::CFLGraph().empty())
{
LLVMModuleSet::buildSVFModule(moduleNameVec);
PAGBuilder builder;
pag = builder.build();
} // if no dot form CFLGraph is specified, we use pag from .bc.
// The CFLBase pointer that will be used to run the analysis
std::unique_ptr<CFLBase> cfl;
// Determines which type of analysis to run based on the options and sets up cfl accordingly
if (Options::CFLSVFG())
cfl = std::make_unique<CFLVF>(pag);
else if (Options::POCRHybrid())
cfl = std::make_unique<POCRHybrid>(pag);
else if (Options::POCRAlias())
cfl = std::make_unique<POCRAlias>(pag);
#if SVF_ENABLE_MATRIX_CFL
else if (Options::MTXAlias())
cfl = std::make_unique<MTXAlias>(pag);
else if (Options::AdvancedMTXAlias())
cfl = std::make_unique<AdvMTXAlias>(pag);
#endif
else
cfl = std::make_unique<CFLAlias>(pag); // if no svfg is specified, we use CFLAlias as the default one.
// Runs the analysis
cfl->analyze();
// Releases the PAG and the LLVMModuleSet to free memory
PAG::releasePAG();
SVF::LLVMModuleSet::releaseLLVMModuleSet();
return 0;
}