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>
42
43namespace SVF
44{
45typedef std::ostream OutStream;
46typedef unsigned u32_t;
47typedef signed s32_t;
48typedef unsigned long long u64_t;
49typedef signed long long s64_t;
50typedef unsigned char u8_t;
51typedef signed char s8_t;
52typedef unsigned short u16_t;
53typedef signed short s16_t;
54
55typedef u32_t NodeID;
56typedef u32_t EdgeID;
57typedef unsigned SymID;
58typedef unsigned CallSiteID;
59typedef unsigned ThreadID;
61
63typedef unsigned PointsToID;
64
66template <class T> struct Hash;
67
68template <class S, class T> struct Hash<std::pair<S, T>>
69{
70 // Pairing function from: http://szudzik.com/ElegantPairing.pdf
71 static size_t szudzik(size_t a, size_t b)
72 {
73 return a > b ? b * b + a : a * a + a + b;
74 }
75
76 size_t operator()(const std::pair<S, T>& t) const
77 {
78 Hash<decltype(t.first)> first;
79 Hash<decltype(t.second)> second;
80 return szudzik(first(t.first), second(t.second));
81 }
82};
83
84template <class T> struct Hash
85{
86 size_t operator()(const T& t) const
87 {
88 std::hash<T> h;
89 return h(t);
90 }
91};
92
93template <typename Key, typename Hash = Hash<Key>,
94 typename KeyEqual = std::equal_to<Key>,
95 typename Allocator = std::allocator<Key>>
96using Set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
97
98template <typename Key, typename Value, typename Hash = Hash<Key>,
99 typename KeyEqual = std::equal_to<Key>,
100 typename Allocator = std::allocator<std::pair<const Key, Value>>>
101 using Map = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
102
103 template <typename Key, typename Compare = std::less<Key>,
104 typename Allocator = std::allocator<Key>>
105 using OrderedSet = std::set<Key, Compare, Allocator>;
106
107 template <typename Key, typename Value, typename Compare = std::less<Key>,
108 typename Allocator = std::allocator<std::pair<const Key, Value>>>
109 using OrderedMap = std::map<Key, Value, Compare, Allocator>;
110
111 typedef std::pair<NodeID, NodeID> NodePair;
116 typedef std::vector<NodeID> NodeVector;
117 typedef std::vector<EdgeID> EdgeVector;
118 typedef std::stack<NodeID> NodeStack;
119 typedef std::list<NodeID> NodeList;
120 typedef std::deque<NodeID> NodeDeque;
122 typedef std::vector<u32_t> CallStrCxt;
123 typedef unsigned Version;
125 typedef std::pair<NodeID, Version> VersionedVar;
127}
cJSON * a
Definition cJSON.cpp:2560
const cJSON *const b
Definition cJSON.h:255
for isBitcode
Definition BasicTypes.h:68
unsigned CallSiteID
Definition GeneralType.h:58
Set< Version > VersionSet
NodeSet EdgeSet
unsigned ThreadID
Definition GeneralType.h:59
std::stack< NodeID > NodeStack
Set< NodeID > NodeSet
std::pair< NodeID, Version > VersionedVar
std::deque< NodeID > NodeDeque
unsigned long long u64_t
Definition GeneralType.h:48
std::vector< NodeID > NodeVector
OrderedSet< NodeID > OrderedNodeSet
u32_t NodeID
Definition GeneralType.h:55
std::vector< EdgeID > EdgeVector
std::set< Key, Compare, Allocator > OrderedSet
Set< VersionedVar > VersionedVarSet
Map< NodePair, NodeID > NodePairMap
s64_t APOffset
Definition GeneralType.h:60
signed char s8_t
Definition GeneralType.h:51
signed short s16_t
Definition GeneralType.h:53
unsigned short u16_t
Definition GeneralType.h:52
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
std::ostream OutStream
Definition GeneralType.h:45
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
signed s32_t
Definition GeneralType.h:47
unsigned char u8_t
Definition GeneralType.h:50
unsigned Version
SparseBitVector NodeBS
Definition GeneralType.h:62
std::vector< u32_t > CallStrCxt
std::list< NodeID > NodeList
Set< NodePair > NodePairSet
unsigned SymID
Definition GeneralType.h:57
unsigned u32_t
Definition GeneralType.h:46
signed long long s64_t
Definition GeneralType.h:49
unsigned PointsToID
Definition GeneralType.h:63
u32_t EdgeID
Definition GeneralType.h:56
std::map< Key, Value, Compare, Allocator > OrderedMap
std::pair< NodeID, NodeID > NodePair
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:96
size_t operator()(const std::pair< S, T > &t) const
Definition GeneralType.h:76
static size_t szudzik(size_t a, size_t b)
Definition GeneralType.h:71
provide extra hash function for std::pair handling
Definition GeneralType.h:85
size_t operator()(const T &t) const
Definition GeneralType.h:86