clang 8.0.0

SymbolManager.h
Go to the documentation of this file.
1 //===- SymbolManager.h - Management of Symbolic Values ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines SymbolManager, a class that manages symbolic values
11 // created for use by ExprEngine and related classes.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
17
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/Type.h"
20 #include "clang/Analysis/AnalysisDeclContext.h"
21 #include "clang/Basic/LLVM.h"
22 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
23 #include "clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h"
24 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
25 #include "llvm/ADT/DenseMap.h"
26 #include "llvm/ADT/DenseSet.h"
27 #include "llvm/ADT/FoldingSet.h"
28 #include "llvm/Support/Allocator.h"
29 #include <cassert>
30
31 namespace clang {
32
33 class ASTContext;
34 class Stmt;
35
36 namespace ento {
37
38 class BasicValueFactory;
39 class StoreManager;
40
41 ///A symbol representing the value stored at a MemRegion.
42 class SymbolRegionValue : public SymbolData {
43 const TypedValueRegion *R;
44
45 public:
46 SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
47 : SymbolData(SymbolRegionValueKind, sym), R(r) {
48 assert(r);
49 assert(isValidTypeForSymbol(r->getValueType()));
50 }
51
52 const TypedValueRegion* getRegion() const { return R; }
53
54 static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) {
55 profile.AddInteger((unsigned) SymbolRegionValueKind);
56 profile.AddPointer(R);
57 }
58
59 void Profile(llvm::FoldingSetNodeID& profile) override {
60 Profile(profile, R);
61 }
62
63 void dumpToStream(raw_ostream &os) const override;
64 const MemRegion *getOriginRegion() const override { return getRegion(); }
65
66 QualType getType() const override;
67
68 // Implement isa<T> support.
69 static bool classof(const SymExpr *SE) {
70 return SE->getKind() == SymbolRegionValueKind;
71 }
72 };
73
74 /// A symbol representing the result of an expression in the case when we do
75 /// not know anything about what the expression is.
76 class SymbolConjured : public SymbolData {
77 const Stmt *S;
78 QualType T;
79 unsigned Count;
80 const LocationContext *LCtx;
81 const void *SymbolTag;
82
83 public:
84 SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
85 QualType t, unsigned count, const void *symbolTag)
86 : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
87 LCtx(lctx), SymbolTag(symbolTag) {
88 // FIXME: 's' might be a nullptr if we're conducting invalidation
89 // that was caused by a destructor call on a temporary object,
90 // which has no statement associated with it.
91 // Due to this, we might be creating the same invalidation symbol for
92 // two different invalidation passes (for two different temporaries).
93 assert(lctx);
94 assert(isValidTypeForSymbol(t));
95 }
96
97 const Stmt *getStmt() const { return S; }
98 unsigned getCount() const { return Count; }
99 const void *getTag() const { return SymbolTag; }
100
101 QualType getType() const override;
102
103 void dumpToStream(raw_ostream &os) const override;
104
105 static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S,
106 QualType T, unsigned Count, const LocationContext *LCtx,
107 const void *SymbolTag) {
108 profile.AddInteger((unsigned) SymbolConjuredKind);
109 profile.AddPointer(S);
110 profile.AddPointer(LCtx);
111 profile.Add(T);
112 profile.AddInteger(Count);
113 profile.AddPointer(SymbolTag);
114 }
115
116 void Profile(llvm::FoldingSetNodeID& profile) override {
117 Profile(profile, S, T, Count, LCtx, SymbolTag);
118 }
119
120 // Implement isa<T> support.
121 static bool classof(const SymExpr *SE) {
122 return SE->getKind() == SymbolConjuredKind;
123 }
124 };
125
126 /// A symbol representing the value of a MemRegion whose parent region has
127 /// symbolic value.
128 class SymbolDerived : public SymbolData {
129 SymbolRef parentSymbol;
130 const TypedValueRegion *R;
131
132 public:
133 SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
134 : SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {
135 assert(parent);
136 assert(r);
137 assert(isValidTypeForSymbol(r->getValueType()));
138 }
139
140 SymbolRef getParentSymbol() const { return parentSymbol; }
141 const TypedValueRegion *getRegion() const { return R; }
142
143 QualType getType() const override;
144
145 void dumpToStream(raw_ostream &os) const override;
146 const MemRegion *getOriginRegion() const override { return getRegion(); }
147
148 static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent,
149 const TypedValueRegion *r) {
150 profile.AddInteger((unsigned) SymbolDerivedKind);
151 profile.AddPointer(r);
152 profile.AddPointer(parent);
153 }
154
155 void Profile(llvm::FoldingSetNodeID& profile) override {
156 Profile(profile, parentSymbol, R);
157 }
158
159 // Implement isa<T> support.
160 static bool classof(const SymExpr *SE) {
161 return SE->getKind() == SymbolDerivedKind;
162 }
163 };
164
165 /// SymbolExtent - Represents the extent (size in bytes) of a bounded region.
166 /// Clients should not ask the SymbolManager for a region's extent. Always use
167 /// SubRegion::getExtent instead -- the value returned may not be a symbol.
168 class SymbolExtent : public SymbolData {
169 const SubRegion *R;
170
171 public:
172 SymbolExtent(SymbolID sym, const SubRegion *r)
173 : SymbolData(SymbolExtentKind, sym), R(r) {
174 assert(r);
175 }
176
177 const SubRegion *getRegion() const { return R; }
178
179 QualType getType() const override;
180
181 void dumpToStream(raw_ostream &os) const override;
182
183 static void Profile(llvm::FoldingSetNodeID& profile, const SubRegion *R) {
184 profile.AddInteger((unsigned) SymbolExtentKind);
185 profile.AddPointer(R);
186 }
187
188 void Profile(llvm::FoldingSetNodeID& profile) override {
189 Profile(profile, R);
190 }
191
192 // Implement isa<T> support.
193 static bool classof(const SymExpr *SE) {
194 return SE->getKind() == SymbolExtentKind;
195 }
196 };
197
198 /// SymbolMetadata - Represents path-dependent metadata about a specific region.
199 /// Metadata symbols remain live as long as they are marked as in use before
200 /// dead-symbol sweeping AND their associated regions are still alive.
201 /// Intended for use by checkers.
202 class SymbolMetadata : public SymbolData {
203 const MemRegion* R;
204 const Stmt *S;
205 QualType T;
206 const LocationContext *LCtx;
207 unsigned Count;
208 const void *Tag;
209
210 public:
211 SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
212 const LocationContext *LCtx, unsigned count, const void *tag)
213 : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
214 Count(count), Tag(tag) {
215 assert(r);
216 assert(s);
217 assert(isValidTypeForSymbol(t));
218 assert(LCtx);
219 assert(tag);
220 }
221
222 const MemRegion *getRegion() const { return R; }
223 const Stmt *getStmt() const { return S; }
224 const LocationContext *getLocationContext() const { return LCtx; }
225 unsigned getCount() const { return Count; }
226 const void *getTag() const { return Tag; }
227
228 QualType getType() const override;
229
230 void dumpToStream(raw_ostream &os) const override;
231
232 static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R,
233 const Stmt *S, QualType T, const LocationContext *LCtx,
234 unsigned Count, const void *Tag) {
235 profile.AddInteger((unsigned) SymbolMetadataKind);
236 profile.AddPointer(R);
237 profile.AddPointer(S);
238 profile.Add(T);
239 profile.AddPointer(LCtx);
240 profile.AddInteger(Count);
241 profile.AddPointer(Tag);
242 }
243
244 void Profile(llvm::FoldingSetNodeID& profile) override {
245 Profile(profile, R, S, T, LCtx, Count, Tag);
246 }
247
248 // Implement isa<T> support.
249 static bool classof(const SymExpr *SE) {
250 return SE->getKind() == SymbolMetadataKind;
251 }
252 };
253
254 /// Represents a cast expression.
255 class SymbolCast : public SymExpr {
256 const SymExpr *Operand;
257
258 /// Type of the operand.
259 QualType FromTy;
260
261 /// The type of the result.
262 QualType ToTy;
263
264 public:
265 SymbolCast(const SymExpr *In, QualType From, QualType To)
266 : SymExpr(SymbolCastKind), Operand(In), FromTy(From), ToTy(To) {
267 assert(In);
268 assert(isValidTypeForSymbol(From));
269 // FIXME: GenericTaintChecker creates symbols of void type.
270 // Otherwise, 'To' should also be a valid type.
271 }
272
273 unsigned computeComplexity() const override {
274 if (Complexity == 0)
275 Complexity = 1 + Operand->computeComplexity();
276 return Complexity;
277 }
278
279 QualType getType() const override { return ToTy; }
280
281 const SymExpr *getOperand() const { return Operand; }
282
283 void dumpToStream(raw_ostream &os) const override;
284
285 static void Profile(llvm::FoldingSetNodeID& ID,
286 const SymExpr *In, QualType From, QualType To) {
287 ID.AddInteger((unsigned) SymbolCastKind);
288 ID.AddPointer(In);
289 ID.Add(From);
290 ID.Add(To);
291 }
292
293 void Profile(llvm::FoldingSetNodeID& ID) override {
294 Profile(ID, Operand, FromTy, ToTy);
295 }
296
297 // Implement isa<T> support.
298 static bool classof(const SymExpr *SE) {
299 return SE->getKind() == SymbolCastKind;
300 }
301 };
302
303 /// Represents a symbolic expression involving a binary operator
304 class BinarySymExpr : public SymExpr {
305 BinaryOperator::Opcode Op;
306 QualType T;
307
308 protected:
309 BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t)
310 : SymExpr(k), Op(op), T(t) {
311 assert(classof(this));
312 // Binary expressions are results of arithmetic. Pointer arithmetic is not
313 // handled by binary expressions, but it is instead handled by applying
314 // sub-regions to regions.
315 assert(isValidTypeForSymbol(t) && !Loc::isLocType(t));
316 }
317
318 public:
319 // FIXME: We probably need to make this out-of-line to avoid redundant
320 // generation of virtual functions.
321 QualType getType() const override { return T; }
322
323 BinaryOperator::Opcode getOpcode() const { return Op; }
324
325 // Implement isa<T> support.
326 static bool classof(const SymExpr *SE) {
327 Kind k = SE->getKind();
328 return k >= BEGIN_BINARYSYMEXPRS && k <= END_BINARYSYMEXPRS;
329 }
330 };
331
332 /// Represents a symbolic expression like 'x' + 3.
333 class SymIntExpr : public BinarySymExpr {
334 const SymExpr *LHS;
335 const llvm::APSInt& RHS;
336
337 public:
338 SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
339 const llvm::APSInt &rhs, QualType t)
340 : BinarySymExpr(SymIntExprKind, op, t), LHS(lhs), RHS(rhs) {
341 assert(lhs);
342 }
343
344 void dumpToStream(raw_ostream &os) const override;
345
346 const SymExpr *getLHS() const { return LHS; }
347 const llvm::APSInt &getRHS() const { return RHS; }
348
349 unsigned computeComplexity() const override {
350 if (Complexity == 0)
351 Complexity = 1 + LHS->computeComplexity();
352 return Complexity;
353 }
354
355 static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
356 BinaryOperator::Opcode op, const llvm::APSInt& rhs,
357 QualType t) {
358 ID.AddInteger((unsigned) SymIntExprKind);
359 ID.AddPointer(lhs);
360 ID.AddInteger(op);
361 ID.AddPointer(&rhs);
362 ID.Add(t);
363 }
364
365 void Profile(llvm::FoldingSetNodeID& ID) override {
366 Profile(ID, LHS, getOpcode(), RHS, getType());
367 }
368
369 // Implement isa<T> support.
370 static bool classof(const SymExpr *SE) {
371 return SE->getKind() == SymIntExprKind;
372 }
373 };
374
375 /// Represents a symbolic expression like 3 - 'x'.
376 class IntSymExpr : public BinarySymExpr {
377 const llvm::APSInt& LHS;
378 const SymExpr *RHS;
379
380 public:
381 IntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op,
382 const SymExpr *rhs, QualType t)
383 : BinarySymExpr(IntSymExprKind, op, t), LHS(lhs), RHS(rhs) {
384 assert(rhs);
385 }
386
387 void dumpToStream(raw_ostream &os) const override;
388
389 const SymExpr *getRHS() const { return RHS; }
390 const llvm::APSInt &getLHS() const { return LHS; }
391
392 unsigned computeComplexity() const override {
393 if (Complexity == 0)
394 Complexity = 1 + RHS->computeComplexity();
395 return Complexity;
396 }
397
398 static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
399 BinaryOperator::Opcode op, const SymExpr *rhs,
400 QualType t) {
401 ID.AddInteger((unsigned) IntSymExprKind);
402 ID.AddPointer(&lhs);
403 ID.AddInteger(op);
404 ID.AddPointer(rhs);
405 ID.Add(t);
406 }
407
408 void Profile(llvm::FoldingSetNodeID& ID) override {
409 Profile(ID, LHS, getOpcode(), RHS, getType());
410 }
411
412 // Implement isa<T> support.
413 static bool classof(const SymExpr *SE) {
414 return SE->getKind() == IntSymExprKind;
415 }
416 };
417
418 /// Represents a symbolic expression like 'x' + 'y'.
419 class SymSymExpr : public BinarySymExpr {
420 const SymExpr *LHS;
421 const SymExpr *RHS;
422
423 public:
424 SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs,
425 QualType t)
426 : BinarySymExpr(SymSymExprKind, op, t), LHS(lhs), RHS(rhs) {
427 assert(lhs);
428 assert(rhs);
429 }
430
431 const SymExpr *getLHS() const { return LHS; }
432 const SymExpr *getRHS() const { return RHS; }
433
434 void dumpToStream(raw_ostream &os) const override;
435
436 unsigned computeComplexity() const override {
437 if (Complexity == 0)
438 Complexity = RHS->computeComplexity() + LHS->computeComplexity();
439 return Complexity;
440 }
441
442 static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
443 BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
444 ID.AddInteger((unsigned) SymSymExprKind);
445 ID.AddPointer(lhs);
446 ID.AddInteger(op);
447 ID.AddPointer(rhs);
448 ID.Add(t);
449 }
450
451 void Profile(llvm::FoldingSetNodeID& ID) override {
452 Profile(ID, LHS, getOpcode(), RHS, getType());
453 }
454
455 // Implement isa<T> support.
456 static bool classof(const SymExpr *SE) {
457 return SE->getKind() == SymSymExprKind;
458 }
459 };
460
461 class SymbolManager {
462 using DataSetTy = llvm::FoldingSet<SymExpr>;
463 using SymbolDependTy = llvm::DenseMap<SymbolRef, SymbolRefSmallVectorTy *>;
464
465 DataSetTy DataSet;
466
467 /// Stores the extra dependencies between symbols: the data should be kept
468 /// alive as long as the key is live.
469 SymbolDependTy SymbolDependencies;
470
471 unsigned SymbolCounter = 0;
472 llvm::BumpPtrAllocator& BPAlloc;
473 BasicValueFactory &BV;
474 ASTContext &Ctx;
475
476 public:
477 SymbolManager(ASTContext &ctx, BasicValueFactory &bv,
478 llvm::BumpPtrAllocator& bpalloc)
479 : SymbolDependencies(16), BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
480 ~SymbolManager();
481
482 static bool canSymbolicate(QualType T);
483
484 /// Make a unique symbol for MemRegion R according to its kind.
485 const SymbolRegionValue* getRegionValueSymbol(const TypedValueRegion* R);
486
487 const SymbolConjured* conjureSymbol(const Stmt *E,
488 const LocationContext *LCtx,
489 QualType T,
490 unsigned VisitCount,
491 const void *SymbolTag = nullptr);
492
493 const SymbolConjured* conjureSymbol(const Expr *E,
494 const LocationContext *LCtx,
495 unsigned VisitCount,
496 const void *SymbolTag = nullptr) {
497 return conjureSymbol(E, LCtx, E->getType(), VisitCount, SymbolTag);
498 }
499
500 const SymbolDerived *getDerivedSymbol(SymbolRef parentSymbol,
501 const TypedValueRegion *R);
502
503 const SymbolExtent *getExtentSymbol(const SubRegion *R);
504
505 /// Creates a metadata symbol associated with a specific region.
506 ///
507 /// VisitCount can be used to differentiate regions corresponding to
508 /// different loop iterations, thus, making the symbol path-dependent.
509 const SymbolMetadata *getMetadataSymbol(const MemRegion *R, const Stmt *S,
510 QualType T,
511 const LocationContext *LCtx,
512 unsigned VisitCount,
513 const void *SymbolTag = nullptr);
514
515 const SymbolCast* getCastSymbol(const SymExpr *Operand,
516 QualType From, QualType To);
517
518 const SymIntExpr *getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
519 const llvm::APSInt& rhs, QualType t);
520
521 const SymIntExpr *getSymIntExpr(const SymExpr &lhs, BinaryOperator::Opcode op,
522 const llvm::APSInt& rhs, QualType t) {
523 return getSymIntExpr(&lhs, op, rhs, t);
524 }
525
526 const IntSymExpr *getIntSymExpr(const llvm::APSInt& lhs,
527 BinaryOperator::Opcode op,
528 const SymExpr *rhs, QualType t);
529
530 const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
531 const SymExpr *rhs, QualType t);
532
533 QualType getType(const SymExpr *SE) const {
534 return SE->getType();
535 }
536
537 /// Add artificial symbol dependency.
538 ///
539 /// The dependent symbol should stay alive as long as the primary is alive.
540 void addSymbolDependency(const SymbolRef Primary, const SymbolRef Dependent);
541
542 const SymbolRefSmallVectorTy *getDependentSymbols(const SymbolRef Primary);
543
544 ASTContext &getContext() { return Ctx; }
545 BasicValueFactory &getBasicVals() { return BV; }
546 };
547
548 /// A class responsible for cleaning up unused symbols.
549 class SymbolReaper {
550 enum SymbolStatus {
551 NotProcessed,
552 HaveMarkedDependents
553 };
554
555 using SymbolSetTy = llvm::DenseSet<SymbolRef>;
556 using SymbolMapTy = llvm::DenseMap<SymbolRef, SymbolStatus>;
557 using RegionSetTy = llvm::DenseSet<const MemRegion *>;
558
559 SymbolMapTy TheLiving;
560 SymbolSetTy MetadataInUse;
561
562 RegionSetTy RegionRoots;
563
564 const StackFrameContext *LCtx;
565 const Stmt *Loc;
566 SymbolManager& SymMgr;
567 StoreRef reapedStore;
568 llvm::DenseMap<const MemRegion *, unsigned> includedRegionCache;
569
570 public:
571 /// Construct a reaper object, which removes everything which is not
572 /// live before we execute statement s in the given location context.
573 ///
574 /// If the statement is NULL, everything is this and parent contexts is
575 /// considered live.
576 /// If the stack frame context is NULL, everything on stack is considered
577 /// dead.
578 SymbolReaper(const StackFrameContext *Ctx, const Stmt *s,
579 SymbolManager &symmgr, StoreManager &storeMgr)
580 : LCtx(Ctx), Loc(s), SymMgr(symmgr), reapedStore(nullptr, storeMgr) {}
581
582 const LocationContext *getLocationContext() const { return LCtx; }
583
584 bool isLive(SymbolRef sym);
585 bool isLiveRegion(const MemRegion *region);
586 bool isLive(const Stmt *ExprVal, const LocationContext *LCtx) const;
587 bool isLive(const VarRegion *VR, bool includeStoreBindings = false) const;
588
589 /// Unconditionally marks a symbol as live.
590 ///
591 /// This should never be
592 /// used by checkers, only by the state infrastructure such as the store and
593 /// environment. Checkers should instead use metadata symbols and markInUse.
594 void markLive(SymbolRef sym);
595
596 /// Marks a symbol as important to a checker.
597 ///
598 /// For metadata symbols,
599 /// this will keep the symbol alive as long as its associated region is also
600 /// live. For other symbols, this has no effect; checkers are not permitted
601 /// to influence the life of other symbols. This should be used before any
602 /// symbol marking has occurred, i.e. in the MarkLiveSymbols callback.
603 void markInUse(SymbolRef sym);
604
605 using region_iterator = RegionSetTy::const_iterator;
606
607 region_iterator region_begin() const { return RegionRoots.begin(); }
608 region_iterator region_end() const { return RegionRoots.end(); }
609
610 /// Returns whether or not a symbol has been confirmed dead.
611 ///
612 /// This should only be called once all marking of dead symbols has completed.
613 /// (For checkers, this means only in the checkDeadSymbols callback.)
614 bool isDead(SymbolRef sym) {
615 return !isLive(sym);
616 }
617
618 void markLive(const MemRegion *region);
619 void markElementIndicesLive(const MemRegion *region);
620
621 /// Set to the value of the symbolic store after
622 /// StoreManager::removeDeadBindings has been called.
623 void setReapedStore(StoreRef st) { reapedStore = st; }
624
625 private:
626 /// Mark the symbols dependent on the input symbol as live.
627 void markDependentsLive(SymbolRef sym);
628 };
629
630 class SymbolVisitor {
631 protected:
632 ~SymbolVisitor() = default;
633
634 public:
635 SymbolVisitor() = default;
636 SymbolVisitor(const SymbolVisitor &) = default;
637 SymbolVisitor(SymbolVisitor &&) {}
638
639 /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
640 ///
641 /// The method returns \c true if symbols should continue be scanned and \c
642 /// false otherwise.
643 virtual bool VisitSymbol(SymbolRef sym) = 0;
644 virtual bool VisitMemRegion(const MemRegion *) { return true; }
645 };
646
647 } // namespace ento
648
649 } // namespace clang
650
651 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
StoreRef.h
clang::Builtin::ID
ID
Definition: Builtins.h:49
ento
clang::ento::SymIntExpr::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:370
clang::ento::TypedValueRegion
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:530
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
clang::ento::MemRegion
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:95
clang::ento::SymbolDerived::SymbolDerived
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
Definition: SymbolManager.h:133
clang::ento::SymbolReaper::isDead
bool isDead(SymbolRef sym)
Returns whether or not a symbol has been confirmed dead.
Definition: SymbolManager.h:614
clang::ento::SymSymExpr::computeComplexity
unsigned computeComplexity() const override
Definition: SymbolManager.h:436
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
Type.h
C Language Family Type Representation.
clang::ento::SymbolRegionValue::Profile
static void Profile(llvm::FoldingSetNodeID &profile, const TypedValueRegion *R)
Definition: SymbolManager.h:54
clang::ento::SymbolExtent::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:193
clang::ento::TypedValueRegion::getValueType
virtual QualType getValueType() const =0
clang::ento::SymbolCast::getOperand
const SymExpr * getOperand() const
Definition: SymbolManager.h:281
llvm::DenseSet< SymbolRef >
clang::ento::SymbolMetadata::Profile
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:244
clang::LocationContext
Definition: AnalysisDeclContext.h:218
MemRegion.h
clang::ento::SymExpr::computeComplexity
virtual unsigned computeComplexity() const =0
clang::ento::SymbolManager::getBasicVals
BasicValueFactory & getBasicVals()
Definition: SymbolManager.h:545
clang::ento::SymbolManager::SymbolManager
SymbolManager(ASTContext &ctx, BasicValueFactory &bv, llvm::BumpPtrAllocator &bpalloc)
Definition: SymbolManager.h:477
clang::ento::BasicValueFactory
Definition: BasicValueFactory.h:107
clang::ento::SymExpr
Symbolic value.
Definition: SymExpr.h:30
clang::ento::SymbolManager::getContext
ASTContext & getContext()
Definition: SymbolManager.h:544
clang::ento::SymbolCast::SymbolCast
SymbolCast(const SymExpr *In, QualType From, QualType To)
Definition: SymbolManager.h:265
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:155
clang::ento::SymbolDerived::Profile
static void Profile(llvm::FoldingSetNodeID &profile, SymbolRef parent, const TypedValueRegion *r)
Definition: SymbolManager.h:148
clang::ento::SymbolExtent::Profile
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:188
clang::ento::SymbolReaper::SymbolReaper
SymbolReaper(const StackFrameContext *Ctx, const Stmt *s, SymbolManager &symmgr, StoreManager &storeMgr)
Construct a reaper object, which removes everything which is not live before we execute statement s i...
Definition: SymbolManager.h:578
clang::ento::SymbolConjured::getCount
unsigned getCount() const
Definition: SymbolManager.h:98
clang::ento::VarRegion
Definition: MemRegion.h:931
clang::ento::SymExpr::Complexity
unsigned Complexity
Definition: SymExpr.h:52
clang::ento::SymbolReaper::setReapedStore
void setReapedStore(StoreRef st)
Set to the value of the symbolic store after StoreManager::removeDeadBindings has been called...
Definition: SymbolManager.h:623
clang::ento::SymIntExpr::Profile
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
Definition: SymbolManager.h:355
clang::ento::SymbolConjured::SymbolConjured
SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx, QualType t, unsigned count, const void *symbolTag)
Definition: SymbolManager.h:84
clang::ento::SymbolManager
Definition: SymbolManager.h:461
clang::ento::Loc::isLocType
static bool isLocType(QualType T)
Definition: SVals.h:327
clang::ento::SymbolExtent::SymbolExtent
SymbolExtent(SymbolID sym, const SubRegion *r)
Definition: SymbolManager.h:172
clang::BinaryOperatorKind
BinaryOperatorKind
Definition: OperationKinds.h:26
clang::ento::SymbolMetadata::getCount
unsigned getCount() const
Definition: SymbolManager.h:225
clang::ento::SymSymExpr::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:456
clang::ento::SymbolVisitor
Definition: SymbolManager.h:630
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::ento::SymbolManager::getType
QualType getType(const SymExpr *SE) const
Definition: SymbolManager.h:533
clang::ento::SymbolReaper::region_iterator
RegionSetTy::const_iterator region_iterator
Definition: SymbolManager.h:605
clang::ento::SymIntExpr
Represents a symbolic expression like &#39;x&#39; + 3.
Definition: SymbolManager.h:333
clang::ento::SymbolDerived
A symbol representing the value of a MemRegion whose parent region has symbolic value.
Definition: SymbolManager.h:128
clang::ento::SymExpr::Kind
Kind
Definition: SymExpr.h:34
clang::ento::SymbolCast::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: SymbolManager.h:293
clang::ento::SymbolMetadata::getRegion
const MemRegion * getRegion() const
Definition: SymbolManager.h:222
clang::ento::SymExpr::getType
virtual QualType getType() const =0
clang::ento::IntSymExpr::Profile
static void Profile(llvm::FoldingSetNodeID &ID, const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
Definition: SymbolManager.h:398
clang::ento::SymbolMetadata::getTag
const void * getTag() const
Definition: SymbolManager.h:226
clang::ento::SymbolReaper::getLocationContext
const LocationContext * getLocationContext() const
Definition: SymbolManager.h:582
clang::ento::SymbolCast::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:298
clang::ento::SymbolConjured::Profile
static void Profile(llvm::FoldingSetNodeID &profile, const Stmt *S, QualType T, unsigned Count, const LocationContext *LCtx, const void *SymbolTag)
Definition: SymbolManager.h:105
clang::ento::StoreManager
Definition: Store.h:54
clang::ento::SymbolManager::getSymIntExpr
const SymIntExpr * getSymIntExpr(const SymExpr &lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
Definition: SymbolManager.h:521
clang::Expr
This represents one expression.
Definition: Expr.h:106
clang::ento::SymbolDerived::getRegion
const TypedValueRegion * getRegion() const
Definition: SymbolManager.h:141
clang::ento::SymbolConjured::Profile
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:116
clang::ento::SymbolExtent::getRegion
const SubRegion * getRegion() const
Definition: SymbolManager.h:177
clang::ento::SymbolCast
Represents a cast expression.
Definition: SymbolManager.h:255
clang::ento::StoreRef
Definition: StoreRef.h:30
clang::ento::SymbolMetadata::getLocationContext
const LocationContext * getLocationContext() const
Definition: SymbolManager.h:224
clang::Expr::getType
QualType getType() const
Definition: Expr.h:128
clang::ento::SymbolMetadata::Profile
static void Profile(llvm::FoldingSetNodeID &profile, const MemRegion *R, const Stmt *S, QualType T, const LocationContext *LCtx, unsigned Count, const void *Tag)
Definition: SymbolManager.h:232
clang::ento::SymbolDerived::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:160
clang::ento::SymbolVisitor::VisitMemRegion
virtual bool VisitMemRegion(const MemRegion *)
Definition: SymbolManager.h:644
clang::ento::IntSymExpr::IntSymExpr
IntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
Definition: SymbolManager.h:381
AnalysisDeclContext.h
clang::ento::IntSymExpr::getRHS
const SymExpr * getRHS() const
Definition: SymbolManager.h:389
clang::ento::SymbolRegionValue::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:69
clang::ento::SymbolRegionValue::getRegion
const TypedValueRegion * getRegion() const
Definition: SymbolManager.h:52
clang::ento::Loc
Definition: SVals.h:318
clang::ento::SymSymExpr::getLHS
const SymExpr * getLHS() const
Definition: SymbolManager.h:431
clang::ento::SymbolConjured::getTag
const void * getTag() const
Definition: SymbolManager.h:99
clang::ento::IntSymExpr
Represents a symbolic expression like 3 - &#39;x&#39;.
Definition: SymbolManager.h:376
clang::ento::SymbolManager::conjureSymbol
const SymbolConjured * conjureSymbol(const Expr *E, const LocationContext *LCtx, unsigned VisitCount, const void *SymbolTag=nullptr)
Definition: SymbolManager.h:493
llvm::SmallVector
Definition: LLVM.h:36
clang::ento::SymbolRegionValue::dumpToStream
void dumpToStream(raw_ostream &os) const override
Definition: SymbolManager.cpp:111
clang::ento::BinarySymExpr::getType
QualType getType() const override
Definition: SymbolManager.h:321
clang::ento::IntSymExpr::getLHS
const llvm::APSInt & getLHS() const
Definition: SymbolManager.h:390
clang::ento::SymbolReaper
A class responsible for cleaning up unused symbols.
Definition: SymbolManager.h:549
clang::ento::SymIntExpr::SymIntExpr
SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
Definition: SymbolManager.h:338
clang::ento::IntSymExpr::computeComplexity
unsigned computeComplexity() const override
Definition: SymbolManager.h:392
clang::ento::SymbolReaper::region_end
region_iterator region_end() const
Definition: SymbolManager.h:608
clang::ento::SymbolCast::getType
QualType getType() const override
Definition: SymbolManager.h:279
clang::ento::SymbolConjured
A symbol representing the result of an expression in the case when we do not know anything about what...
Definition: SymbolManager.h:76
clang::ento::SymExpr::isValidTypeForSymbol
static bool isValidTypeForSymbol(QualType T)
Definition: SymExpr.h:46
clang::ento::SymbolRegionValue
A symbol representing the value stored at a MemRegion.
Definition: SymbolManager.h:42
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::ento::SymbolCast::Profile
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *In, QualType From, QualType To)
Definition: SymbolManager.h:285
clang::ento::SymbolRegionValue::SymbolRegionValue
SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
Definition: SymbolManager.h:46
clang::ento::BinarySymExpr
Represents a symbolic expression involving a binary operator.
Definition: SymbolManager.h:304
clang::ento::SymIntExpr::getRHS
const llvm::APSInt & getRHS() const
Definition: SymbolManager.h:347
IteratorComparison::getOpcode
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
clang::ento::SymbolReaper::region_begin
region_iterator region_begin() const
Definition: SymbolManager.h:607
clang::ento::SymbolDerived::getOriginRegion
const MemRegion * getOriginRegion() const override
Find the region from which this symbol originates.
Definition: SymbolManager.h:146
clang::ento::SymbolMetadata::getStmt
const Stmt * getStmt() const
Definition: SymbolManager.h:223
clang::ento::SymbolRegionValue::getType
QualType getType() const override
Definition: SymbolManager.cpp:341
clang::ento::SymbolConjured::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:121
clang::ento::SymbolMetadata::SymbolMetadata
SymbolMetadata(SymbolID sym, const MemRegion *r, const Stmt *s, QualType t, const LocationContext *LCtx, unsigned count, const void *tag)
Definition: SymbolManager.h:211
clang::ento::SymSymExpr::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: SymbolManager.h:451
clang::ento::SymIntExpr::computeComplexity
unsigned computeComplexity() const override
Definition: SymbolManager.h:349
clang::ento::SymSymExpr::getRHS
const SymExpr * getRHS() const
Definition: SymbolManager.h:432
clang::ento::SymbolVisitor::SymbolVisitor
SymbolVisitor(SymbolVisitor &&)
Definition: SymbolManager.h:637
SymExpr.h
clang::ento::BinarySymExpr::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:326
clang::ento::SubRegion
SubRegion - A region that subsets another larger region.
Definition: MemRegion.h:436
clang::ento::IntSymExpr::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: SymbolManager.h:408
clang::ento::SymbolConjured::getStmt
const Stmt * getStmt() const
Definition: SymbolManager.h:97
clang::ento::SymbolMetadata
SymbolMetadata - Represents path-dependent metadata about a specific region.
Definition: SymbolManager.h:202
clang::StackFrameContext
Definition: AnalysisDeclContext.h:292
clang::ento::SymbolExtent::Profile
static void Profile(llvm::FoldingSetNodeID &profile, const SubRegion *R)
Definition: SymbolManager.h:183
clang::ento::SymExpr::getKind
Kind getKind() const
Definition: SymExpr.h:57
clang::ento::SymbolID
unsigned SymbolID
Definition: SymExpr.h:113
clang::ento::SymbolRegionValue::getOriginRegion
const MemRegion * getOriginRegion() const override
Find the region from which this symbol originates.
Definition: SymbolManager.h:64
clang::ento::BinarySymExpr::getOpcode
BinaryOperator::Opcode getOpcode() const
Definition: SymbolManager.h:323
clang::ento::SymbolDerived::getParentSymbol
SymbolRef getParentSymbol() const
Definition: SymbolManager.h:140
clang::ento::SymSymExpr::SymSymExpr
SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
Definition: SymbolManager.h:424
clang::ento::SymbolRegionValue::Profile
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:59
clang::ento::SymbolMetadata::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:249
clang::ento::IntSymExpr::classof
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:413
Expr.h
clang::ento::BinarySymExpr::BinarySymExpr
BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t)
Definition: SymbolManager.h:309
clang::ento::SymbolExtent
SymbolExtent - Represents the extent (size in bytes) of a bounded region.
Definition: SymbolManager.h:168
clang::ento::SymbolDerived::Profile
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:155
clang::ento::SymIntExpr::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: SymbolManager.h:365
clang::ento::SymbolCast::computeComplexity
unsigned computeComplexity() const override
Definition: SymbolManager.h:273
clang::ento::SymSymExpr
Represents a symbolic expression like &#39;x&#39; + &#39;y&#39;.
Definition: SymbolManager.h:419
clang::ento::SymbolData
A symbol representing data which can be stored in a memory location (region).
Definition: SymExpr.h:117
clang::ento::SymIntExpr::getLHS
const SymExpr * getLHS() const
Definition: SymbolManager.h:346
clang::ento::SymSymExpr::Profile
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
Definition: SymbolManager.h:442