Static Value-Flow Analysis
Loading...
Searching...
No Matches
ExtAPI.h
Go to the documentation of this file.
1//===- ExtAPI.h -- External functions -----------------------------------------//
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 * ExtAPI.h
25 *
26 * Created on: July 1, 2022
27 * Author: Shuangxiang Kan
28 */
29
30#ifndef __ExtAPI_H
31#define __ExtAPI_H
32
33#include "SVFIR/SVFValue.h"
34#include <Util/config.h>
35#include <string>
36#include <vector>
37#include <map>
38
40
41namespace SVF
42{
43
44class FunObjVar;
45
46class ExtAPI
47{
48 friend class LLVMModuleSet;
49 friend class SVFIRBuilder;
50 friend class GraphDBClient;
51
52private:
53
54 static ExtAPI *extOp;
55
56 // Map SVFFunction to its annotations
58
59 // extapi.bc file path
60 static std::string extBcPath;
61
62 ExtAPI() = default;
63
64public:
65
66 static ExtAPI *getExtAPI();
67
68 static void destory();
69
70 // Set extapi.bc file path
71 static bool setExtBcPath(const std::string& path);
72
73 // Get extapi.bc file path
74 std::string getExtBcPath();
75
76 // Get the annotation of (F)
77 std::string getExtFuncAnnotation(const FunObjVar* fun, const std::string&funcAnnotation);
78
79 const std::vector<std::string>& getExtFuncAnnotations(const FunObjVar*fun);
80
81 // Does (F) have some annotation?
82 bool hasExtFuncAnnotation(const FunObjVar* fun, const std::string&funcAnnotation);
83
84public:
85
86 // Does (F) have a static var X (unavailable to us) that its return points to?
87 bool has_static(const FunObjVar *F);
88
89 // Does (F) have a memcpy_like operation?
90 bool is_memcpy(const FunObjVar *F);
91
92 // Does (F) have a memset_like operation?
93 bool is_memset(const FunObjVar *F);
94
95 // Does (F) allocate a new object and return it?
96 bool is_alloc(const FunObjVar *F);
97
98 // Does (F) allocate a new object and assign it to one of its arguments?
99 bool is_arg_alloc(const FunObjVar *F);
100
101 // Does (F) allocate a new stack object and return it?
102 bool is_alloc_stack_ret(const FunObjVar *F);
103
104 // Get the position of argument which holds the new object
106
107 // Does (F) reallocate a new object?
108 bool is_realloc(const FunObjVar *F);
109
110 bool is_ext(const FunObjVar* funObjVar);
111
112private:
113 // Set the annotation of (F)
114 void setExtFuncAnnotations(const FunObjVar* fun, const std::vector<std::string>&funcAnnotations);
115};
116} // End namespace SVF
117
118#endif
bool is_alloc_stack_ret(const FunObjVar *F)
Definition ExtAPI.cpp:288
bool is_arg_alloc(const FunObjVar *F)
Definition ExtAPI.cpp:283
bool is_memcpy(const FunObjVar *F)
Definition ExtAPI.cpp:265
std::string getExtBcPath()
Definition ExtAPI.cpp:136
static std::string extBcPath
Definition ExtAPI.h:60
static ExtAPI * extOp
Definition ExtAPI.h:54
s32_t get_alloc_arg_pos(const FunObjVar *F)
Definition ExtAPI.cpp:294
static ExtAPI * getExtAPI()
Definition ExtAPI.cpp:44
bool is_ext(const FunObjVar *funObjVar)
Definition ExtAPI.cpp:314
std::string getExtFuncAnnotation(const FunObjVar *fun, const std::string &funcAnnotation)
Definition ExtAPI.cpp:243
bool is_realloc(const FunObjVar *F)
Definition ExtAPI.cpp:310
Map< const FunObjVar *, std::vector< std::string > > funObjVar2Annotations
Definition ExtAPI.h:57
void setExtFuncAnnotations(const FunObjVar *fun, const std::vector< std::string > &funcAnnotations)
Definition ExtAPI.cpp:223
friend class GraphDBClient
Definition ExtAPI.h:50
ExtAPI()=default
static void destory()
Definition ExtAPI.cpp:53
static bool setExtBcPath(const std::string &path)
Definition ExtAPI.cpp:63
bool hasExtFuncAnnotation(const FunObjVar *fun, const std::string &funcAnnotation)
Definition ExtAPI.cpp:229
bool is_alloc(const FunObjVar *F)
Definition ExtAPI.cpp:277
const std::vector< std::string > & getExtFuncAnnotations(const FunObjVar *fun)
Definition ExtAPI.cpp:256
bool is_memset(const FunObjVar *F)
Definition ExtAPI.cpp:272
bool has_static(const FunObjVar *F)
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
signed s32_t
Definition GeneralType.h:48