clang  15.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 RangeSet;
59 
60 /// \class ProgramState
61 /// ProgramState - This class encapsulates:
62 ///
63 /// 1. A mapping from expressions to values (Environment)
64 /// 2. A mapping from locations to values (Store)
65 /// 3. Constraints on symbolic values (GenericDataMap)
66 ///
67 /// Together these represent the "abstract state" of a program.
68 ///
69 /// ProgramState is intended to be used as a functional object; that is,
70 /// once it is created and made "persistent" in a FoldingSet, its
71 /// values will never change.
72 class ProgramState : public llvm::FoldingSetNode {
73 public:
74  typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
75  typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
76 
77 private:
78  void operator=(const ProgramState& R) = delete;
79 
80  friend class ProgramStateManager;
81  friend class ExplodedGraph;
82  friend class ExplodedNode;
83  friend class NodeBuilder;
84 
85  ProgramStateManager *stateMgr;
86  Environment Env; // Maps a Stmt to its current SVal.
87  Store store; // Maps a location to its current value.
88  GenericDataMap GDM; // Custom data stored by a client of this class.
89 
90  // A state is infeasible if there is a contradiction among the constraints.
91  // An infeasible state is represented by a `nullptr`.
92  // In the sense of `assumeDual`, a state can have two children by adding a
93  // new constraint and the negation of that new constraint. A parent state is
94  // over-constrained if both of its children are infeasible. In the
95  // mathematical sense, it means that the parent is infeasible and we should
96  // have realized that at the moment when we have created it. However, we
97  // could not recognize that because of the imperfection of the underlying
98  // constraint solver. We say it is posteriorly over-constrained because we
99  // recognize that a parent is infeasible only *after* a new and more specific
100  // constraint and its negation are evaluated.
101  //
102  // Example:
103  //
104  // x * x = 4 and x is in the range [0, 1]
105  // This is an already infeasible state, but the constraint solver is not
106  // capable of handling sqrt, thus we don't know it yet.
107  //
108  // Then a new constraint `x = 0` is added. At this moment the constraint
109  // solver re-evaluates the existing constraints and realizes the
110  // contradiction `0 * 0 = 4`.
111  // We also evaluate the negated constraint `x != 0`; the constraint solver
112  // deduces `x = 1` and then realizes the contradiction `1 * 1 = 4`.
113  // Both children are infeasible, thus the parent state is marked as
114  // posteriorly over-constrained. These parents are handled with special care:
115  // we do not allow transitions to exploded nodes with such states.
116  bool PosteriorlyOverconstrained = false;
117  // Make internal constraint solver entities friends so they can access the
118  // overconstrained-related functions. We want to keep this API inaccessible
119  // for Checkers.
120  friend class ConstraintManager;
121  bool isPosteriorlyOverconstrained() const {
122  return PosteriorlyOverconstrained;
123  }
124  ProgramStateRef cloneAsPosteriorlyOverconstrained() const;
125 
126  unsigned refCount;
127 
128  /// makeWithStore - Return a ProgramState with the same values as the current
129  /// state with the exception of using the specified Store.
130  ProgramStateRef makeWithStore(const StoreRef &store) const;
131 
132  void setStore(const StoreRef &storeRef);
133 
134 public:
135  /// This ctor is used when creating the first ProgramState object.
137  StoreRef st, GenericDataMap gdm);
138 
139  /// Copy ctor - We must explicitly define this or else the "Next" ptr
140  /// in FoldingSetNode will also get copied.
141  ProgramState(const ProgramState &RHS);
142 
143  ~ProgramState();
144 
145  int64_t getID() const;
146 
147  /// Return the ProgramStateManager associated with this state.
149  return *stateMgr;
150  }
151 
153 
154  /// Return the ConstraintManager.
156 
157  /// getEnvironment - Return the environment associated with this state.
158  /// The environment is the mapping from expressions to values.
159  const Environment& getEnvironment() const { return Env; }
160 
161  /// Return the store associated with this state. The store
162  /// is a mapping from locations to values.
163  Store getStore() const { return store; }
164 
165 
166  /// getGDM - Return the generic data map associated with this state.
167  GenericDataMap getGDM() const { return GDM; }
168 
169  void setGDM(GenericDataMap gdm) { GDM = gdm; }
170 
171  /// Profile - Profile the contents of a ProgramState object for use in a
172  /// FoldingSet. Two ProgramState objects are considered equal if they
173  /// have the same Environment, Store, and GenericDataMap.
174  static void Profile(llvm::FoldingSetNodeID& ID, const ProgramState *V) {
175  V->Env.Profile(ID);
176  ID.AddPointer(V->store);
177  V->GDM.Profile(ID);
178  ID.AddBoolean(V->PosteriorlyOverconstrained);
179  }
180 
181  /// Profile - Used to profile the contents of this object for inclusion
182  /// in a FoldingSet.
183  void Profile(llvm::FoldingSetNodeID& ID) const {
184  Profile(ID, this);
185  }
186 
189 
190  //==---------------------------------------------------------------------==//
191  // Constraints on values.
192  //==---------------------------------------------------------------------==//
193  //
194  // Each ProgramState records constraints on symbolic values. These constraints
195  // are managed using the ConstraintManager associated with a ProgramStateManager.
196  // As constraints gradually accrue on symbolic values, added constraints
197  // may conflict and indicate that a state is infeasible (as no real values
198  // could satisfy all the constraints). This is the principal mechanism
199  // for modeling path-sensitivity in ExprEngine/ProgramState.
200  //
201  // Various "assume" methods form the interface for adding constraints to
202  // symbolic values. A call to 'assume' indicates an assumption being placed
203  // on one or symbolic values. 'assume' methods take the following inputs:
204  //
205  // (1) A ProgramState object representing the current state.
206  //
207  // (2) The assumed constraint (which is specific to a given "assume" method).
208  //
209  // (3) A binary value "Assumption" that indicates whether the constraint is
210  // assumed to be true or false.
211  //
212  // The output of "assume*" is a new ProgramState object with the added constraints.
213  // If no new state is feasible, NULL is returned.
214  //
215 
216  /// Assumes that the value of \p cond is zero (if \p assumption is "false")
217  /// or non-zero (if \p assumption is "true").
218  ///
219  /// This returns a new state with the added constraint on \p cond.
220  /// If no new state is feasible, NULL is returned.
221  LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
222  bool assumption) const;
223 
224  /// Assumes both "true" and "false" for \p cond, and returns both
225  /// corresponding states (respectively).
226  ///
227  /// This is more efficient than calling assume() twice. Note that one (but not
228  /// both) of the returned states may be NULL.
229  LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
230  assume(DefinedOrUnknownSVal cond) const;
231 
232  LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
234  QualType IndexType = QualType()) const;
235 
236  LLVM_NODISCARD ProgramStateRef
238  bool assumption, QualType IndexType = QualType()) const;
239 
240  /// Assumes that the value of \p Val is bounded with [\p From; \p To]
241  /// (if \p assumption is "true") or it is fully out of this range
242  /// (if \p assumption is "false").
243  ///
244  /// This returns a new state with the added constraint on \p cond.
245  /// If no new state is feasible, NULL is returned.
247  const llvm::APSInt &From,
248  const llvm::APSInt &To,
249  bool assumption) const;
250 
251  /// Assumes given range both "true" and "false" for \p Val, and returns both
252  /// corresponding states (respectively).
253  ///
254  /// This is more efficient than calling assume() twice. Note that one (but not
255  /// both) of the returned states may be NULL.
256  LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
258  const llvm::APSInt &To) const;
259 
260  /// Check if the given SVal is not constrained to zero and is not
261  /// a zero constant.
263 
264  /// Check if the given SVal is constrained to zero or is a zero
265  /// constant.
267 
268  /// \return Whether values \p Lhs and \p Rhs are equal.
269  ConditionTruthVal areEqual(SVal Lhs, SVal Rhs) const;
270 
271  /// Utility method for getting regions.
272  LLVM_ATTRIBUTE_RETURNS_NONNULL
273  const VarRegion* getRegion(const VarDecl *D, const LocationContext *LC) const;
274 
275  //==---------------------------------------------------------------------==//
276  // Binding and retrieving values to/from the environment and symbolic store.
277  //==---------------------------------------------------------------------==//
278 
279  /// Create a new state by binding the value 'V' to the statement 'S' in the
280  /// state's environment.
281  LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
282  const LocationContext *LCtx, SVal V,
283  bool Invalidate = true) const;
284 
285  LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
286  const LocationContext *LCtx,
287  bool notifyChanges = true) const;
288 
289  LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
290  const LocationContext *LCtx) const;
291 
292  /// Initializes the region of memory represented by \p loc with an initial
293  /// value. Once initialized, all values loaded from any sub-regions of that
294  /// region will be equal to \p V, unless overwritten later by the program.
295  /// This method should not be used on regions that are already initialized.
296  /// If you need to indicate that memory contents have suddenly become unknown
297  /// within a certain region of memory, consider invalidateRegions().
298  LLVM_NODISCARD ProgramStateRef
299  bindDefaultInitial(SVal loc, SVal V, const LocationContext *LCtx) const;
300 
301  /// Performs C++ zero-initialization procedure on the region of memory
302  /// represented by \p loc.
303  LLVM_NODISCARD ProgramStateRef
304  bindDefaultZero(SVal loc, const LocationContext *LCtx) const;
305 
306  LLVM_NODISCARD ProgramStateRef killBinding(Loc LV) const;
307 
308  /// Returns the state with bindings for the given regions
309  /// cleared from the store.
310  ///
311  /// Optionally invalidates global regions as well.
312  ///
313  /// \param Regions the set of regions to be invalidated.
314  /// \param E the expression that caused the invalidation.
315  /// \param BlockCount The number of times the current basic block has been
316  // visited.
317  /// \param CausesPointerEscape the flag is set to true when
318  /// the invalidation entails escape of a symbol (representing a
319  /// pointer). For example, due to it being passed as an argument in a
320  /// call.
321  /// \param IS the set of invalidated symbols.
322  /// \param Call if non-null, the invalidated regions represent parameters to
323  /// the call and should be considered directly invalidated.
324  /// \param ITraits information about special handling for a particular
325  /// region/symbol.
326  LLVM_NODISCARD ProgramStateRef
328  unsigned BlockCount, const LocationContext *LCtx,
329  bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
330  const CallEvent *Call = nullptr,
331  RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
332 
333  LLVM_NODISCARD ProgramStateRef
334  invalidateRegions(ArrayRef<SVal> Regions, const Expr *E,
335  unsigned BlockCount, const LocationContext *LCtx,
336  bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
337  const CallEvent *Call = nullptr,
338  RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
339 
340  /// enterStackFrame - Returns the state for entry to the given stack frame,
341  /// preserving the current state.
342  LLVM_NODISCARD ProgramStateRef enterStackFrame(
343  const CallEvent &Call, const StackFrameContext *CalleeCtx) const;
344 
345  /// Return the value of 'self' if available in the given context.
346  SVal getSelfSVal(const LocationContext *LC) const;
347 
348  /// Get the lvalue for a base class object reference.
349  Loc getLValue(const CXXBaseSpecifier &BaseSpec, const SubRegion *Super) const;
350 
351  /// Get the lvalue for a base class object reference.
352  Loc getLValue(const CXXRecordDecl *BaseClass, const SubRegion *Super,
353  bool IsVirtual) const;
354 
355  /// Get the lvalue for a variable reference.
356  Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
357 
358  Loc getLValue(const CompoundLiteralExpr *literal,
359  const LocationContext *LC) const;
360 
361  /// Get the lvalue for an ivar reference.
362  SVal getLValue(const ObjCIvarDecl *decl, SVal base) const;
363 
364  /// Get the lvalue for a field reference.
365  SVal getLValue(const FieldDecl *decl, SVal Base) const;
366 
367  /// Get the lvalue for an indirect field reference.
368  SVal getLValue(const IndirectFieldDecl *decl, SVal Base) const;
369 
370  /// Get the lvalue for an array index.
371  SVal getLValue(QualType ElementType, SVal Idx, SVal Base) const;
372 
373  /// Returns the SVal bound to the statement 'S' in the state's environment.
374  SVal getSVal(const Stmt *S, const LocationContext *LCtx) const;
375 
376  SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const;
377 
378  /// Return the value bound to the specified location.
379  /// Returns UnknownVal() if none found.
380  SVal getSVal(Loc LV, QualType T = QualType()) const;
381 
382  /// Returns the "raw" SVal bound to LV before any value simplfication.
383  SVal getRawSVal(Loc LV, QualType T= QualType()) const;
384 
385  /// Return the value bound to the specified location.
386  /// Returns UnknownVal() if none found.
387  SVal getSVal(const MemRegion* R, QualType T = QualType()) const;
388 
389  /// Return the value bound to the specified location, assuming
390  /// that the value is a scalar integer or an enumeration or a pointer.
391  /// Returns UnknownVal() if none found or the region is not known to hold
392  /// a value of such type.
393  SVal getSValAsScalarOrLoc(const MemRegion *R) const;
394 
395  using region_iterator = const MemRegion **;
396 
397  /// Visits the symbols reachable from the given SVal using the provided
398  /// SymbolVisitor.
399  ///
400  /// This is a convenience API. Consider using ScanReachableSymbols class
401  /// directly when making multiple scans on the same state with the same
402  /// visitor to avoid repeated initialization cost.
403  /// \sa ScanReachableSymbols
404  bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const;
405 
406  /// Visits the symbols reachable from the regions in the given
407  /// MemRegions range using the provided SymbolVisitor.
408  bool scanReachableSymbols(llvm::iterator_range<region_iterator> Reachable,
409  SymbolVisitor &visitor) const;
410 
411  template <typename CB> CB scanReachableSymbols(SVal val) const;
412  template <typename CB> CB
413  scanReachableSymbols(llvm::iterator_range<region_iterator> Reachable) const;
414 
415  //==---------------------------------------------------------------------==//
416  // Accessing the Generic Data Map (GDM).
417  //==---------------------------------------------------------------------==//
418 
419  void *const* FindGDM(void *K) const;
420 
421  template <typename T>
422  LLVM_NODISCARD ProgramStateRef
423  add(typename ProgramStateTrait<T>::key_type K) const;
424 
425  template <typename T>
427  get() const {
429  }
430 
431  template<typename T>
433  get(typename ProgramStateTrait<T>::key_type key) const {
434  void *const* d = FindGDM(ProgramStateTrait<T>::GDMIndex());
436  }
437 
438  template <typename T>
440 
441  template <typename T>
442  LLVM_NODISCARD ProgramStateRef
443  remove(typename ProgramStateTrait<T>::key_type K) const;
444 
445  template <typename T>
446  LLVM_NODISCARD ProgramStateRef
448  typename ProgramStateTrait<T>::context_type C) const;
449 
450  template <typename T> LLVM_NODISCARD ProgramStateRef remove() const;
451 
452  template <typename T>
453  LLVM_NODISCARD ProgramStateRef
454  set(typename ProgramStateTrait<T>::data_type D) const;
455 
456  template <typename T>
457  LLVM_NODISCARD ProgramStateRef
459  typename ProgramStateTrait<T>::value_type E) const;
460 
461  template <typename T>
462  LLVM_NODISCARD ProgramStateRef
465  typename ProgramStateTrait<T>::context_type C) const;
466 
467  template<typename T>
468  bool contains(typename ProgramStateTrait<T>::key_type key) const {
469  void *const* d = FindGDM(ProgramStateTrait<T>::GDMIndex());
471  }
472 
473  // Pretty-printing.
474  void printJson(raw_ostream &Out, const LocationContext *LCtx = nullptr,
475  const char *NL = "\n", unsigned int Space = 0,
476  bool IsDot = false) const;
477 
478  void printDOT(raw_ostream &Out, const LocationContext *LCtx = nullptr,
479  unsigned int Space = 0) const;
480 
481  void dump() const;
482 
483 private:
484  friend void ProgramStateRetain(const ProgramState *state);
485  friend void ProgramStateRelease(const ProgramState *state);
486 
487  /// \sa invalidateValues()
488  /// \sa invalidateRegions()
490  invalidateRegionsImpl(ArrayRef<SVal> Values,
491  const Expr *E, unsigned BlockCount,
492  const LocationContext *LCtx,
493  bool ResultsInSymbolEscape,
494  InvalidatedSymbols *IS,
496  const CallEvent *Call) const;
497 };
498 
499 //===----------------------------------------------------------------------===//
500 // ProgramStateManager - Factory object for ProgramStates.
501 //===----------------------------------------------------------------------===//
502 
504  friend class ProgramState;
505  friend void ProgramStateRelease(const ProgramState *state);
506 private:
507  /// Eng - The ExprEngine that owns this state manager.
508  ExprEngine *Eng; /* Can be null. */
509 
510  EnvironmentManager EnvMgr;
511  std::unique_ptr<StoreManager> StoreMgr;
512  std::unique_ptr<ConstraintManager> ConstraintMgr;
513 
514  ProgramState::GenericDataMap::Factory GDMFactory;
515 
516  typedef llvm::DenseMap<void*,std::pair<void*,void (*)(void*)> > GDMContextsTy;
517  GDMContextsTy GDMContexts;
518 
519  /// StateSet - FoldingSet containing all the states created for analyzing
520  /// a particular function. This is used to unique states.
521  llvm::FoldingSet<ProgramState> StateSet;
522 
523  /// Object that manages the data for all created SVals.
524  std::unique_ptr<SValBuilder> svalBuilder;
525 
526  /// Manages memory for created CallEvents.
527  std::unique_ptr<CallEventManager> CallEventMgr;
528 
529  /// A BumpPtrAllocator to allocate states.
530  llvm::BumpPtrAllocator &Alloc;
531 
532  /// A vector of ProgramStates that we can reuse.
533  std::vector<ProgramState *> freeStates;
534 
535 public:
537  StoreManagerCreator CreateStoreManager,
538  ConstraintManagerCreator CreateConstraintManager,
539  llvm::BumpPtrAllocator& alloc,
540  ExprEngine *expreng);
541 
543 
545 
546  ASTContext &getContext() { return svalBuilder->getContext(); }
547  const ASTContext &getContext() const { return svalBuilder->getContext(); }
548 
550  return svalBuilder->getBasicValueFactory();
551  }
552 
554  return *svalBuilder;
555  }
556 
557  const SValBuilder &getSValBuilder() const {
558  return *svalBuilder;
559  }
560 
562  return svalBuilder->getSymbolManager();
563  }
565  return svalBuilder->getSymbolManager();
566  }
567 
568  llvm::BumpPtrAllocator& getAllocator() { return Alloc; }
569 
571  return svalBuilder->getRegionManager();
572  }
574  return svalBuilder->getRegionManager();
575  }
576 
577  CallEventManager &getCallEventManager() { return *CallEventMgr; }
578 
579  StoreManager &getStoreManager() { return *StoreMgr; }
580  ConstraintManager &getConstraintManager() { return *ConstraintMgr; }
581  ExprEngine &getOwningEngine() { return *Eng; }
582 
585  const StackFrameContext *LCtx,
586  SymbolReaper &SymReaper);
587 
588 public:
589 
590  SVal ArrayToPointer(Loc Array, QualType ElementTy) {
591  return StoreMgr->ArrayToPointer(Array, ElementTy);
592  }
593 
594  // Methods that manipulate the GDM.
595  ProgramStateRef addGDM(ProgramStateRef St, void *Key, void *Data);
597 
598  // Methods that query & manipulate the Store.
599 
601  StoreMgr->iterBindings(state->getStore(), F);
602  }
603 
606  ProgramStateRef GDMState);
607 
609  return ConstraintMgr->haveEqualConstraints(S1, S2);
610  }
611 
613  return S1->Env == S2->Env;
614  }
615 
617  return S1->store == S2->store;
618  }
619 
620  //==---------------------------------------------------------------------==//
621  // Generic Data Map methods.
622  //==---------------------------------------------------------------------==//
623  //
624  // ProgramStateManager and ProgramState support a "generic data map" that allows
625  // different clients of ProgramState objects to embed arbitrary data within a
626  // ProgramState object. The generic data map is essentially an immutable map
627  // from a "tag" (that acts as the "key" for a client) and opaque values.
628  // Tags/keys and values are simply void* values. The typical way that clients
629  // generate unique tags are by taking the address of a static variable.
630  // Clients are responsible for ensuring that data values referred to by a
631  // the data pointer are immutable (and thus are essentially purely functional
632  // data).
633  //
634  // The templated methods below use the ProgramStateTrait<T> class
635  // to resolve keys into the GDM and to return data values to clients.
636  //
637 
638  // Trait based GDM dispatch.
639  template <typename T>
643  }
644 
645  template<typename T>
650 
653  }
654 
655  template <typename T>
661  }
662 
663  template <typename T>
667 
670  }
671 
672  template <typename T>
675  }
676 
677  void *FindGDMContext(void *index,
678  void *(*CreateContext)(llvm::BumpPtrAllocator&),
679  void (*DeleteContext)(void*));
680 
681  template <typename T>
686 
688  }
689 };
690 
691 
692 //===----------------------------------------------------------------------===//
693 // Out-of-line method definitions for ProgramState.
694 //===----------------------------------------------------------------------===//
695 
697  return stateMgr->getConstraintManager();
698 }
699 
701  const LocationContext *LC) const
702 {
704 }
705 
707  bool Assumption) const {
708  if (Cond.isUnknown())
709  return this;
710 
711  return getStateManager().ConstraintMgr
712  ->assume(this, Cond.castAs<DefinedSVal>(), Assumption);
713 }
714 
715 inline std::pair<ProgramStateRef , ProgramStateRef >
717  if (Cond.isUnknown())
718  return std::make_pair(this, this);
719 
720  return getStateManager().ConstraintMgr
721  ->assumeDual(this, Cond.castAs<DefinedSVal>());
722 }
723 
725  DefinedOrUnknownSVal Val, const llvm::APSInt &From, const llvm::APSInt &To,
726  bool Assumption) const {
727  if (Val.isUnknown())
728  return this;
729 
730  assert(isa<NonLoc>(Val) && "Only NonLocs are supported!");
731 
732  return getStateManager().ConstraintMgr->assumeInclusiveRange(
733  this, Val.castAs<NonLoc>(), From, To, Assumption);
734 }
735 
736 inline std::pair<ProgramStateRef, ProgramStateRef>
738  const llvm::APSInt &From,
739  const llvm::APSInt &To) const {
740  if (Val.isUnknown())
741  return std::make_pair(this, this);
742 
743  assert(isa<NonLoc>(Val) && "Only NonLocs are supported!");
744 
745  return getStateManager().ConstraintMgr->assumeInclusiveRangeDual(
746  this, Val.castAs<NonLoc>(), From, To);
747 }
748 
750  if (Optional<Loc> L = LV.getAs<Loc>())
751  return bindLoc(*L, V, LCtx);
752  return this;
753 }
754 
756  const SubRegion *Super) const {
757  const auto *Base = BaseSpec.getType()->getAsCXXRecordDecl();
758  return loc::MemRegionVal(
759  getStateManager().getRegionManager().getCXXBaseObjectRegion(
760  Base, Super, BaseSpec.isVirtual()));
761 }
762 
763 inline Loc ProgramState::getLValue(const CXXRecordDecl *BaseClass,
764  const SubRegion *Super,
765  bool IsVirtual) const {
766  return loc::MemRegionVal(
767  getStateManager().getRegionManager().getCXXBaseObjectRegion(
768  BaseClass, Super, IsVirtual));
769 }
770 
772  const LocationContext *LC) const {
773  return getStateManager().StoreMgr->getLValueVar(VD, LC);
774 }
775 
777  const LocationContext *LC) const {
778  return getStateManager().StoreMgr->getLValueCompoundLiteral(literal, LC);
779 }
780 
782  return getStateManager().StoreMgr->getLValueIvar(D, Base);
783 }
784 
785 inline SVal ProgramState::getLValue(const FieldDecl *D, SVal Base) const {
786  return getStateManager().StoreMgr->getLValueField(D, Base);
787 }
788 
790  SVal Base) const {
791  StoreManager &SM = *getStateManager().StoreMgr;
792  for (const auto *I : D->chain()) {
793  Base = SM.getLValueField(cast<FieldDecl>(I), Base);
794  }
795 
796  return Base;
797 }
798 
799 inline SVal ProgramState::getLValue(QualType ElementType, SVal Idx, SVal Base) const{
800  if (Optional<NonLoc> N = Idx.getAs<NonLoc>())
801  return getStateManager().StoreMgr->getLValueElement(ElementType, *N, Base);
802  return UnknownVal();
803 }
804 
805 inline SVal ProgramState::getSVal(const Stmt *Ex,
806  const LocationContext *LCtx) const{
807  return Env.getSVal(EnvironmentEntry(Ex, LCtx),
808  *getStateManager().svalBuilder);
809 }
810 
811 inline SVal
813  const LocationContext *LCtx) const {
814  if (const Expr *Ex = dyn_cast<Expr>(S)) {
815  QualType T = Ex->getType();
816  if (Ex->isGLValue() || Loc::isLocType(T) ||
818  return getSVal(S, LCtx);
819  }
820 
821  return UnknownVal();
822 }
823 
825  return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
826 }
827 
828 inline SVal ProgramState::getSVal(const MemRegion* R, QualType T) const {
829  return getStateManager().StoreMgr->getBinding(getStore(),
831  T);
832 }
833 
835  return getStateManager().getBasicVals();
836 }
837 
840 }
841 
842 template<typename T>
844  return getStateManager().add<T>(this, K, get_context<T>());
845 }
846 
847 template <typename T>
849  return getStateManager().get_context<T>();
850 }
851 
852 template<typename T>
854  return getStateManager().remove<T>(this, K, get_context<T>());
855 }
856 
857 template<typename T>
859  typename ProgramStateTrait<T>::context_type C) const {
860  return getStateManager().remove<T>(this, K, C);
861 }
862 
863 template <typename T>
865  return getStateManager().remove<T>(this);
866 }
867 
868 template<typename T>
870  return getStateManager().set<T>(this, D);
871 }
872 
873 template<typename T>
875  typename ProgramStateTrait<T>::value_type E) const {
876  return getStateManager().set<T>(this, K, E, get_context<T>());
877 }
878 
879 template<typename T>
882  typename ProgramStateTrait<T>::context_type C) const {
883  return getStateManager().set<T>(this, K, E, C);
884 }
885 
886 template <typename CB>
888  CB cb(this);
889  scanReachableSymbols(val, cb);
890  return cb;
891 }
892 
893 template <typename CB>
895  llvm::iterator_range<region_iterator> Reachable) const {
896  CB cb(this);
897  scanReachableSymbols(Reachable, cb);
898  return cb;
899 }
900 
901 /// \class ScanReachableSymbols
902 /// A utility class that visits the reachable symbols using a custom
903 /// SymbolVisitor. Terminates recursive traversal when the visitor function
904 /// returns false.
907 
908  VisitedItems visited;
909  ProgramStateRef state;
910  SymbolVisitor &visitor;
911 public:
913  : state(std::move(st)), visitor(v) {}
914 
915  bool scan(nonloc::LazyCompoundVal val);
916  bool scan(nonloc::CompoundVal val);
917  bool scan(SVal val);
918  bool scan(const MemRegion *R);
919  bool scan(const SymExpr *sym);
920 };
921 
922 } // end ento namespace
923 
924 } // end clang namespace
925 
926 #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:645
clang::ento::ProgramStateManager::haveEqualConstraints
bool haveEqualConstraints(ProgramStateRef S1, ProgramStateRef S2) const
Definition: ProgramState.h:608
clang::ento::ProgramStateManager::getOwningEngine
ExprEngine & getOwningEngine()
Definition: ProgramState.h:581
clang::ento::Loc::isLocType
static bool isLocType(QualType T)
Definition: SVals.h:286
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:664
clang::ento::ProgramState::assumeInBound
LLVM_NODISCARD ProgramStateRef assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound, bool assumption, QualType IndexType=QualType()) const
Definition: ProgramState.cpp:362
clang::ento::SymbolVisitor
Definition: SymbolManager.h:654
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:113
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:373
clang::ento::ProgramState::get_context
ProgramStateTrait< T >::context_type get_context() const
Definition: ProgramState.h:848
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:101
clang::ento::NonLoc
Definition: SVals.h:262
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:217
clang::ento::ProgramState::getGDM
GenericDataMap getGDM() const
getGDM - Return the generic data map associated with this state.
Definition: ProgramState.h:167
clang::ento::ProgramStateManager::getSValBuilder
SValBuilder & getSValBuilder()
Definition: ProgramState.h:553
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:174
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:731
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2862
clang::ento::ProgramState::getEnvironment
const Environment & getEnvironment() const
getEnvironment - Return the environment associated with this state.
Definition: ProgramState.h:159
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:75
llvm::Optional
Definition: LLVM.h:40
clang::ento::ProgramState::assumeInBoundDual
LLVM_NODISCARD std::pair< ProgramStateRef, ProgramStateRef > assumeInBoundDual(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound, QualType IndexType=QualType()) const
Definition: ProgramState.cpp:318
clang::StackFrameContext
It represents a stack frame of the call stack (based on CallEvent).
Definition: AnalysisDeclContext.h:299
clang::ento::UnknownVal
Definition: SVals.h:232
clang::ento::ProgramState::setGDM
void setGDM(GenericDataMap gdm)
Definition: ProgramState.h:169
clang::ento::loc::MemRegionVal
Definition: SVals.h:502
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:72
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:948
clang::ento::ProgramStateManager::getAllocator
llvm::BumpPtrAllocator & getAllocator()
Definition: ProgramState.h:568
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:656
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:183
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:105
clang::ento::ProgramStateManager::addGDM
ProgramStateRef addGDM(ProgramStateRef St, void *Key, void *Data)
Definition: ProgramState.cpp:522
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:95
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:405
DynamicTypeInfo.h
V
#define V(N, I)
Definition: ASTContext.h:3176
clang::ento::DefinedSVal
Definition: SVals.h:239
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:546
clang::ento::NodeBuilder
Definition: CoreEngine.h:241
clang::ento::ProgramStateManager::getSymbolManager
SymbolManager & getSymbolManager()
Definition: ProgramState.h:561
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:755
clang::ento::ProgramStateManager::set
ProgramStateRef set(ProgramStateRef st, typename ProgramStateTrait< T >::data_type D)
Definition: ProgramState.h:640
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:590
clang::ento::ProgramState::IntSetTy
llvm::ImmutableSet< llvm::APSInt * > IntSetTy
Definition: ProgramState.h:74
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
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:371
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:163
clang::ento::ProgramState::getAnalysisManager
AnalysisManager & getAnalysisManager() const
Definition: ProgramState.cpp:496
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:460
clang::ento::VarRegion
Definition: MemRegion.h:928
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:534
clang::ento::ProgramState::getConstraintManager
ConstraintManager & getConstraintManager() const
Return the ConstraintManager.
Definition: ProgramState.h:696
clang::ento::SymbolReaper
A class responsible for cleaning up unused symbols.
Definition: SymbolManager.h:572
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:1759
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:564
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:616
clang::ento::ProgramState::get
ProgramStateTrait< T >::lookup_type get(typename ProgramStateTrait< T >::key_type key) const
Definition: ProgramState.h:433
clang::ento::ExplodedGraph
Definition: ExplodedGraph.h:302
clang::ento::ProgramStateManager::getBasicVals
BasicValueFactory & getBasicVals()
Definition: ProgramState.h:549
clang::ento::nonloc::LazyCompoundVal
Definition: SVals.h:398
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:646
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:278
clang::ento::ProgramStateManager::remove
ProgramStateRef remove(ProgramStateRef st)
Definition: ProgramState.h:673
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:573
clang::ento::ProgramState::getStateManager
ProgramStateManager & getStateManager() const
Return the ProgramStateManager associated with this state.
Definition: ProgramState.h:148
clang::CompoundLiteralExpr
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3405
clang::ento::ProgramState::getBasicVals
BasicValueFactory & getBasicVals() const
Definition: ProgramState.h:834
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:413
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:1233
clang::ento::ProgramStateManager
Definition: ProgramState.h:503
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:577
clang::ento::ProgramState::printDOT
void printDOT(raw_ostream &Out, const LocationContext *LCtx=nullptr, unsigned int Space=0) const
Definition: ProgramState.cpp:487
clang::ento::ProgramStateManager::getInitialState
ProgramStateRef getInitialState(const LocationContext *InitLoc)
Definition: ProgramState.cpp:396
llvm::ArrayRef
Definition: LLVM.h:34
clang::ento::ScanReachableSymbols
Definition: ProgramState.h:905
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:382
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:805
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:612
clang::ento::ScanReachableSymbols::ScanReachableSymbols
ScanReachableSymbols(ProgramStateRef st, SymbolVisitor &v)
Definition: ProgramState.h:912
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:427
clang::ento::ExprEngine
Definition: ExprEngine.h:123
clang::ento::StoreManager::BindingsHandler
Definition: Store.h:252
int64_t
long int64_t
Definition: hlsl_basic_types.h:25
clang::ento::ProgramStateManager::getStoreManager
StoreManager & getStoreManager()
Definition: ProgramState.h:579
clang::ento::ProgramStateManager::getRegionManager
MemRegionManager & getRegionManager()
Definition: ProgramState.h:570
clang::ento::ProgramState::FindGDM
void *const * FindGDM(void *K) const
Definition: ProgramState.cpp:504
clang::ento::MemRegionManager
Definition: MemRegion.h:1341
std
Definition: Format.h:4296
clang::ento::ProgramStateManager::FindGDMContext
void * FindGDMContext(void *index, void *(*CreateContext)(llvm::BumpPtrAllocator &), void(*DeleteContext)(void *))
Definition: ProgramState.cpp:509
clang::ento::ProgramState::getSValAsScalarOrLoc
SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const
Definition: ProgramState.h:812
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::ento::ScanReachableSymbols::scan
bool scan(nonloc::LazyCompoundVal val)
Definition: ProgramState.cpp:546
clang
Definition: CalledOnceCheck.h:17
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3116
clang::ento::ProgramStateManager::getContext
const ASTContext & getContext() const
Definition: ProgramState.h:547
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:148
clang::ento::SVal::isUnknown
bool isUnknown() const
Definition: SVals.h:126
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::ento::ProgramState::getRegion
const LLVM_ATTRIBUTE_RETURNS_NONNULL VarRegion * getRegion(const VarDecl *D, const LocationContext *LC) const
Utility method for getting regions.
Definition: ProgramState.h:700
clang::ento::ProgramState::areEqual
ConditionTruthVal areEqual(SVal Lhs, SVal Rhs) const
Definition: ProgramState.cpp:378
clang::ento::ProgramStateManager::getConstraintManager
ConstraintManager & getConstraintManager()
Definition: ProgramState.h:580
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:492
clang::ento::SubRegion
SubRegion - A region that subsets another larger region.
Definition: MemRegion.h:442
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:1557
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:3138
clang::ento::ProgramState::contains
bool contains(typename ProgramStateTrait< T >::key_type key) const
Definition: ProgramState.h:468
clang::ento::ProgramStateManager::get_context
ProgramStateTrait< T >::context_type get_context()
Definition: ProgramState.h:682
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:824
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:481
clang::ento::EnvironmentEntry
An entry in the environment consists of a Stmt and an LocationContext.
Definition: Environment.h:35
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:47
clang::Type::isIntegralOrEnumerationType
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition: Type.h:7199
clang::ento::ProgramStateManager::iterBindings
void iterBindings(ProgramStateRef state, StoreManager::BindingsHandler &F)
Definition: ProgramState.h:600
clang::ento::ProgramStateManager::getSValBuilder
const SValBuilder & getSValBuilder() const
Definition: ProgramState.h:557
clang::ento::ProgramState::getSymbolManager
SymbolManager & getSymbolManager() const
Definition: ProgramState.h:838
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:706
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:724