clang  7.0.0svn
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"
21 #include "clang/Basic/LLVM.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:
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:
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:
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  QualType getType() const override { return ToTy; }
274 
275  const SymExpr *getOperand() const { return Operand; }
276 
277  void dumpToStream(raw_ostream &os) const override;
278 
279  static void Profile(llvm::FoldingSetNodeID& ID,
280  const SymExpr *In, QualType From, QualType To) {
281  ID.AddInteger((unsigned) SymbolCastKind);
282  ID.AddPointer(In);
283  ID.Add(From);
284  ID.Add(To);
285  }
286 
287  void Profile(llvm::FoldingSetNodeID& ID) override {
288  Profile(ID, Operand, FromTy, ToTy);
289  }
290 
291  // Implement isa<T> support.
292  static bool classof(const SymExpr *SE) {
293  return SE->getKind() == SymbolCastKind;
294  }
295 };
296 
297 /// Represents a symbolic expression involving a binary operator
298 class BinarySymExpr : public SymExpr {
300  QualType T;
301 
302 protected:
304  : SymExpr(k), Op(op), T(t) {
305  assert(classof(this));
306  assert(isValidTypeForSymbol(t));
307  }
308 
309 public:
310  // FIXME: We probably need to make this out-of-line to avoid redundant
311  // generation of virtual functions.
312  QualType getType() const override { return T; }
313 
314  BinaryOperator::Opcode getOpcode() const { return Op; }
315 
316  // Implement isa<T> support.
317  static bool classof(const SymExpr *SE) {
318  Kind k = SE->getKind();
319  return k >= BEGIN_BINARYSYMEXPRS && k <= END_BINARYSYMEXPRS;
320  }
321 };
322 
323 /// Represents a symbolic expression like 'x' + 3.
324 class SymIntExpr : public BinarySymExpr {
325  const SymExpr *LHS;
326  const llvm::APSInt& RHS;
327 
328 public:
330  const llvm::APSInt &rhs, QualType t)
331  : BinarySymExpr(SymIntExprKind, op, t), LHS(lhs), RHS(rhs) {
332  assert(lhs);
333  }
334 
335  void dumpToStream(raw_ostream &os) const override;
336 
337  const SymExpr *getLHS() const { return LHS; }
338  const llvm::APSInt &getRHS() const { return RHS; }
339 
340  static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
341  BinaryOperator::Opcode op, const llvm::APSInt& rhs,
342  QualType t) {
343  ID.AddInteger((unsigned) SymIntExprKind);
344  ID.AddPointer(lhs);
345  ID.AddInteger(op);
346  ID.AddPointer(&rhs);
347  ID.Add(t);
348  }
349 
350  void Profile(llvm::FoldingSetNodeID& ID) override {
351  Profile(ID, LHS, getOpcode(), RHS, getType());
352  }
353 
354  // Implement isa<T> support.
355  static bool classof(const SymExpr *SE) {
356  return SE->getKind() == SymIntExprKind;
357  }
358 };
359 
360 /// Represents a symbolic expression like 3 - 'x'.
361 class IntSymExpr : public BinarySymExpr {
362  const llvm::APSInt& LHS;
363  const SymExpr *RHS;
364 
365 public:
366  IntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op,
367  const SymExpr *rhs, QualType t)
368  : BinarySymExpr(IntSymExprKind, op, t), LHS(lhs), RHS(rhs) {
369  assert(rhs);
370  }
371 
372  void dumpToStream(raw_ostream &os) const override;
373 
374  const SymExpr *getRHS() const { return RHS; }
375  const llvm::APSInt &getLHS() const { return LHS; }
376 
377  static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
378  BinaryOperator::Opcode op, const SymExpr *rhs,
379  QualType t) {
380  ID.AddInteger((unsigned) IntSymExprKind);
381  ID.AddPointer(&lhs);
382  ID.AddInteger(op);
383  ID.AddPointer(rhs);
384  ID.Add(t);
385  }
386 
387  void Profile(llvm::FoldingSetNodeID& ID) override {
388  Profile(ID, LHS, getOpcode(), RHS, getType());
389  }
390 
391  // Implement isa<T> support.
392  static bool classof(const SymExpr *SE) {
393  return SE->getKind() == IntSymExprKind;
394  }
395 };
396 
397 /// Represents a symbolic expression like 'x' + 'y'.
398 class SymSymExpr : public BinarySymExpr {
399  const SymExpr *LHS;
400  const SymExpr *RHS;
401 
402 public:
403  SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs,
404  QualType t)
405  : BinarySymExpr(SymSymExprKind, op, t), LHS(lhs), RHS(rhs) {
406  assert(lhs);
407  assert(rhs);
408  }
409 
410  const SymExpr *getLHS() const { return LHS; }
411  const SymExpr *getRHS() const { return RHS; }
412 
413  void dumpToStream(raw_ostream &os) const override;
414 
415  static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
416  BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
417  ID.AddInteger((unsigned) SymSymExprKind);
418  ID.AddPointer(lhs);
419  ID.AddInteger(op);
420  ID.AddPointer(rhs);
421  ID.Add(t);
422  }
423 
424  void Profile(llvm::FoldingSetNodeID& ID) override {
425  Profile(ID, LHS, getOpcode(), RHS, getType());
426  }
427 
428  // Implement isa<T> support.
429  static bool classof(const SymExpr *SE) {
430  return SE->getKind() == SymSymExprKind;
431  }
432 };
433 
435  using DataSetTy = llvm::FoldingSet<SymExpr>;
436  using SymbolDependTy = llvm::DenseMap<SymbolRef, SymbolRefSmallVectorTy *>;
437 
438  DataSetTy DataSet;
439 
440  /// Stores the extra dependencies between symbols: the data should be kept
441  /// alive as long as the key is live.
442  SymbolDependTy SymbolDependencies;
443 
444  unsigned SymbolCounter = 0;
445  llvm::BumpPtrAllocator& BPAlloc;
446  BasicValueFactory &BV;
447  ASTContext &Ctx;
448 
449 public:
451  llvm::BumpPtrAllocator& bpalloc)
452  : SymbolDependencies(16), BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
453  ~SymbolManager();
454 
455  static bool canSymbolicate(QualType T);
456 
457  /// Make a unique symbol for MemRegion R according to its kind.
458  const SymbolRegionValue* getRegionValueSymbol(const TypedValueRegion* R);
459 
460  const SymbolConjured* conjureSymbol(const Stmt *E,
461  const LocationContext *LCtx,
462  QualType T,
463  unsigned VisitCount,
464  const void *SymbolTag = nullptr);
465 
467  const LocationContext *LCtx,
468  unsigned VisitCount,
469  const void *SymbolTag = nullptr) {
470  return conjureSymbol(E, LCtx, E->getType(), VisitCount, SymbolTag);
471  }
472 
473  const SymbolDerived *getDerivedSymbol(SymbolRef parentSymbol,
474  const TypedValueRegion *R);
475 
476  const SymbolExtent *getExtentSymbol(const SubRegion *R);
477 
478  /// Creates a metadata symbol associated with a specific region.
479  ///
480  /// VisitCount can be used to differentiate regions corresponding to
481  /// different loop iterations, thus, making the symbol path-dependent.
482  const SymbolMetadata *getMetadataSymbol(const MemRegion *R, const Stmt *S,
483  QualType T,
484  const LocationContext *LCtx,
485  unsigned VisitCount,
486  const void *SymbolTag = nullptr);
487 
488  const SymbolCast* getCastSymbol(const SymExpr *Operand,
489  QualType From, QualType To);
490 
491  const SymIntExpr *getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
492  const llvm::APSInt& rhs, QualType t);
493 
495  const llvm::APSInt& rhs, QualType t) {
496  return getSymIntExpr(&lhs, op, rhs, t);
497  }
498 
499  const IntSymExpr *getIntSymExpr(const llvm::APSInt& lhs,
501  const SymExpr *rhs, QualType t);
502 
503  const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
504  const SymExpr *rhs, QualType t);
505 
506  QualType getType(const SymExpr *SE) const {
507  return SE->getType();
508  }
509 
510  /// Add artificial symbol dependency.
511  ///
512  /// The dependent symbol should stay alive as long as the primary is alive.
513  void addSymbolDependency(const SymbolRef Primary, const SymbolRef Dependent);
514 
515  const SymbolRefSmallVectorTy *getDependentSymbols(const SymbolRef Primary);
516 
517  ASTContext &getContext() { return Ctx; }
518  BasicValueFactory &getBasicVals() { return BV; }
519 };
520 
521 /// A class responsible for cleaning up unused symbols.
523  enum SymbolStatus {
524  NotProcessed,
525  HaveMarkedDependents
526  };
527 
529  using SymbolMapTy = llvm::DenseMap<SymbolRef, SymbolStatus>;
531 
532  SymbolMapTy TheLiving;
533  SymbolSetTy MetadataInUse;
534  SymbolSetTy TheDead;
535 
536  RegionSetTy RegionRoots;
537 
538  const StackFrameContext *LCtx;
539  const Stmt *Loc;
540  SymbolManager& SymMgr;
541  StoreRef reapedStore;
542  llvm::DenseMap<const MemRegion *, unsigned> includedRegionCache;
543 
544 public:
545  /// Construct a reaper object, which removes everything which is not
546  /// live before we execute statement s in the given location context.
547  ///
548  /// If the statement is NULL, everything is this and parent contexts is
549  /// considered live.
550  /// If the stack frame context is NULL, everything on stack is considered
551  /// dead.
552  SymbolReaper(const StackFrameContext *Ctx, const Stmt *s,
553  SymbolManager &symmgr, StoreManager &storeMgr)
554  : LCtx(Ctx), Loc(s), SymMgr(symmgr), reapedStore(nullptr, storeMgr) {}
555 
556  const LocationContext *getLocationContext() const { return LCtx; }
557 
558  bool isLive(SymbolRef sym);
559  bool isLiveRegion(const MemRegion *region);
560  bool isLive(const Stmt *ExprVal, const LocationContext *LCtx) const;
561  bool isLive(const VarRegion *VR, bool includeStoreBindings = false) const;
562 
563  /// Unconditionally marks a symbol as live.
564  ///
565  /// This should never be
566  /// used by checkers, only by the state infrastructure such as the store and
567  /// environment. Checkers should instead use metadata symbols and markInUse.
568  void markLive(SymbolRef sym);
569 
570  /// Marks a symbol as important to a checker.
571  ///
572  /// For metadata symbols,
573  /// this will keep the symbol alive as long as its associated region is also
574  /// live. For other symbols, this has no effect; checkers are not permitted
575  /// to influence the life of other symbols. This should be used before any
576  /// symbol marking has occurred, i.e. in the MarkLiveSymbols callback.
577  void markInUse(SymbolRef sym);
578 
579  /// If a symbol is known to be live, marks the symbol as live.
580  ///
581  /// Otherwise, if the symbol cannot be proven live, it is marked as dead.
582  /// Returns true if the symbol is dead, false if live.
583  bool maybeDead(SymbolRef sym);
584 
585  using dead_iterator = SymbolSetTy::const_iterator;
586 
587  dead_iterator dead_begin() const { return TheDead.begin(); }
588  dead_iterator dead_end() const { return TheDead.end(); }
589 
590  bool hasDeadSymbols() const {
591  return !TheDead.empty();
592  }
593 
594  using region_iterator = RegionSetTy::const_iterator;
595 
596  region_iterator region_begin() const { return RegionRoots.begin(); }
597  region_iterator region_end() const { return RegionRoots.end(); }
598 
599  /// Returns whether or not a symbol has been confirmed dead.
600  ///
601  /// This should only be called once all marking of dead symbols has completed.
602  /// (For checkers, this means only in the evalDeadSymbols callback.)
603  bool isDead(SymbolRef sym) const {
604  return TheDead.count(sym);
605  }
606 
607  void markLive(const MemRegion *region);
608  void markElementIndicesLive(const MemRegion *region);
609 
610  /// Set to the value of the symbolic store after
611  /// StoreManager::removeDeadBindings has been called.
612  void setReapedStore(StoreRef st) { reapedStore = st; }
613 
614 private:
615  /// Mark the symbols dependent on the input symbol as live.
616  void markDependentsLive(SymbolRef sym);
617 };
618 
620 protected:
621  ~SymbolVisitor() = default;
622 
623 public:
624  SymbolVisitor() = default;
625  SymbolVisitor(const SymbolVisitor &) = default;
627 
628  /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
629  ///
630  /// The method returns \c true if symbols should continue be scanned and \c
631  /// false otherwise.
632  virtual bool VisitSymbol(SymbolRef sym) = 0;
633  virtual bool VisitMemRegion(const MemRegion *region) { return true; }
634 };
635 
636 } // namespace ento
637 
638 } // namespace clang
639 
640 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
static bool classof(const SymExpr *SE)
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:525
A (possibly-)qualified type.
Definition: Type.h:655
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:94
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
Stmt - This represents one statement.
Definition: Stmt.h:66
C Language Family Type Representation.
static void Profile(llvm::FoldingSetNodeID &profile, const TypedValueRegion *R)
Definition: SymbolManager.h:54
static bool classof(const SymExpr *SE)
virtual QualType getValueType() const =0
const SymExpr * getOperand() const
void Profile(llvm::FoldingSetNodeID &profile) override
BasicValueFactory & getBasicVals()
bool isDead(SymbolRef sym) const
Returns whether or not a symbol has been confirmed dead.
SymbolManager(ASTContext &ctx, BasicValueFactory &bv, llvm::BumpPtrAllocator &bpalloc)
Symbolic value.
Definition: SymExpr.h:30
SymbolCast(const SymExpr *In, QualType From, QualType To)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
static void Profile(llvm::FoldingSetNodeID &profile, SymbolRef parent, const TypedValueRegion *r)
void Profile(llvm::FoldingSetNodeID &profile) override
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...
unsigned getCount() const
Definition: SymbolManager.h:98
void setReapedStore(StoreRef st)
Set to the value of the symbolic store after StoreManager::removeDeadBindings has been called...
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx, QualType t, unsigned count, const void *symbolTag)
Definition: SymbolManager.h:84
SymbolExtent(SymbolID sym, const SubRegion *r)
BinaryOperatorKind
static bool classof(const SymExpr *SE)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
QualType getType(const SymExpr *SE) const
RegionSetTy::const_iterator region_iterator
Represents a symbolic expression like &#39;x&#39; + 3.
A symbol representing the value of a MemRegion whose parent region has symbolic value.
void Profile(llvm::FoldingSetNodeID &ID) override
const MemRegion * getRegion() const
virtual QualType getType() const =0
static void Profile(llvm::FoldingSetNodeID &ID, const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
const void * getTag() const
const LocationContext * getLocationContext() const
static bool classof(const SymExpr *SE)
static void Profile(llvm::FoldingSetNodeID &profile, const Stmt *S, QualType T, unsigned Count, const LocationContext *LCtx, const void *SymbolTag)
const SymIntExpr * getSymIntExpr(const SymExpr &lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
Expr - This represents one expression.
Definition: Expr.h:106
const TypedValueRegion * getRegion() const
const FunctionProtoType * T
void Profile(llvm::FoldingSetNodeID &profile) override
const SubRegion * getRegion() const
Represents a cast expression.
const LocationContext * getLocationContext() const
QualType getType() const
Definition: Expr.h:128
static void Profile(llvm::FoldingSetNodeID &profile, const MemRegion *R, const Stmt *S, QualType T, const LocationContext *LCtx, unsigned Count, const void *Tag)
static bool classof(const SymExpr *SE)
IntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
const SymExpr * getRHS() const
static bool classof(const SymExpr *SE)
Definition: SymbolManager.h:69
virtual bool VisitMemRegion(const MemRegion *region)
const TypedValueRegion * getRegion() const
Definition: SymbolManager.h:52
const SymExpr * getLHS() const
const void * getTag() const
Definition: SymbolManager.h:99
Represents a symbolic expression like 3 - &#39;x&#39;.
const SymbolConjured * conjureSymbol(const Expr *E, const LocationContext *LCtx, unsigned VisitCount, const void *SymbolTag=nullptr)
void dumpToStream(raw_ostream &os) const override
QualType getType() const override
const llvm::APSInt & getLHS() const
A class responsible for cleaning up unused symbols.
SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
region_iterator region_end() const
QualType getType() const override
A symbol representing the result of an expression in the case when we do not know anything about what...
Definition: SymbolManager.h:76
static bool isValidTypeForSymbol(QualType T)
Definition: SymExpr.h:46
SymbolSetTy::const_iterator dead_iterator
A symbol representing the value stored at a MemRegion.
Definition: SymbolManager.h:42
Dataflow Directional Tag Classes.
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *In, QualType From, QualType To)
SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
Definition: SymbolManager.h:46
Represents a symbolic expression involving a binary operator.
const llvm::APSInt & getRHS() const
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
region_iterator region_begin() const
const MemRegion * getOriginRegion() const override
Find the region from which this symbol originates.
const Stmt * getStmt() const
QualType getType() const override
static bool classof(const SymExpr *SE)
SymbolMetadata(SymbolID sym, const MemRegion *r, const Stmt *s, QualType t, const LocationContext *LCtx, unsigned count, const void *tag)
void Profile(llvm::FoldingSetNodeID &ID) override
dead_iterator dead_begin() const
const SymExpr * getRHS() const
SymbolVisitor(SymbolVisitor &&)
static bool classof(const SymExpr *SE)
SubRegion - A region that subsets another larger region.
Definition: MemRegion.h:431
void Profile(llvm::FoldingSetNodeID &ID) override
const Stmt * getStmt() const
Definition: SymbolManager.h:97
SymbolMetadata - Represents path-dependent metadata about a specific region.
dead_iterator dead_end() const
static void Profile(llvm::FoldingSetNodeID &profile, const SubRegion *R)
Kind getKind() const
Definition: SymExpr.h:55
unsigned SymbolID
Definition: SymExpr.h:111
const MemRegion * getOriginRegion() const override
Find the region from which this symbol originates.
Definition: SymbolManager.h:64
BinaryOperator::Opcode getOpcode() const
SymbolRef getParentSymbol() const
SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
void Profile(llvm::FoldingSetNodeID &profile) override
Definition: SymbolManager.h:59
static bool classof(const SymExpr *SE)
static bool classof(const SymExpr *SE)
BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t)
SymbolExtent - Represents the extent (size in bytes) of a bounded region.
void Profile(llvm::FoldingSetNodeID &profile) override
void Profile(llvm::FoldingSetNodeID &ID) override
Represents a symbolic expression like &#39;x&#39; + &#39;y&#39;.
A symbol representing data which can be stored in a memory location (region).
Definition: SymExpr.h:115
const SymExpr * getLHS() const
static void Profile(llvm::FoldingSetNodeID &ID, const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)