clang  14.0.0git
ProgramState.h
Go to the documentation of this file.
1 //== ProgramState.h - Path-sensitive "State" for tracking values -*- C++ -*--=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the state of the program along the analysisa path.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATE_H
14 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATE_H
15 
16 #include "clang/Basic/LLVM.h"
23 #include "llvm/ADT/FoldingSet.h"
24 #include "llvm/ADT/ImmutableMap.h"
25 #include "llvm/Support/Allocator.h"
26 #include <utility>
27 
28 namespace llvm {
29 class APSInt;
30 }
31 
32 namespace clang {
33 class ASTContext;
34 
35 namespace ento {
36 
37 class AnalysisManager;
38 class CallEvent;
39 class CallEventManager;
40 
41 typedef std::unique_ptr<ConstraintManager>(*ConstraintManagerCreator)(
43 typedef std::unique_ptr<StoreManager>(*StoreManagerCreator)(
45 
46 //===----------------------------------------------------------------------===//
47 // ProgramStateTrait - Traits used by the Generic Data Map of a ProgramState.
48 //===----------------------------------------------------------------------===//
49 
50 template <typename T> struct ProgramStateTrait {
51  typedef typename T::data_type data_type;
52  static inline void *MakeVoidPtr(data_type D) { return (void*) D; }
53  static inline data_type MakeData(void *const* P) {
54  return P ? (data_type) *P : (data_type) 0;
55  }
56 };
57 
58 /// \class ProgramState
59 /// ProgramState - This class encapsulates:
60 ///
61 /// 1. A mapping from expressions to values (Environment)
62 /// 2. A mapping from locations to values (Store)
63 /// 3. Constraints on symbolic values (GenericDataMap)
64 ///
65 /// Together these represent the "abstract state" of a program.
66 ///
67 /// ProgramState is intended to be used as a functional object; that is,
68 /// once it is created and made "persistent" in a FoldingSet, its
69 /// values will never change.
70 class ProgramState : public llvm::FoldingSetNode {
71 public:
72  typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
73  typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
74 
75 private:
76  void operator=(const ProgramState& R) = delete;
77 
78  friend class ProgramStateManager;
79  friend class ExplodedGraph;
80  friend class ExplodedNode;
81 
82  ProgramStateManager *stateMgr;
83  Environment Env; // Maps a Stmt to its current SVal.
84  Store store; // Maps a location to its current value.
85  GenericDataMap GDM; // Custom data stored by a client of this class.
86  unsigned refCount;
87 
88  /// makeWithStore - Return a ProgramState with the same values as the current
89  /// state with the exception of using the specified Store.
90  ProgramStateRef makeWithStore(const StoreRef &store) const;
91 
92  void setStore(const StoreRef &storeRef);
93 
94 public:
95  /// This ctor is used when creating the first ProgramState object.
97  StoreRef st, GenericDataMap gdm);
98 
99  /// Copy ctor - We must explicitly define this or else the "Next" ptr
100  /// in FoldingSetNode will also get copied.
101  ProgramState(const ProgramState &RHS);
102 
103  ~ProgramState();
104 
105  int64_t getID() const;
106 
107  /// Return the ProgramStateManager associated with this state.
109  return *stateMgr;
110  }
111 
113 
114  /// Return the ConstraintManager.
116 
117  /// getEnvironment - Return the environment associated with this state.
118  /// The environment is the mapping from expressions to values.
119  const Environment& getEnvironment() const { return Env; }
120 
121  /// Return the store associated with this state. The store
122  /// is a mapping from locations to values.
123  Store getStore() const { return store; }
124 
125 
126  /// getGDM - Return the generic data map associated with this state.
127  GenericDataMap getGDM() const { return GDM; }
128 
129  void setGDM(GenericDataMap gdm) { GDM = gdm; }
130 
131  /// Profile - Profile the contents of a ProgramState object for use in a
132  /// FoldingSet. Two ProgramState objects are considered equal if they
133  /// have the same Environment, Store, and GenericDataMap.
134  static void Profile(llvm::FoldingSetNodeID& ID, const ProgramState *V) {
135  V->Env.Profile(ID);
136  ID.AddPointer(V->store);
137  V->GDM.Profile(ID);
138  }
139 
140  /// Profile - Used to profile the contents of this object for inclusion
141  /// in a FoldingSet.
142  void Profile(llvm::FoldingSetNodeID& ID) const {
143  Profile(ID, this);
144  }
145 
148 
149  //==---------------------------------------------------------------------==//
150  // Constraints on values.
151  //==---------------------------------------------------------------------==//
152  //
153  // Each ProgramState records constraints on symbolic values. These constraints
154  // are managed using the ConstraintManager associated with a ProgramStateManager.
155  // As constraints gradually accrue on symbolic values, added constraints
156  // may conflict and indicate that a state is infeasible (as no real values
157  // could satisfy all the constraints). This is the principal mechanism
158  // for modeling path-sensitivity in ExprEngine/ProgramState.
159  //
160  // Various "assume" methods form the interface for adding constraints to
161  // symbolic values. A call to 'assume' indicates an assumption being placed
162  // on one or symbolic values. 'assume' methods take the following inputs:
163  //
164  // (1) A ProgramState object representing the current state.
165  //
166  // (2) The assumed constraint (which is specific to a given "assume" method).
167  //
168  // (3) A binary value "Assumption" that indicates whether the constraint is
169  // assumed to be true or false.
170  //
171  // The output of "assume*" is a new ProgramState object with the added constraints.
172  // If no new state is feasible, NULL is returned.
173  //
174 
175  /// Assumes that the value of \p cond is zero (if \p assumption is "false")
176  /// or non-zero (if \p assumption is "true").
177  ///
178  /// This returns a new state with the added constraint on \p cond.
179  /// If no new state is feasible, NULL is returned.
180  LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
181  bool assumption) const;
182 
183  /// Assumes both "true" and "false" for \p cond, and returns both
184  /// corresponding states (respectively).
185  ///
186  /// This is more efficient than calling assume() twice. Note that one (but not
187  /// both) of the returned states may be NULL.
188  LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
189  assume(DefinedOrUnknownSVal cond) const;
190 
191  LLVM_NODISCARD ProgramStateRef
193  bool assumption, QualType IndexType = QualType()) const;
194 
195  /// Assumes that the value of \p Val is bounded with [\p From; \p To]
196  /// (if \p assumption is "true") or it is fully out of this range
197  /// (if \p assumption is "false").
198  ///
199  /// This returns a new state with the added constraint on \p cond.
200  /// If no new state is feasible, NULL is returned.
202  const llvm::APSInt &From,
203  const llvm::APSInt &To,
204  bool assumption) const;
205 
206  /// Assumes given range both "true" and "false" for \p Val, and returns both
207  /// corresponding states (respectively).
208  ///
209  /// This is more efficient than calling assume() twice. Note that one (but not
210  /// both) of the returned states may be NULL.
211  LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
213  const llvm::APSInt &To) const;
214 
215  /// Check if the given SVal is not constrained to zero and is not
216  /// a zero constant.
218 
219  /// Check if the given SVal is constrained to zero or is a zero
220  /// constant.
222 
223  /// \return Whether values \p Lhs and \p Rhs are equal.
224  ConditionTruthVal areEqual(SVal Lhs, SVal Rhs) const;
225 
226  /// Utility method for getting regions.
227  const VarRegion* getRegion(const VarDecl *D, const LocationContext *LC) const;
228 
229  //==---------------------------------------------------------------------==//
230  // Binding and retrieving values to/from the environment and symbolic store.
231  //==---------------------------------------------------------------------==//
232 
233  /// Create a new state by binding the value 'V' to the statement 'S' in the
234  /// state's environment.
235  LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
236  const LocationContext *LCtx, SVal V,
237  bool Invalidate = true) const;
238 
239  LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
240  const LocationContext *LCtx,
241  bool notifyChanges = true) const;
242 
243  LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
244  const LocationContext *LCtx) const;
245 
246  /// Initializes the region of memory represented by \p loc with an initial
247  /// value. Once initialized, all values loaded from any sub-regions of that
248  /// region will be equal to \p V, unless overwritten later by the program.
249  /// This method should not be used on regions that are already initialized.
250  /// If you need to indicate that memory contents have suddenly become unknown
251  /// within a certain region of memory, consider invalidateRegions().
252  LLVM_NODISCARD ProgramStateRef
253  bindDefaultInitial(SVal loc, SVal V, const LocationContext *LCtx) const;
254 
255  /// Performs C++ zero-initialization procedure on the region of memory
256  /// represented by \p loc.
257  LLVM_NODISCARD ProgramStateRef
258  bindDefaultZero(SVal loc, const LocationContext *LCtx) const;
259 
260  LLVM_NODISCARD ProgramStateRef killBinding(Loc LV) const;
261 
262  /// Returns the state with bindings for the given regions
263  /// cleared from the store.
264  ///
265  /// Optionally invalidates global regions as well.
266  ///
267  /// \param Regions the set of regions to be invalidated.
268  /// \param E the expression that caused the invalidation.
269  /// \param BlockCount The number of times the current basic block has been
270  // visited.
271  /// \param CausesPointerEscape the flag is set to true when
272  /// the invalidation entails escape of a symbol (representing a
273  /// pointer). For example, due to it being passed as an argument in a
274  /// call.
275  /// \param IS the set of invalidated symbols.
276  /// \param Call if non-null, the invalidated regions represent parameters to
277  /// the call and should be considered directly invalidated.
278  /// \param ITraits information about special handling for a particular
279  /// region/symbol.
280  LLVM_NODISCARD ProgramStateRef
282  unsigned BlockCount, const LocationContext *LCtx,
283  bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
284  const CallEvent *Call = nullptr,
285  RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
286 
287  LLVM_NODISCARD ProgramStateRef
288  invalidateRegions(ArrayRef<SVal> Regions, const Expr *E,
289  unsigned BlockCount, const LocationContext *LCtx,
290  bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
291  const CallEvent *Call = nullptr,
292  RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
293 
294  /// enterStackFrame - Returns the state for entry to the given stack frame,
295  /// preserving the current state.
296  LLVM_NODISCARD ProgramStateRef enterStackFrame(
297  const CallEvent &Call, const StackFrameContext *CalleeCtx) const;
298 
299  /// Return the value of 'self' if available in the given context.
300  SVal getSelfSVal(const LocationContext *LC) const;
301 
302  /// Get the lvalue for a base class object reference.
303  Loc getLValue(const CXXBaseSpecifier &BaseSpec, const SubRegion *Super) const;
304 
305  /// Get the lvalue for a base class object reference.
306  Loc getLValue(const CXXRecordDecl *BaseClass, const SubRegion *Super,
307  bool IsVirtual) const;
308 
309  /// Get the lvalue for a parameter.
310  Loc getLValue(const Expr *Call, unsigned Index,
311  const LocationContext *LC) const;
312 
313  /// Get the lvalue for a variable reference.
314  Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
315 
316  Loc getLValue(const CompoundLiteralExpr *literal,
317  const LocationContext *LC) const;
318 
319  /// Get the lvalue for an ivar reference.
320  SVal getLValue(const ObjCIvarDecl *decl, SVal base) const;
321 
322  /// Get the lvalue for a field reference.
323  SVal getLValue(const FieldDecl *decl, SVal Base) const;
324 
325  /// Get the lvalue for an indirect field reference.
326  SVal getLValue(const IndirectFieldDecl *decl, SVal Base) const;
327 
328  /// Get the lvalue for an array index.
329  SVal getLValue(QualType ElementType, SVal Idx, SVal Base) const;
330 
331  /// Returns the SVal bound to the statement 'S' in the state's environment.
332  SVal getSVal(const Stmt *S, const LocationContext *LCtx) const;
333 
334  SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const;
335 
336  /// Return the value bound to the specified location.
337  /// Returns UnknownVal() if none found.
338  SVal getSVal(Loc LV, QualType T = QualType()) const;
339 
340  /// Returns the "raw" SVal bound to LV before any value simplfication.
341  SVal getRawSVal(Loc LV, QualType T= QualType()) const;
342 
343  /// Return the value bound to the specified location.
344  /// Returns UnknownVal() if none found.
345  SVal getSVal(const MemRegion* R, QualType T = QualType()) const;
346 
347  /// Return the value bound to the specified location, assuming
348  /// that the value is a scalar integer or an enumeration or a pointer.
349  /// Returns UnknownVal() if none found or the region is not known to hold
350  /// a value of such type.
351  SVal getSValAsScalarOrLoc(const MemRegion *R) const;
352 
353  using region_iterator = const MemRegion **;
354 
355  /// Visits the symbols reachable from the given SVal using the provided
356  /// SymbolVisitor.
357  ///
358  /// This is a convenience API. Consider using ScanReachableSymbols class
359  /// directly when making multiple scans on the same state with the same
360  /// visitor to avoid repeated initialization cost.
361  /// \sa ScanReachableSymbols
362  bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const;
363 
364  /// Visits the symbols reachable from the regions in the given
365  /// MemRegions range using the provided SymbolVisitor.
366  bool scanReachableSymbols(llvm::iterator_range<region_iterator> Reachable,
367  SymbolVisitor &visitor) const;
368 
369  template <typename CB> CB scanReachableSymbols(SVal val) const;
370  template <typename CB> CB
371  scanReachableSymbols(llvm::iterator_range<region_iterator> Reachable) const;
372 
373  //==---------------------------------------------------------------------==//
374  // Accessing the Generic Data Map (GDM).
375  //==---------------------------------------------------------------------==//
376 
377  void *const* FindGDM(void *K) const;
378 
379  template <typename T>
380  LLVM_NODISCARD ProgramStateRef
381  add(typename ProgramStateTrait<T>::key_type K) const;
382 
383  template <typename T>
385  get() const {
387  }
388 
389  template<typename T>
391  get(typename ProgramStateTrait<T>::key_type key) const {
392  void *const* d = FindGDM(ProgramStateTrait<T>::GDMIndex());
394  }
395 
396  template <typename T>
398 
399  template <typename T>
400  LLVM_NODISCARD ProgramStateRef
401  remove(typename ProgramStateTrait<T>::key_type K) const;
402 
403  template <typename T>
404  LLVM_NODISCARD ProgramStateRef
406  typename ProgramStateTrait<T>::context_type C) const;
407 
408  template <typename T> LLVM_NODISCARD ProgramStateRef remove() const;
409 
410  template <typename T>
411  LLVM_NODISCARD ProgramStateRef
412  set(typename ProgramStateTrait<T>::data_type D) const;
413 
414  template <typename T>
415  LLVM_NODISCARD ProgramStateRef
417  typename ProgramStateTrait<T>::value_type E) const;
418 
419  template <typename T>
420  LLVM_NODISCARD ProgramStateRef
423  typename ProgramStateTrait<T>::context_type C) const;
424 
425  template<typename T>
426  bool contains(typename ProgramStateTrait<T>::key_type key) const {
427  void *const* d = FindGDM(ProgramStateTrait<T>::GDMIndex());
429  }
430 
431  // Pretty-printing.
432  void printJson(raw_ostream &Out, const LocationContext *LCtx = nullptr,
433  const char *NL = "\n", unsigned int Space = 0,
434  bool IsDot = false) const;
435 
436  void printDOT(raw_ostream &Out, const LocationContext *LCtx = nullptr,
437  unsigned int Space = 0) const;
438 
439  void dump() const;
440 
441 private:
442  friend void ProgramStateRetain(const ProgramState *state);
443  friend void ProgramStateRelease(const ProgramState *state);
444 
445  /// \sa invalidateValues()
446  /// \sa invalidateRegions()
448  invalidateRegionsImpl(ArrayRef<SVal> Values,
449  const Expr *E, unsigned BlockCount,
450  const LocationContext *LCtx,
451  bool ResultsInSymbolEscape,
452  InvalidatedSymbols *IS,
454  const CallEvent *Call) const;
455 };
456 
457 //===----------------------------------------------------------------------===//
458 // ProgramStateManager - Factory object for ProgramStates.
459 //===----------------------------------------------------------------------===//
460 
462  friend class ProgramState;
463  friend void ProgramStateRelease(const ProgramState *state);
464 private:
465  /// Eng - The ExprEngine that owns this state manager.
466  ExprEngine *Eng; /* Can be null. */
467 
468  EnvironmentManager EnvMgr;
469  std::unique_ptr<StoreManager> StoreMgr;
470  std::unique_ptr<ConstraintManager> ConstraintMgr;
471 
472  ProgramState::GenericDataMap::Factory GDMFactory;
473 
474  typedef llvm::DenseMap<void*,std::pair<void*,void (*)(void*)> > GDMContextsTy;
475  GDMContextsTy GDMContexts;
476 
477  /// StateSet - FoldingSet containing all the states created for analyzing
478  /// a particular function. This is used to unique states.
479  llvm::FoldingSet<ProgramState> StateSet;
480 
481  /// Object that manages the data for all created SVals.
482  std::unique_ptr<SValBuilder> svalBuilder;
483 
484  /// Manages memory for created CallEvents.
485  std::unique_ptr<CallEventManager> CallEventMgr;
486 
487  /// A BumpPtrAllocator to allocate states.
488  llvm::BumpPtrAllocator &Alloc;
489 
490  /// A vector of ProgramStates that we can reuse.
491  std::vector<ProgramState *> freeStates;
492 
493 public:
495  StoreManagerCreator CreateStoreManager,
496  ConstraintManagerCreator CreateConstraintManager,
497  llvm::BumpPtrAllocator& alloc,
498  ExprEngine *expreng);
499 
501 
503 
504  ASTContext &getContext() { return svalBuilder->getContext(); }
505  const ASTContext &getContext() const { return svalBuilder->getContext(); }
506 
508  return svalBuilder->getBasicValueFactory();
509  }
510 
512  return *svalBuilder;
513  }
514 
515  const SValBuilder &getSValBuilder() const {
516  return *svalBuilder;
517  }
518 
520  return svalBuilder->getSymbolManager();
521  }
523  return svalBuilder->getSymbolManager();
524  }
525 
526  llvm::BumpPtrAllocator& getAllocator() { return Alloc; }
527 
529  return svalBuilder->getRegionManager();
530  }
532  return svalBuilder->getRegionManager();
533  }
534 
535  CallEventManager &getCallEventManager() { return *CallEventMgr; }
536 
537  StoreManager &getStoreManager() { return *StoreMgr; }
538  ConstraintManager &getConstraintManager() { return *ConstraintMgr; }
539  ExprEngine &getOwningEngine() { return *Eng; }
540 
543  const StackFrameContext *LCtx,
544  SymbolReaper &SymReaper);
545 
546 public:
547 
548  SVal ArrayToPointer(Loc Array, QualType ElementTy) {
549  return StoreMgr->ArrayToPointer(Array, ElementTy);
550  }
551 
552  // Methods that manipulate the GDM.
553  ProgramStateRef addGDM(ProgramStateRef St, void *Key, void *Data);
555 
556  // Methods that query & manipulate the Store.
557 
559  StoreMgr->iterBindings(state->getStore(), F);
560  }
561 
564  ProgramStateRef GDMState);
565 
567  return ConstraintMgr->haveEqualConstraints(S1, S2);
568  }
569 
571  return S1->Env == S2->Env;
572  }
573 
575  return S1->store == S2->store;
576  }
577 
578  //==---------------------------------------------------------------------==//
579  // Generic Data Map methods.
580  //==---------------------------------------------------------------------==//
581  //
582  // ProgramStateManager and ProgramState support a "generic data map" that allows
583  // different clients of ProgramState objects to embed arbitrary data within a
584  // ProgramState object. The generic data map is essentially an immutable map
585  // from a "tag" (that acts as the "key" for a client) and opaque values.
586  // Tags/keys and values are simply void* values. The typical way that clients
587  // generate unique tags are by taking the address of a static variable.
588  // Clients are responsible for ensuring that data values referred to by a
589  // the data pointer are immutable (and thus are essentially purely functional
590  // data).
591  //
592  // The templated methods below use the ProgramStateTrait<T> class
593  // to resolve keys into the GDM and to return data values to clients.
594  //
595 
596  // Trait based GDM dispatch.
597  template <typename T>
601  }
602 
603  template<typename T>
608 
611  }
612 
613  template <typename T>
619  }
620 
621  template <typename T>
625 
628  }
629 
630  template <typename T>
633  }
634 
635  void *FindGDMContext(void *index,
636  void *(*CreateContext)(llvm::BumpPtrAllocator&),
637  void (*DeleteContext)(void*));
638 
639  template <typename T>
644 
646  }
647 };
648 
649 
650 //===----------------------------------------------------------------------===//
651 // Out-of-line method definitions for ProgramState.
652 //===----------------------------------------------------------------------===//
653 
655  return stateMgr->getConstraintManager();
656 }
657 
659  const LocationContext *LC) const
660 {
662 }
663 
665  bool Assumption) const {
666  if (Cond.isUnknown())
667  return this;
668 
669  return getStateManager().ConstraintMgr
670  ->assume(this, Cond.castAs<DefinedSVal>(), Assumption);
671 }
672 
673 inline std::pair<ProgramStateRef , ProgramStateRef >
675  if (Cond.isUnknown())
676  return std::make_pair(this, this);
677 
678  return getStateManager().ConstraintMgr
679  ->assumeDual(this, Cond.castAs<DefinedSVal>());
680 }
681 
683  DefinedOrUnknownSVal Val, const llvm::APSInt &From, const llvm::APSInt &To,
684  bool Assumption) const {
685  if (Val.isUnknown())
686  return this;
687 
688  assert(Val.getAs<NonLoc>() && "Only NonLocs are supported!");
689 
690  return getStateManager().ConstraintMgr->assumeInclusiveRange(
691  this, Val.castAs<NonLoc>(), From, To, Assumption);
692 }
693 
694 inline std::pair<ProgramStateRef, ProgramStateRef>
696  const llvm::APSInt &From,
697  const llvm::APSInt &To) const {
698  if (Val.isUnknown())
699  return std::make_pair(this, this);
700 
701  assert(Val.getAs<NonLoc>() && "Only NonLocs are supported!");
702 
703  return getStateManager().ConstraintMgr->assumeInclusiveRangeDual(
704  this, Val.castAs<NonLoc>(), From, To);
705 }
706 
708  if (Optional<Loc> L = LV.getAs<Loc>())
709  return bindLoc(*L, V, LCtx);
710  return this;
711 }
712 
714  const SubRegion *Super) const {
715  const auto *Base = BaseSpec.getType()->getAsCXXRecordDecl();
716  return loc::MemRegionVal(
717  getStateManager().getRegionManager().getCXXBaseObjectRegion(
718  Base, Super, BaseSpec.isVirtual()));
719 }
720 
721 inline Loc ProgramState::getLValue(const CXXRecordDecl *BaseClass,
722  const SubRegion *Super,
723  bool IsVirtual) const {
724  return loc::MemRegionVal(
725  getStateManager().getRegionManager().getCXXBaseObjectRegion(
726  BaseClass, Super, IsVirtual));
727 }
728 
730  const LocationContext *LC) const {
731  return getStateManager().StoreMgr->getLValueVar(VD, LC);
732 }
733 
735  const LocationContext *LC) const {
736  return getStateManager().StoreMgr->getLValueCompoundLiteral(literal, LC);
737 }
738 
740  return getStateManager().StoreMgr->getLValueIvar(D, Base);
741 }
742 
743 inline SVal ProgramState::getLValue(const FieldDecl *D, SVal Base) const {
744  return getStateManager().StoreMgr->getLValueField(D, Base);
745 }
746 
748  SVal Base) const {
749  StoreManager &SM = *getStateManager().StoreMgr;
750  for (const auto *I : D->chain()) {
751  Base = SM.getLValueField(cast<FieldDecl>(I), Base);
752  }
753 
754  return Base;
755 }
756 
757 inline SVal ProgramState::getLValue(QualType ElementType, SVal Idx, SVal Base) const{
758  if (Optional<NonLoc> N = Idx.getAs<NonLoc>())
759  return getStateManager().StoreMgr->getLValueElement(ElementType, *N, Base);
760  return UnknownVal();
761 }
762 
763 inline SVal ProgramState::getSVal(const Stmt *Ex,
764  const LocationContext *LCtx) const{
765  return Env.getSVal(EnvironmentEntry(Ex, LCtx),
766  *getStateManager().svalBuilder);
767 }
768 
769 inline SVal
771  const LocationContext *LCtx) const {
772  if (const Expr *Ex = dyn_cast<Expr>(S)) {
773  QualType T = Ex->getType();
774  if (Ex->isGLValue() || Loc::isLocType(T) ||
776  return getSVal(S, LCtx);
777  }
778 
779  return UnknownVal();
780 }
781 
783  return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
784 }
785 
786 inline SVal ProgramState::getSVal(const MemRegion* R, QualType T) const {
787  return getStateManager().StoreMgr->getBinding(getStore(),
789  T);
790 }
791 
793  return getStateManager().getBasicVals();
794 }
795 
798 }
799 
800 template<typename T>
802  return getStateManager().add<T>(this, K, get_context<T>());
803 }
804 
805 template <typename T>
807  return getStateManager().get_context<T>();
808 }
809 
810 template<typename T>
812  return getStateManager().remove<T>(this, K, get_context<T>());
813 }
814 
815 template<typename T>
817  typename ProgramStateTrait<T>::context_type C) const {
818  return getStateManager().remove<T>(this, K, C);
819 }
820 
821 template <typename T>
823  return getStateManager().remove<T>(this);
824 }
825 
826 template<typename T>
828  return getStateManager().set<T>(this, D);
829 }
830 
831 template<typename T>
833  typename ProgramStateTrait<T>::value_type E) const {
834  return getStateManager().set<T>(this, K, E, get_context<T>());
835 }
836 
837 template<typename T>
840  typename ProgramStateTrait<T>::context_type C) const {
841  return getStateManager().set<T>(this, K, E, C);
842 }
843 
844 template <typename CB>
846  CB cb(this);
847  scanReachableSymbols(val, cb);
848  return cb;
849 }
850 
851 template <typename CB>
853  llvm::iterator_range<region_iterator> Reachable) const {
854  CB cb(this);
855  scanReachableSymbols(Reachable, cb);
856  return cb;
857 }
858 
859 /// \class ScanReachableSymbols
860 /// A utility class that visits the reachable symbols using a custom
861 /// SymbolVisitor. Terminates recursive traversal when the visitor function
862 /// returns false.
865 
866  VisitedItems visited;
867  ProgramStateRef state;
868  SymbolVisitor &visitor;
869 public:
871  : state(std::move(st)), visitor(v) {}
872 
873  bool scan(nonloc::LazyCompoundVal val);
874  bool scan(nonloc::CompoundVal val);
875  bool scan(SVal val);
876  bool scan(const MemRegion *R);
877  bool scan(const SymExpr *sym);
878 };
879 
880 } // end ento namespace
881 
882 } // end clang namespace
883 
884 #endif
clang::ento::ProgramState::scanReachableSymbols
bool scanReachableSymbols(SVal val, SymbolVisitor &visitor) const
Visits the symbols reachable from the given SVal using the provided SymbolVisitor.
Definition: ProgramState.cpp:630
clang::ento::ProgramStateManager::haveEqualConstraints
bool haveEqualConstraints(ProgramStateRef S1, ProgramStateRef S2) const
Definition: ProgramState.h:566
clang::ento::ProgramStateManager::getOwningEngine
ExprEngine & getOwningEngine()
Definition: ProgramState.h:539
clang::ento::Loc::isLocType
static bool isLocType(QualType T)
Definition: SVals.h:335
clang::ento::ProgramState::killBinding
LLVM_NODISCARD ProgramStateRef killBinding(Loc LV) const
Definition: ProgramState.cpp:218
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::CXXBaseSpecifier::getType
QualType getType() const
Retrieves the type of the base class.
Definition: DeclCXX.h:245
clang::ento::ProgramStateManager::remove
ProgramStateRef remove(ProgramStateRef st, typename ProgramStateTrait< T >::key_type K, typename ProgramStateTrait< T >::context_type C)
Definition: ProgramState.h:622
clang::ento::ProgramState::assumeInBound
LLVM_NODISCARD ProgramStateRef assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound, bool assumption, QualType IndexType=QualType()) const
Definition: ProgramState.cpp:317
clang::ento::SymbolVisitor
Definition: SymbolManager.h:586
ConstraintManager.h
clang::ento::ProgramStateManager::ProgramStateManager
ProgramStateManager(ASTContext &Ctx, StoreManagerCreator CreateStoreManager, ConstraintManagerCreator CreateConstraintManager, llvm::BumpPtrAllocator &alloc, ExprEngine *expreng)
Definition: ProgramState.cpp:71
clang::ento::BasicValueFactory
Definition: BasicValueFactory.h:107
clang::LocationContext
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Definition: AnalysisDeclContext.h:215
clang::ento::nonloc::CompoundVal
Definition: SVals.h:463
clang::ento::ProgramState::get_context
ProgramStateTrait< T >::context_type get_context() const
Definition: ProgramState.h:806
clang::ento::SVal::castAs
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition: SVals.h:102
clang::ento::NonLoc
Definition: SVals.h:304
clang::ento::ProgramState::getSelfSVal
SVal getSelfSVal(const LocationContext *LC) const
Return the value of 'self' if available in the given context.
Definition: ProgramState.cpp:239
clang::ento::ConstraintManager
Definition: ConstraintManager.h:77
clang::ento::StoreManagerCreator
std::unique_ptr< StoreManager >(* StoreManagerCreator)(ProgramStateManager &)
Definition: ProgramState.h:43
clang::ento::DefinedOrUnknownSVal
Definition: SVals.h:235
clang::ento::ProgramState::getGDM
GenericDataMap getGDM() const
getGDM - Return the generic data map associated with this state.
Definition: ProgramState.h:127
clang::ento::ProgramStateManager::getSValBuilder
SValBuilder & getSValBuilder()
Definition: ProgramState.h:511
clang::ento::ProgramState::Profile
static void Profile(llvm::FoldingSetNodeID &ID, const ProgramState *V)
Profile - Profile the contents of a ProgramState object for use in a FoldingSet.
Definition: ProgramState.h:134
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:674
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2838
clang::ento::ProgramState::getEnvironment
const Environment & getEnvironment() const
getEnvironment - Return the environment associated with this state.
Definition: ProgramState.h:119
clang::ento::ExplodedNode
Definition: ExplodedGraph.h:65
ProgramState_Fwd.h
clang::ento::ProgramState::set
LLVM_NODISCARD ProgramStateRef set(typename ProgramStateTrait< T >::data_type D) const
clang::ento::ProgramState::GenericDataMap
llvm::ImmutableMap< void *, void * > GenericDataMap
Definition: ProgramState.h:73
llvm::Optional
Definition: LLVM.h:40
clang::StackFrameContext
It represents a stack frame of the call stack (based on CallEvent).
Definition: AnalysisDeclContext.h:295
clang::ento::UnknownVal
Definition: SVals.h:256
clang::ento::ProgramState::setGDM
void setGDM(GenericDataMap gdm)
Definition: ProgramState.h:129
clang::ento::loc::MemRegionVal
Definition: SVals.h:605
clang::ento::Store
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
Definition: StoreRef.h:27
clang::ento::ProgramState
Definition: ProgramState.h:70
clang::ento::MemRegionManager::getVarRegion
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
Definition: MemRegion.cpp:946
clang::ento::ProgramStateManager::getAllocator
llvm::BumpPtrAllocator & getAllocator()
Definition: ProgramState.h:526
clang::ento::StoreManager
Definition: Store.h:53
clang::ento::ProgramStateManager::add
ProgramStateRef add(ProgramStateRef st, typename ProgramStateTrait< T >::key_type K, typename ProgramStateTrait< T >::context_type C)
Definition: ProgramState.h:614
clang::ento::ProgramState::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Profile - Used to profile the contents of this object for inclusion in a FoldingSet.
Definition: ProgramState.h:142
clang::ento::SVal::getAs
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type.
Definition: SVals.h:110
clang::ento::ProgramStateManager::addGDM
ProgramStateRef addGDM(ProgramStateRef St, void *Key, void *Data)
Definition: ProgramState.cpp:507
clang::ento::EnvironmentManager
Definition: Environment.h:99
clang::ento::ProgramState::bindLoc
LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V, const LocationContext *LCtx, bool notifyChanges=true) const
clang::ento::MemRegion
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:94
clang::ento::ConditionTruthVal
Definition: ConstraintManager.h:38
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:19
clang::ento::ProgramState::~ProgramState
~ProgramState()
Definition: ProgramState.cpp:62
clang::ento::ProgramStateManager::getPersistentStateWithGDM
ProgramStateRef getPersistentStateWithGDM(ProgramStateRef FromState, ProgramStateRef GDMState)
Definition: ProgramState.cpp:396
DynamicTypeInfo.h
V
#define V(N, I)
Definition: ASTContext.h:3127
clang::ento::DefinedSVal
Definition: SVals.h:268
clang::ento::ProgramState::enterStackFrame
LLVM_NODISCARD ProgramStateRef enterStackFrame(const CallEvent &Call, const StackFrameContext *CalleeCtx) const
enterStackFrame - Returns the state for entry to the given stack frame, preserving the current state.
Definition: ProgramState.cpp:232
clang::ento::ProgramStateManager::getContext
ASTContext & getContext()
Definition: ProgramState.h:504
clang::ento::ProgramStateManager::getSymbolManager
SymbolManager & getSymbolManager()
Definition: ProgramState.h:519
clang::ento::ProgramState::getLValue
Loc getLValue(const CXXBaseSpecifier &BaseSpec, const SubRegion *Super) const
Get the lvalue for a base class object reference.
Definition: ProgramState.h:713
clang::ento::ProgramStateManager::set
ProgramStateRef set(ProgramStateRef st, typename ProgramStateTrait< T >::data_type D)
Definition: ProgramState.h:598
clang::ento::ProgramStateManager::removeDeadBindingsFromEnvironmentAndStore
ProgramStateRef removeDeadBindingsFromEnvironmentAndStore(ProgramStateRef St, const StackFrameContext *LCtx, SymbolReaper &SymReaper)
Definition: ProgramState.cpp:90
clang::ento::ProgramState::getID
int64_t getID() const
Definition: ProgramState.cpp:67
clang::ento::ProgramStateManager::ArrayToPointer
SVal ArrayToPointer(Loc Array, QualType ElementTy)
Definition: ProgramState.h:548
clang::ento::ProgramState::IntSetTy
llvm::ImmutableSet< llvm::APSInt * > IntSetTy
Definition: ProgramState.h:72
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::ento::ProgramState::remove
LLVM_NODISCARD ProgramStateRef remove() const
clang::ento::SymExpr
Symbolic value.
Definition: SymExpr.h:29
clang::ento::StoreRef
Definition: StoreRef.h:29
Store.h
clang::ento::ProgramState::isNonNull
ConditionTruthVal isNonNull(SVal V) const
Check if the given SVal is not constrained to zero and is not a zero constant.
Definition: ProgramState.cpp:362
clang::ento::ProgramState::add
LLVM_NODISCARD ProgramStateRef add(typename ProgramStateTrait< T >::key_type K) const
clang::ento::ProgramStateTrait
Definition: ProgramState.h:50
clang::ento::ProgramState::getStore
Store getStore() const
Return the store associated with this state.
Definition: ProgramState.h:123
clang::ento::ProgramState::getAnalysisManager
AnalysisManager & getAnalysisManager() const
Definition: ProgramState.cpp:481
clang::ento::ProgramState::printJson
void printJson(raw_ostream &Out, const LocationContext *LCtx=nullptr, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
Definition: ProgramState.cpp:445
clang::ento::VarRegion
Definition: MemRegion.h:906
clang::CXXBaseSpecifier::isVirtual
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition: DeclCXX.h:199
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::ento::ProgramStateManager::removeGDM
ProgramStateRef removeGDM(ProgramStateRef state, void *Key)
Definition: ProgramState.cpp:519
clang::ento::ProgramState::getConstraintManager
ConstraintManager & getConstraintManager() const
Return the ConstraintManager.
Definition: ProgramState.h:654
clang::ento::SymbolReaper
A class responsible for cleaning up unused symbols.
Definition: SymbolManager.h:505
llvm::DenseSet< SymbolRef >
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1760
clang::ento::ProgramState::bindDefaultInitial
LLVM_NODISCARD ProgramStateRef bindDefaultInitial(SVal loc, SVal V, const LocationContext *LCtx) const
Initializes the region of memory represented by loc with an initial value.
Definition: ProgramState.cpp:128
clang::ento::ProgramStateManager::getSymbolManager
const SymbolManager & getSymbolManager() const
Definition: ProgramState.h:522
clang::ento::Environment::getSVal
SVal getSVal(const EnvironmentEntry &E, SValBuilder &svalBuilder) const
Fetches the current binding of the expression in the Environment.
Definition: Environment.cpp:86
Base
clang::ento::ProgramStateManager::haveEqualStores
bool haveEqualStores(ProgramStateRef S1, ProgramStateRef S2) const
Definition: ProgramState.h:574
clang::ento::ProgramState::get
ProgramStateTrait< T >::lookup_type get(typename ProgramStateTrait< T >::key_type key) const
Definition: ProgramState.h:391
clang::ento::ExplodedGraph
Definition: ExplodedGraph.h:304
clang::ento::ProgramStateManager::getBasicVals
BasicValueFactory & getBasicVals()
Definition: ProgramState.h:507
clang::ento::nonloc::LazyCompoundVal
Definition: SVals.h:492
clang::ento::ProgramStateManager::set
ProgramStateRef set(ProgramStateRef st, typename ProgramStateTrait< T >::key_type K, typename ProgramStateTrait< T >::value_type V, typename ProgramStateTrait< T >::context_type C)
Definition: ProgramState.h:604
state
and static some checkers Checker The latter are built on top of the former via the Checker and CheckerVisitor and attempts to isolate them from much of the gore of the internal analysis the analyzer is basically a source code simulator that traces out possible paths of execution The state of the and the combination of state and program point is a node in an exploded which has the entry program point and initial state
Definition: README.txt:30
clang::ento::Loc
Definition: SVals.h:326
clang::ento::ProgramStateManager::remove
ProgramStateRef remove(ProgramStateRef st)
Definition: ProgramState.h:631
clang::ento::ProgramStateManager::ProgramStateRelease
friend void ProgramStateRelease(const ProgramState *state)
Decrement the number of times this state is referenced.
Definition: ProgramState.cpp:34
clang::ento::SValBuilder
Definition: SValBuilder.h:53
clang::ento::ProgramStateManager::getRegionManager
const MemRegionManager & getRegionManager() const
Definition: ProgramState.h:531
clang::ento::ProgramState::getStateManager
ProgramStateManager & getStateManager() const
Return the ProgramStateManager associated with this state.
Definition: ProgramState.h:108
clang::CompoundLiteralExpr
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3409
clang::ento::ProgramState::getBasicVals
BasicValueFactory & getBasicVals() const
Definition: ProgramState.h:792
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::ento::ProgramState::invalidateRegions
LLVM_NODISCARD ProgramStateRef invalidateRegions(ArrayRef< const MemRegion * > Regions, const Expr *E, unsigned BlockCount, const LocationContext *LCtx, bool CausesPointerEscape, InvalidatedSymbols *IS=nullptr, const CallEvent *Call=nullptr, RegionAndSymbolInvalidationTraits *ITraits=nullptr) const
Returns the state with bindings for the given regions cleared from the store.
clang::ento::ProgramStateManager::getPersistentState
ProgramStateRef getPersistentState(ProgramState &Impl)
Definition: ProgramState.cpp:404
clang::ast_matchers::decl
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchersInternal.cpp:734
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::ento::ProgramState::BindExpr
LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S, const LocationContext *LCtx, SVal V, bool Invalidate=true) const
Create a new state by binding the value 'V' to the statement 'S' in the state's environment.
Definition: ProgramState.cpp:303
clang::ento::CallEventManager
Manages the lifetime of CallEvent objects.
Definition: CallEvent.h:1220
clang::ento::ProgramStateManager
Definition: ProgramState.h:461
SValBuilder.h
clang::ento::ProgramStateTrait::MakeVoidPtr
static void * MakeVoidPtr(data_type D)
Definition: ProgramState.h:52
clang::ento::ProgramStateManager::getCallEventManager
CallEventManager & getCallEventManager()
Definition: ProgramState.h:535
clang::ento::ProgramState::printDOT
void printDOT(raw_ostream &Out, const LocationContext *LCtx=nullptr, unsigned int Space=0) const
Definition: ProgramState.cpp:472
clang::ento::ProgramStateManager::getInitialState
ProgramStateRef getInitialState(const LocationContext *InitLoc)
Definition: ProgramState.cpp:387
llvm::ArrayRef
Definition: LLVM.h:34
clang::ento::ScanReachableSymbols
Definition: ProgramState.h:863
clang::ento::ProgramState::isNull
ConditionTruthVal isNull(SVal V) const
Check if the given SVal is constrained to zero or is a zero constant.
Definition: ProgramState.cpp:373
clang::ento::ProgramState::getSVal
SVal getSVal(const Stmt *S, const LocationContext *LCtx) const
Returns the SVal bound to the statement 'S' in the state's environment.
Definition: ProgramState.h:763
clang::ento::ProgramStateTrait::data_type
T::data_type data_type
Definition: ProgramState.h:51
LLVM.h
clang::ento::ProgramStateTrait::MakeData
static data_type MakeData(void *const *P)
Definition: ProgramState.h:53
clang::ento::ProgramStateManager::haveEqualEnvironments
bool haveEqualEnvironments(ProgramStateRef S1, ProgramStateRef S2) const
Definition: ProgramState.h:570
clang::ento::ScanReachableSymbols::ScanReachableSymbols
ScanReachableSymbols(ProgramStateRef st, SymbolVisitor &v)
Definition: ProgramState.h:870
clang::ento::AnalysisManager
Definition: AnalysisManager.h:31
clang::ento::ProgramState::bindDefaultZero
LLVM_NODISCARD ProgramStateRef bindDefaultZero(SVal loc, const LocationContext *LCtx) const
Performs C++ zero-initialization procedure on the region of memory represented by loc.
Definition: ProgramState.cpp:138
clang::ento::ProgramState::get
ProgramStateTrait< T >::data_type get() const
Definition: ProgramState.h:385
clang::ento::ExprEngine
Definition: ExprEngine.h:123
clang::ento::StoreManager::BindingsHandler
Definition: Store.h:252
clang::ento::ProgramStateManager::getStoreManager
StoreManager & getStoreManager()
Definition: ProgramState.h:537
clang::ento::ProgramStateManager::getRegionManager
MemRegionManager & getRegionManager()
Definition: ProgramState.h:528
clang::ento::ProgramState::FindGDM
void *const * FindGDM(void *K) const
Definition: ProgramState.cpp:489
clang::ento::MemRegionManager
Definition: MemRegion.h:1302
std
Definition: Format.h:4275
clang::ento::ProgramStateManager::FindGDMContext
void * FindGDMContext(void *index, void *(*CreateContext)(llvm::BumpPtrAllocator &), void(*DeleteContext)(void *))
Definition: ProgramState.cpp:494
clang::ento::ProgramState::getSValAsScalarOrLoc
SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const
Definition: ProgramState.h:770
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::ento::ScanReachableSymbols::scan
bool scan(nonloc::LazyCompoundVal val)
Definition: ProgramState.cpp:531
clang
Definition: CalledOnceCheck.h:17
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3092
clang::ento::ProgramStateManager::getContext
const ASTContext & getContext() const
Definition: ProgramState.h:505
clang::ento::ProgramStateManager::~ProgramStateManager
~ProgramStateManager()
Definition: ProgramState.cpp:84
clang::ento::ProgramState::ProgramStateRelease
friend void ProgramStateRelease(const ProgramState *state)
Decrement the number of times this state is referenced.
Definition: ProgramState.cpp:34
Environment.h
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::ObjCIvarDecl
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1923
clang::ento::CallEvent
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:142
clang::ento::SVal::isUnknown
bool isUnknown() const
Definition: SVals.h:135
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::ento::ProgramState::getRegion
const VarRegion * getRegion(const VarDecl *D, const LocationContext *LC) const
Utility method for getting regions.
Definition: ProgramState.h:658
clang::ento::ProgramState::areEqual
ConditionTruthVal areEqual(SVal Lhs, SVal Rhs) const
Definition: ProgramState.cpp:369
clang::ento::ProgramStateManager::getConstraintManager
ConstraintManager & getConstraintManager()
Definition: ProgramState.h:538
clang::ento::SVal
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition: SVals.h:74
v
do v
Definition: arm_acle.h:76
clang::ento::ProgramState::dump
void dump() const
Definition: ProgramState.cpp:477
clang::ento::SubRegion
SubRegion - A region that subsets another larger region.
Definition: MemRegion.h:435
clang::ento::Environment
An immutable map from EnvironemntEntries to SVals.
Definition: Environment.h:56
clang::ento::RegionAndSymbolInvalidationTraits
Information about invalidation for a particular region/symbol.
Definition: MemRegion.h:1516
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ento::ConstraintManagerCreator
std::unique_ptr< ConstraintManager >(* ConstraintManagerCreator)(ProgramStateManager &, ExprEngine *)
Definition: ProgramState.h:41
clang::IndirectFieldDecl::chain
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:3114
clang::ento::ProgramState::contains
bool contains(typename ProgramStateTrait< T >::key_type key) const
Definition: ProgramState.h:426
clang::ento::ProgramStateManager::get_context
ProgramStateTrait< T >::context_type get_context()
Definition: ProgramState.h:640
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::ento::ProgramState::ProgramState
ProgramState(ProgramStateManager *mgr, const Environment &env, StoreRef st, GenericDataMap gdm)
This ctor is used when creating the first ProgramState object.
Definition: ProgramState.cpp:46
clang::ento::ProgramState::getRawSVal
SVal getRawSVal(Loc LV, QualType T=QualType()) const
Returns the "raw" SVal bound to LV before any value simplfication.
Definition: ProgramState.h:782
clang::ento::ProgramState::ProgramStateRetain
friend void ProgramStateRetain(const ProgramState *state)
Increments the number of times this state is referenced.
Definition: ProgramState.cpp:29
clang::ento::SymbolManager
Definition: SymbolManager.h:417
clang::ento::EnvironmentEntry
An entry in the environment consists of a Stmt and an LocationContext.
Definition: Environment.h:35
llvm::IntrusiveRefCntPtr< const ProgramState >
clang::Type::isIntegralOrEnumerationType
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition: Type.h:7084
clang::ento::ProgramStateManager::iterBindings
void iterBindings(ProgramStateRef state, StoreManager::BindingsHandler &F)
Definition: ProgramState.h:558
clang::ento::ProgramStateManager::getSValBuilder
const SValBuilder & getSValBuilder() const
Definition: ProgramState.h:515
clang::ento::ProgramState::getSymbolManager
SymbolManager & getSymbolManager() const
Definition: ProgramState.h:796
clang::ento::ProgramState::assume
LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond, bool assumption) const
Assumes that the value of cond is zero (if assumption is "false") or non-zero (if assumption is "true...
Definition: ProgramState.h:664
clang::ento::ProgramState::assumeInclusiveRange
LLVM_NODISCARD ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt &From, const llvm::APSInt &To, bool assumption) const
Assumes that the value of Val is bounded with [From; To] (if assumption is "true") or it is fully out...
Definition: ProgramState.h:682