clang: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65#ifndef LLVM_CLANG_STATICANALYZER_UNINITIALIZEDOBJECT_H
66#define LLVM_CLANG_STATICANALYZER_UNINITIALIZEDOBJECT_H
67
69
71namespace ento {
72
79};
80
81
82
83
84
86protected:
88
89
90
92
93public:
95
96
97
103
104 void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(this); }
105
106
108
109
110
111 if (FR == nullptr)
112 return false;
113
114 return FR == OtherFR;
115 }
116
119 assert(FR);
121 }
122
123
124
125
126
127
128
129
130
131
132
133 virtual void printNoteMsg(llvm::raw_ostream &Out) const = 0;
134
135
136 virtual void printPrefix(llvm::raw_ostream &Out) const = 0;
137
138
139 virtual void printNode(llvm::raw_ostream &Out) const = 0;
140
141
142
144
145 virtual bool isBase() const { return false; }
146};
147
148
149
151
152
153
154
155
156
157
158
159
161public:
162 using FieldChain = llvm::ImmutableList<const FieldNode &>;
163
164private:
165 FieldChain::Factory &ChainFactory;
167
170 Chain = NewChain;
171 }
172
173public:
177
178
179 template FieldChainInfo add(const FieldNodeT &FN);
180
181
182
184
186 bool isEmpty() const { return Chain.isEmpty(); }
187
190
191 void printNoteMsg(llvm::raw_ostream &Out) const;
192};
193
194using UninitFieldMap = std::map<const FieldRegion *, llvm::SmallString<50>>;
195
196
200
202 bool IsAnyFieldInitialized = false;
203
204 FieldChainInfo::FieldChain::Factory ChainFactory;
205
206
207
208
209
210
211
212
213
214
215
217
218public:
219
220
224
225
226
227 std::pair<ProgramStateRef, const UninitFieldMap &> getResults() {
228 return {State, UninitFields};
229 }
230
231
232
233
234
236
237private:
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
291
292
293
295
296
297
298
300
301
302 bool isPrimitiveUninit(SVal V);
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
319 const MemRegion *PointeeR = nullptr);
320};
321
322
323
328}
329
332}
333
334
335
336template
338 assert((FN.getRegion()) &&
339 "Can't add a field that is already a part of the "
340 "fieldchain! Is this a cyclic reference?");
341
343 NewChain.Chain = ChainFactory.add(FN, Chain);
344 return NewChain;
345}
346
347template
349 FieldChainInfo NewChain(ChainFactory, Chain.getTail());
350 return NewChain.add(FN);
351}
352
353}
354}
355
356#endif
Represents a member of a struct/union/class.
A (possibly-)qualified type.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isAtomicType() const
bool isFunctionType() const
bool isVectorType() const
bool isAnyPointerType() const
Represents a field chain.
bool contains(const FieldRegion *FR) const
llvm::ImmutableList< const FieldNode & > FieldChain
FieldChainInfo(FieldChain::Factory &F)
const FieldNode & getHead() const
const FieldRegion * getUninitRegion() const
FieldChainInfo replaceHead(const FieldNodeT &FN)
Constructs a new FieldChainInfo object with FN as the new head of the list.
FieldChainInfo(const FieldChainInfo &Other)=default
FieldChainInfo add(const FieldNodeT &FN)
Constructs a new FieldChainInfo object with FN appended.
void printNoteMsg(llvm::raw_ostream &Out) const
A lightweight polymorphic wrapper around FieldRegion *.
virtual bool isBase() const
FieldNode(const FieldRegion *FR)
void Profile(llvm::FoldingSetNodeID &ID) const
virtual void printSeparator(llvm::raw_ostream &Out) const =0
Print the separator.
bool isSameRegion(const FieldRegion *OtherFR) const
Helper method for uniqueing.
const FieldRegion * getRegion() const
virtual void printPrefix(llvm::raw_ostream &Out) const =0
Print any prefixes before the fieldchain. Could contain casts, etc.
virtual void printNoteMsg(llvm::raw_ostream &Out) const =0
If this is the last element of the fieldchain, this method will print the note message associated wit...
FieldNode & operator=(const FieldNode &)=delete
FieldNode & operator=(const FieldNode &&)=delete
FieldNode(const FieldNode &)=delete
FieldNode(FieldNode &&)=delete
const FieldDecl * getDecl() const
~FieldNode()=default
FieldNodes are never meant to be created on the heap, see FindUninitializedFields::addFieldToUninits(...
virtual void printNode(llvm::raw_ostream &Out) const =0
Print the node. Should contain the name of the field stored in FR.
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
Searches for and stores uninitialized fields in a non-union object.
std::pair< ProgramStateRef, const UninitFieldMap & > getResults()
Returns with the modified state and a map of (uninitialized region, note message) pairs.
bool isAnyFieldInitialized()
Returns whether the analyzed region contains at least one initialized field.
MemRegion - The root abstract class for all memory regions.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
TypedValueRegion - An abstract class representing regions having a typed value.
std::string getVariableName(const FieldDecl *Field)
Returns with Field's name.
bool isPrimitiveType(const QualType &T)
Returns true if T is a primitive type.
bool isDereferencableType(const QualType &T)
std::map< const FieldRegion *, llvm::SmallString< 50 > > UninitFieldMap
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
@ Other
Other implicit parameter.
bool ShouldConvertNotesToWarnings
std::string IgnoredRecordsWithFieldPattern
bool CheckPointeeInitialization