clang: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATETRAIT_H
17#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATETRAIT_H
18
19#include "llvm/ADT/ImmutableList.h"
20#include "llvm/ADT/ImmutableMap.h"
21#include "llvm/ADT/ImmutableSet.h"
22#include "llvm/Support/Allocator.h"
23#include
24#include <type_traits>
25
27namespace ento {
28
30
31
32
33
34#define REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, Type) \
35 namespace { \
36 class Name {}; \
37 using Name##Ty = Type; \
38 } \
39 namespace clang { \
40 namespace ento { \
41 template <> \
42 struct ProgramStateTrait : public ProgramStatePartialTrait<Name##Ty> { \
43 static void *GDMIndex() { \
44 static int Index; \
45 return &Index; \
46 } \
47 }; \
48 } \
49 }
50
51
52
53
54
55 #define REGISTER_FACTORY_WITH_PROGRAMSTATE(Type) \
56 namespace clang { \
57 namespace ento { \
58 template <> \
59 struct ProgramStateTrait \
60 : public ProgramStatePartialTrait { \
61 static void *GDMIndex() { static int Index; return &Index; } \
62 }; \
63 } \
64 }
65
66
67
68
69
70
71
72
73 #define CLANG_ENTO_PROGRAMSTATE_MAP(Key, Value) llvm::ImmutableMap<Key, Value>
74
75
76
77
78
79
80
81
82
83
84
85
86
87 #define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value) \
88 REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, \
89 CLANG_ENTO_PROGRAMSTATE_MAP(Key, Value))
90
91
92
93
94
95 #define REGISTER_MAP_FACTORY_WITH_PROGRAMSTATE(Name, Key, Value) \
96 using Name = llvm::ImmutableMap<Key, Value>; \
97 REGISTER_FACTORY_WITH_PROGRAMSTATE(Name)
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 #define REGISTER_SET_WITH_PROGRAMSTATE(Name, Elem) \
113 REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, llvm::ImmutableSet)
114
115
116
117
118
119 #define REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(Name, Elem) \
120 using Name = llvm::ImmutableSet; \
121 REGISTER_FACTORY_WITH_PROGRAMSTATE(Name)
122
123
124
125
126
127
128
129
130
131
132
133
134
135 #define REGISTER_LIST_WITH_PROGRAMSTATE(Name, Elem) \
136 REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, llvm::ImmutableList)
137
138
139
140
141
142 #define REGISTER_LIST_FACTORY_WITH_PROGRAMSTATE(Name, Elem) \
143 using Name = llvm::ImmutableList; \
144 REGISTER_FACTORY_WITH_PROGRAMSTATE(Name)
145
146
147
148 template <typename Key, typename Data, typename Info>
150 using data_type = llvm::ImmutableMap<Key, Data, Info>;
155
157 return p ? data_type((typename data_type::TreeTy *) *p)
159 }
160
162 return B.getRoot();
163 }
164
166 return B.lookup(K);
167 }
168
171 return F.add(B, K, E);
172 }
173
175 return F.remove(B, K);
176 }
177
179 return B.contains(K);
180 }
181
183 return *((typename data_type::Factory *) p);
184 }
185
187 return new typename data_type::Factory(Alloc);
188 }
189
191 delete (typename data_type::Factory *) Ctx;
192 }
193 };
194
195
196 template <typename Key, typename Info>
198 using data_type = llvm::ImmutableSet<Key, Info>;
201
203 return p ? data_type((typename data_type::TreeTy *) *p)
205 }
206
208 return B.getRoot();
209 }
210
212 return F.add(B, K);
213 }
214
216 return F.remove(B, K);
217 }
218
220 return B.contains(K);
221 }
222
224 return *((typename data_type::Factory *) p);
225 }
226
228 return new typename data_type::Factory(Alloc);
229 }
230
232 delete (typename data_type::Factory *) Ctx;
233 }
234 };
235
236
237 template
242
244 return F.add(K, L);
245 }
246
248 return L.contains(K);
249 }
250
252 return p ? data_type((const llvm::ImmutableListImpl *) *p)
254 }
255
257 return const_cast<llvm::ImmutableListImpl *>(D.getInternalPointer());
258 }
259
261 return *((typename data_type::Factory *) p);
262 }
263
265 return new typename data_type::Factory(Alloc);
266 }
267
269 delete (typename data_type::Factory *) Ctx;
270 }
271 };
272
277 };
278
279
280 template
282 std::enable_if_t<std::is_integral::value>>
284
285
286 template
289
290
291 template
294
295}
296}
297
298#endif
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
static T MakeData(void *const *P)
static void * MakeVoidPtr(T D)
static void * MakeVoidPtr(data_type D)
typename data_type::Factory & context_type
static data_type Add(data_type L, key_type K, context_type F)
static context_type MakeContext(void *p)
static bool Contains(data_type L, key_type K)
llvm::ImmutableList< T > data_type
static void * CreateContext(llvm::BumpPtrAllocator &Alloc)
static void DeleteContext(void *Ctx)
static data_type MakeData(void *const *p)
const value_type * lookup_type
static data_type Set(data_type B, key_type K, value_type E, context_type F)
static data_type MakeData(void *const *p)
static context_type MakeContext(void *p)
typename data_type::Factory & context_type
static lookup_type Lookup(data_type B, key_type K)
static void DeleteContext(void *Ctx)
static data_type Remove(data_type B, key_type K, context_type F)
static bool Contains(data_type B, key_type K)
static void * CreateContext(llvm::BumpPtrAllocator &Alloc)
llvm::ImmutableMap< Key, Data, Info > data_type
static void * MakeVoidPtr(data_type B)
static data_type MakeData(void *const *p)
static data_type Remove(data_type B, key_type K, context_type F)
static void * MakeVoidPtr(data_type B)
static data_type Add(data_type B, key_type K, context_type F)
static void DeleteContext(void *Ctx)
static context_type MakeContext(void *p)
static bool Contains(data_type B, key_type K)
typename data_type::Factory & context_type
static void * CreateContext(llvm::BumpPtrAllocator &Alloc)
llvm::ImmutableSet< Key, Info > data_type