Static Value-Flow Analysis
saber.cpp
Go to the documentation of this file.
1 //===- saber.cpp -- Source-sink bug checker------------------------------------//
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  // Saber: Software Bug Check.
25  //
26  // Author: Yulei Sui,
27  */
28 
29 #include "SVF-LLVM/LLVMUtil.h"
30 #include "SVF-LLVM/SVFIRBuilder.h"
31 #include "SABER/LeakChecker.h"
32 #include "SABER/FileChecker.h"
34 #include "Util/CommandLine.h"
35 #include "Util/Options.h"
36 #include "Util/Z3Expr.h"
37 
38 
39 using namespace llvm;
40 using namespace SVF;
41 
42 int main(int argc, char ** argv)
43 {
44 
45  std::vector<std::string> moduleNameVec;
46  moduleNameVec = OptionBase::parseOptions(
47  argc, argv, "Source-Sink Bug Detector", "[options] <input-bitcode...>"
48  );
49 
50  if (Options::WriteAnder() == "ir_annotator")
51  {
52  LLVMModuleSet::preProcessBCs(moduleNameVec);
53  }
54 
55  SVFModule* svfModule = LLVMModuleSet::buildSVFModule(moduleNameVec);
56  SVFIRBuilder builder(svfModule);
57  SVFIR* pag = builder.build();
58 
59 
60  std::unique_ptr<LeakChecker> saber;
61 
62  if(Options::MemoryLeakCheck())
63  saber = std::make_unique<LeakChecker>();
64  else if(Options::FileCheck())
65  saber = std::make_unique<FileChecker>();
66  else if(Options::DFreeCheck())
67  saber = std::make_unique<DoubleFreeChecker>();
68  else
69  saber = std::make_unique<LeakChecker>(); // if no checker is specified, we use leak checker as the default one.
70 
71  saber->runOnModule(pag);
72  LLVMModuleSet::releaseLLVMModuleSet();
73 
74 
75  return 0;
76 
77 }
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.
for isBitcode
Definition: BasicTypes.h:68
int main(int argc, char **argv)
Definition: saber.cpp:42