Static Value-Flow Analysis
Loading...
Searching...
No Matches
GeneralType.h
Go to the documentation of this file.
1//===- GeneralType.h -- Primitive types used in SVF--------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <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 * GeneralType.h
25 *
26 * Created on: Feb 8, 2024
27 * Author: Jiawei Wang
28 */
29
30#pragma once
31#include <cstdint>
32#include <deque>
33#include <iostream>
34#include <list>
35#include <map>
36#include <set>
37#include <stack>
38#include <unordered_map>
39#include <unordered_set>
40#include <vector>
41
42#include "Util/Hash.h"
44
45namespace SVF
46{
47
48template <typename Key, typename Hash = Hash<Key>,
49 typename KeyEqual = std::equal_to<Key>,
50 typename Allocator = std::allocator<Key>>
51using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
52
53template <typename Key, typename Value, typename Hash = Hash<Key>,
54 typename KeyEqual = std::equal_to<Key>,
55 typename Allocator = std::allocator<std::pair<const Key, Value>>>
56 using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
57
58 template <typename Key, typename Compare = std::less<Key>,
59 typename Allocator = std::allocator<Key>>
60 using OrderedSet = std::set<Key, Compare, Allocator>;
61
62 template <typename Key, typename Value, typename Compare = std::less<Key>,
63 typename Allocator = std::allocator<std::pair<const Key, Value>>>
64 using OrderedMap = std::map<Key, Value, Compare, Allocator>;
65
66 typedef std::ostream OutStream;
67 typedef unsigned u32_t;
68 typedef signed s32_t;
69 typedef unsigned long long u64_t;
70 typedef signed long long s64_t;
71 typedef unsigned char u8_t;
72 typedef signed char s8_t;
73 typedef unsigned short u16_t;
74 typedef signed short s16_t;
75
76 typedef u32_t NodeID;
77 typedef u32_t EdgeID;
78 typedef unsigned CallSiteID;
79 typedef unsigned ThreadID;
80 typedef s64_t APOffset;
81
83 typedef unsigned PointsToID;
84
85 typedef std::pair<NodeID, NodeID> NodePair;
90 typedef std::vector<NodeID> NodeVector;
91 typedef std::vector<EdgeID> EdgeVector;
92 typedef std::stack<NodeID> NodeStack;
93 typedef std::list<NodeID> NodeList;
94 typedef std::deque<NodeID> NodeDeque;
96 typedef std::vector<u32_t> CallStrCxt;
97 typedef unsigned Version;
99 typedef std::pair<NodeID, Version> VersionedVar;
101
102// TODO: be explicit that this is a pair of 32-bit unsigneds?
103 template <> struct Hash<NodePair>
104{
105 size_t operator()(const NodePair& p) const
106 {
107 // Make sure our assumptions are sound: use u32_t
108 // and u64_t. If NodeID is not actually u32_t or size_t
109 // is not u64_t we should be fine since we get a
110 // consistent result.
111 uint32_t first = (uint32_t)(p.first);
112 uint32_t second = (uint32_t)(p.second);
113 return ((uint64_t)(first) << 32) | (uint64_t)(second);
114 }
115};
116
117} // namespace SVF
118
119template <> struct std::hash<SVF::NodePair>
120{
121 size_t operator()(const SVF::NodePair& p) const
122 {
123 // Make sure our assumptions are sound: use u32_t
124 // and u64_t. If NodeID is not actually u32_t or size_t
125 // is not u64_t we should be fine since we get a
126 // consistent result.
127 uint32_t first = (uint32_t)(p.first);
128 uint32_t second = (uint32_t)(p.second);
129 return ((uint64_t)(first) << 32) | (uint64_t)(second);
130 }
131};
cJSON * p
Definition cJSON.cpp:2559
for isBitcode
Definition BasicTypes.h:70
unsigned CallSiteID
Definition GeneralType.h:78
Set< Version > VersionSet
Definition GeneralType.h:98
NodeSet EdgeSet
Definition GeneralType.h:95
unsigned ThreadID
Definition GeneralType.h:79
std::stack< NodeID > NodeStack
Definition GeneralType.h:92
Set< NodeID > NodeSet
Definition GeneralType.h:87
std::pair< NodeID, Version > VersionedVar
Definition GeneralType.h:99
std::deque< NodeID > NodeDeque
Definition GeneralType.h:94
unsigned long long u64_t
Definition GeneralType.h:69
std::vector< NodeID > NodeVector
Definition GeneralType.h:90
OrderedSet< NodeID > OrderedNodeSet
Definition GeneralType.h:86
u32_t NodeID
Definition GeneralType.h:76
std::vector< EdgeID > EdgeVector
Definition GeneralType.h:91
std::set< Key, Compare, Allocator > OrderedSet
Definition GeneralType.h:60
Set< VersionedVar > VersionedVarSet
Map< NodePair, NodeID > NodePairMap
Definition GeneralType.h:89
s64_t APOffset
Definition GeneralType.h:80
signed char s8_t
Definition GeneralType.h:72
signed short s16_t
Definition GeneralType.h:74
unsigned short u16_t
Definition GeneralType.h:73
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition GeneralType.h:56
std::ostream OutStream
Definition GeneralType.h:66
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
signed s32_t
Definition GeneralType.h:68
unsigned char u8_t
Definition GeneralType.h:71
unsigned Version
Definition GeneralType.h:97
SparseBitVector NodeBS
Definition GeneralType.h:82
std::vector< u32_t > CallStrCxt
Definition GeneralType.h:96
std::list< NodeID > NodeList
Definition GeneralType.h:93
Set< NodePair > NodePairSet
Definition GeneralType.h:88
unsigned u32_t
Definition GeneralType.h:67
signed long long s64_t
Definition GeneralType.h:70
unsigned PointsToID
Definition GeneralType.h:83
u32_t EdgeID
Definition GeneralType.h:77
std::map< Key, Value, Compare, Allocator > OrderedMap
Definition GeneralType.h:64
std::pair< NodeID, NodeID > NodePair
Definition GeneralType.h:85
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:51
size_t operator()(const NodePair &p) const
provide extra hash function for std::pair handling
Definition Hash.h:29
size_t operator()(const SVF::NodePair &p) const