Static Value-Flow Analysis
wpa.cpp
Go to the documentation of this file.
1 //===- wpa.cpp -- Whole program analysis -------------------------------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-2017> <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  // Whole Program Pointer Analysis
25  //
26  // Author: Yulei Sui,
27  */
28 
29 #include "SVF-LLVM/LLVMUtil.h"
30 #include "SVF-LLVM/SVFIRBuilder.h"
31 #include "WPA/WPAPass.h"
32 #include "Util/CommandLine.h"
33 #include "Util/Options.h"
34 #include "SVFIR/SVFFileSystem.h"
35 
36 
37 using namespace llvm;
38 using namespace std;
39 using namespace SVF;
40 
41 int main(int argc, char** argv)
42 {
43  auto moduleNameVec =
44  OptionBase::parseOptions(argc, argv, "Whole Program Points-to Analysis",
45  "[options] <input-bitcode...>");
46 
47  // Refers to content of a singleton unique_ptr<SVFIR> in SVFIR.
48  SVFIR* pag;
49 
50  if (Options::ReadJson())
51  {
52  pag = SVFIRReader::read(moduleNameVec.front());
53  }
54  else
55  {
56  if (Options::WriteAnder() == "ir_annotator")
57  {
58  LLVMModuleSet::preProcessBCs(moduleNameVec);
59  }
60 
61  SVFModule* svfModule = LLVMModuleSet::buildSVFModule(moduleNameVec);
62 
64  SVFIRBuilder builder(svfModule);
65  pag = builder.build();
66 
67  }
68 
69  WPAPass wpa;
70  wpa.runOnModule(pag);
71 
72  LLVMModuleSet::releaseLLVMModuleSet();
73  return 0;
74 }
static std::vector< std::string > parseOptions(int argc, char *argv[], std::string description, std::string callFormat)
Definition: CommandLine.h:75
virtual SVFIR * build()
Start building SVFIR here.
virtual void runOnModule(SVFIR *svfModule)
Run pointer analysis on SVFModule.
Definition: WPAPass.cpp:69
for isBitcode
Definition: BasicTypes.h:68
int main(int argc, char **argv)
Definition: wpa.cpp:41