svf-tools 1.0.695 → 1.0.696

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.695",
3
+ "version": "1.0.696",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,3 +20,4 @@ add_subdirectory(Example)
20
20
  add_subdirectory(DDA)
21
21
  add_subdirectory(MTA)
22
22
  add_subdirectory(CFL)
23
+ add_subdirectory(LLVM2SVF)
@@ -0,0 +1,10 @@
1
+ if(DEFINED IN_SOURCE_BUILD)
2
+ add_llvm_tool(llvm2svf llvm2svf.cpp)
3
+ else()
4
+ add_executable(llvm2svf llvm2svf.cpp)
5
+
6
+ target_link_libraries(llvm2svf SvfLLVM ${llvm_libs})
7
+
8
+ set_target_properties(llvm2svf PROPERTIES RUNTIME_OUTPUT_DIRECTORY
9
+ ${CMAKE_BINARY_DIR}/bin)
10
+ endif()
@@ -0,0 +1,72 @@
1
+ //===- llvm2svf.cpp -- LLVM IR to SVF IR conversion -------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2023> <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
+ * llvm2svf.cpp
25
+ *
26
+ * Created on: 21 Apr 2023
27
+ * Authors: Xudong Wang
28
+ */
29
+
30
+ #include "SVF-LLVM/SVFIRBuilder.h"
31
+ #include "Util/CommandLine.h"
32
+ #include "Util/Options.h"
33
+ #include "SVFIR/SVFIRRW.h"
34
+
35
+
36
+ using namespace std;
37
+ using namespace SVF;
38
+
39
+ #include <iostream>
40
+ #include <string>
41
+
42
+ std::string replaceExtension(const std::string& path)
43
+ {
44
+ size_t pos = path.rfind('.');
45
+ if (pos == std::string::npos || path.substr(pos) != ".bc")
46
+ {
47
+ SVFUtil::errs() << "Error: file extension is not .bc\n";
48
+ exit(EXIT_FAILURE);
49
+ }
50
+ return path.substr(0, pos) + ".svf.json";
51
+ }
52
+
53
+ int main(int argc, char** argv)
54
+ {
55
+ auto moduleNameVec = OptionBase::parseOptions(
56
+ argc, argv, "llvm2svf", "[options] <input-bitcode...>");
57
+
58
+ LLVMModuleSet* moduleSet = LLVMModuleSet::getLLVMModuleSet();
59
+ if (Options::WriteAnder() == "ir_annotator")
60
+ {
61
+ moduleSet->preProcessBCs(moduleNameVec);
62
+ }
63
+
64
+ SVFModule* svfModule = moduleSet->buildSVFModule(moduleNameVec);
65
+ const std::string jsonPath = replaceExtension(moduleNameVec.front());
66
+ // PAG is borrowed from a unique_ptr, so we don't need to delete it.
67
+ const SVFIR* pag = SVFIRBuilder(svfModule).build();
68
+ SVFIRWriter::writeJsonToPath(pag, jsonPath);
69
+ SVFUtil::outs() << "SVF IR is written to '" << jsonPath << "'\n";
70
+
71
+ return 0;
72
+ }