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