Implicitly expand argument packs when performing template argument
[clang.git] / include / clang / Checker / PathSensitive / GRState.h
blob47ea4c9d08bd9788cc15964a055497f237918c03
1 //== GRState.h - Path-sensitive "State" for tracking values -----*- C++ -*--==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines SymbolRef, ExprBindKey, and GRState*.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_ANALYSIS_VALUESTATE_H
15 #define LLVM_CLANG_ANALYSIS_VALUESTATE_H
17 #include "clang/Checker/PathSensitive/ConstraintManager.h"
18 #include "clang/Checker/PathSensitive/Environment.h"
19 #include "clang/Checker/PathSensitive/Store.h"
20 #include "clang/Checker/PathSensitive/SValBuilder.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/ImmutableMap.h"
23 #include "llvm/Support/Casting.h"
25 namespace llvm {
26 class APSInt;
27 class BumpPtrAllocator;
28 class raw_ostream;
31 namespace clang {
32 class ASTContext;
33 class GRStateManager;
34 class Checker;
36 typedef ConstraintManager* (*ConstraintManagerCreator)(GRStateManager&,
37 GRSubEngine&);
38 typedef StoreManager* (*StoreManagerCreator)(GRStateManager&);
40 //===----------------------------------------------------------------------===//
41 // GRStateTrait - Traits used by the Generic Data Map of a GRState.
42 //===----------------------------------------------------------------------===//
44 template <typename T> struct GRStatePartialTrait;
46 template <typename T> struct GRStateTrait {
47 typedef typename T::data_type data_type;
48 static inline void* GDMIndex() { return &T::TagInt; }
49 static inline void* MakeVoidPtr(data_type D) { return (void*) D; }
50 static inline data_type MakeData(void* const* P) {
51 return P ? (data_type) *P : (data_type) 0;
55 class GRStateManager;
57 /// GRState - This class encapsulates:
58 ///
59 /// 1. A mapping from expressions to values (Environment)
60 /// 2. A mapping from locations to values (Store)
61 /// 3. Constraints on symbolic values (GenericDataMap)
62 ///
63 /// Together these represent the "abstract state" of a program.
64 ///
65 /// GRState is intended to be used as a functional object; that is,
66 /// once it is created and made "persistent" in a FoldingSet, its
67 /// values will never change.
68 class GRState : public llvm::FoldingSetNode {
69 public:
70 typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
71 typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
73 private:
74 void operator=(const GRState& R) const; // Do not implement.
76 friend class GRStateManager;
78 GRStateManager *StateMgr;
79 Environment Env; // Maps a Stmt to its current SVal.
80 Store St; // Maps a location to its current value.
81 GenericDataMap GDM; // Custom data stored by a client of this class.
83 /// makeWithStore - Return a GRState with the same values as the current
84 /// state with the exception of using the specified Store.
85 const GRState *makeWithStore(Store store) const;
87 public:
89 /// This ctor is used when creating the first GRState object.
90 GRState(GRStateManager *mgr, const Environment& env,
91 Store st, GenericDataMap gdm)
92 : StateMgr(mgr),
93 Env(env),
94 St(st),
95 GDM(gdm) {}
97 /// Copy ctor - We must explicitly define this or else the "Next" ptr
98 /// in FoldingSetNode will also get copied.
99 GRState(const GRState& RHS)
100 : llvm::FoldingSetNode(),
101 StateMgr(RHS.StateMgr),
102 Env(RHS.Env),
103 St(RHS.St),
104 GDM(RHS.GDM) {}
106 /// getStateManager - Return the GRStateManager associated with this state.
107 GRStateManager &getStateManager() const {
108 return *StateMgr;
111 /// getEnvironment - Return the environment associated with this state.
112 /// The environment is the mapping from expressions to values.
113 const Environment& getEnvironment() const { return Env; }
115 /// getStore - Return the store associated with this state. The store
116 /// is a mapping from locations to values.
117 Store getStore() const { return St; }
119 void setStore(Store s) { St = s; }
121 /// getGDM - Return the generic data map associated with this state.
122 GenericDataMap getGDM() const { return GDM; }
124 void setGDM(GenericDataMap gdm) { GDM = gdm; }
126 /// Profile - Profile the contents of a GRState object for use in a
127 /// FoldingSet. Two GRState objects are considered equal if they
128 /// have the same Environment, Store, and GenericDataMap.
129 static void Profile(llvm::FoldingSetNodeID& ID, const GRState* V) {
130 V->Env.Profile(ID);
131 ID.AddPointer(V->St);
132 V->GDM.Profile(ID);
135 /// Profile - Used to profile the contents of this object for inclusion
136 /// in a FoldingSet.
137 void Profile(llvm::FoldingSetNodeID& ID) const {
138 Profile(ID, this);
141 BasicValueFactory &getBasicVals() const;
142 SymbolManager &getSymbolManager() const;
144 //==---------------------------------------------------------------------==//
145 // Constraints on values.
146 //==---------------------------------------------------------------------==//
148 // Each GRState records constraints on symbolic values. These constraints
149 // are managed using the ConstraintManager associated with a GRStateManager.
150 // As constraints gradually accrue on symbolic values, added constraints
151 // may conflict and indicate that a state is infeasible (as no real values
152 // could satisfy all the constraints). This is the principal mechanism
153 // for modeling path-sensitivity in GRExprEngine/GRState.
155 // Various "assume" methods form the interface for adding constraints to
156 // symbolic values. A call to 'assume' indicates an assumption being placed
157 // on one or symbolic values. 'assume' methods take the following inputs:
159 // (1) A GRState object representing the current state.
161 // (2) The assumed constraint (which is specific to a given "assume" method).
163 // (3) A binary value "Assumption" that indicates whether the constraint is
164 // assumed to be true or false.
166 // The output of "assume*" is a new GRState object with the added constraints.
167 // If no new state is feasible, NULL is returned.
170 const GRState *assume(DefinedOrUnknownSVal cond, bool assumption) const;
172 /// This method assumes both "true" and "false" for 'cond', and
173 /// returns both corresponding states. It's shorthand for doing
174 /// 'assume' twice.
175 std::pair<const GRState*, const GRState*>
176 assume(DefinedOrUnknownSVal cond) const;
178 const GRState *assumeInBound(DefinedOrUnknownSVal idx,
179 DefinedOrUnknownSVal upperBound,
180 bool assumption) const;
182 //==---------------------------------------------------------------------==//
183 // Utility methods for getting regions.
184 //==---------------------------------------------------------------------==//
186 const VarRegion* getRegion(const VarDecl *D, const LocationContext *LC) const;
188 //==---------------------------------------------------------------------==//
189 // Binding and retrieving values to/from the environment and symbolic store.
190 //==---------------------------------------------------------------------==//
192 /// BindCompoundLiteral - Return the state that has the bindings currently
193 /// in this state plus the bindings for the CompoundLiteral.
194 const GRState *bindCompoundLiteral(const CompoundLiteralExpr* CL,
195 const LocationContext *LC,
196 SVal V) const;
198 /// Create a new state by binding the value 'V' to the statement 'S' in the
199 /// state's environment.
200 const GRState *BindExpr(const Stmt *S, SVal V, bool Invalidate = true) const;
202 /// Create a new state by binding the value 'V' and location 'locaton' to the
203 /// statement 'S' in the state's environment.
204 const GRState *bindExprAndLocation(const Stmt *S, SVal location, SVal V)
205 const;
207 const GRState *bindDecl(const VarRegion *VR, SVal V) const;
209 const GRState *bindDeclWithNoInit(const VarRegion *VR) const;
211 const GRState *bindLoc(Loc location, SVal V) const;
213 const GRState *bindLoc(SVal location, SVal V) const;
215 const GRState *bindDefault(SVal loc, SVal V) const;
217 const GRState *unbindLoc(Loc LV) const;
219 /// InvalidateRegion - Returns the state with bindings for the given region
220 /// cleared from the store. See InvalidateRegions.
221 const GRState *InvalidateRegion(const MemRegion *R,
222 const Expr *E, unsigned BlockCount,
223 StoreManager::InvalidatedSymbols *IS = NULL)
224 const {
225 return InvalidateRegions(&R, &R+1, E, BlockCount, IS, false);
228 /// InvalidateRegions - Returns the state with bindings for the given regions
229 /// cleared from the store. The regions are provided as a continuous array
230 /// from Begin to End. Optionally invalidates global regions as well.
231 const GRState *InvalidateRegions(const MemRegion * const *Begin,
232 const MemRegion * const *End,
233 const Expr *E, unsigned BlockCount,
234 StoreManager::InvalidatedSymbols *IS,
235 bool invalidateGlobals) const;
237 /// EnterStackFrame - Returns the state for entry to the given stack frame,
238 /// preserving the current state.
239 const GRState *EnterStackFrame(const StackFrameContext *frame) const;
241 /// Get the lvalue for a variable reference.
242 Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
244 /// Get the lvalue for a StringLiteral.
245 Loc getLValue(const StringLiteral *literal) const;
247 Loc getLValue(const CompoundLiteralExpr *literal,
248 const LocationContext *LC) const;
250 /// Get the lvalue for an ivar reference.
251 SVal getLValue(const ObjCIvarDecl *decl, SVal base) const;
253 /// Get the lvalue for a field reference.
254 SVal getLValue(const FieldDecl *decl, SVal Base) const;
256 /// Get the lvalue for an array index.
257 SVal getLValue(QualType ElementType, SVal Idx, SVal Base) const;
259 const llvm::APSInt *getSymVal(SymbolRef sym) const;
261 /// Returns the SVal bound to the statement 'S' in the state's environment.
262 SVal getSVal(const Stmt* S) const;
264 SVal getSValAsScalarOrLoc(const Stmt *Ex) const;
266 SVal getSVal(Loc LV, QualType T = QualType()) const;
268 /// Returns the "raw" SVal bound to LV before any value simplfication.
269 SVal getRawSVal(Loc LV, QualType T= QualType()) const;
271 SVal getSVal(const MemRegion* R) const;
273 SVal getSValAsScalarOrLoc(const MemRegion *R) const;
275 const llvm::APSInt *getSymVal(SymbolRef sym);
277 bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const;
279 bool scanReachableSymbols(const SVal *I, const SVal *E,
280 SymbolVisitor &visitor) const;
282 bool scanReachableSymbols(const MemRegion * const *I,
283 const MemRegion * const *E,
284 SymbolVisitor &visitor) const;
286 template <typename CB> CB scanReachableSymbols(SVal val) const;
287 template <typename CB> CB scanReachableSymbols(const SVal *beg,
288 const SVal *end) const;
290 template <typename CB> CB
291 scanReachableSymbols(const MemRegion * const *beg,
292 const MemRegion * const *end) const;
294 //==---------------------------------------------------------------------==//
295 // Accessing the Generic Data Map (GDM).
296 //==---------------------------------------------------------------------==//
298 void* const* FindGDM(void* K) const;
300 template<typename T>
301 const GRState *add(typename GRStateTrait<T>::key_type K) const;
303 template <typename T>
304 typename GRStateTrait<T>::data_type
305 get() const {
306 return GRStateTrait<T>::MakeData(FindGDM(GRStateTrait<T>::GDMIndex()));
309 template<typename T>
310 typename GRStateTrait<T>::lookup_type
311 get(typename GRStateTrait<T>::key_type key) const {
312 void* const* d = FindGDM(GRStateTrait<T>::GDMIndex());
313 return GRStateTrait<T>::Lookup(GRStateTrait<T>::MakeData(d), key);
316 template <typename T>
317 typename GRStateTrait<T>::context_type get_context() const;
320 template<typename T>
321 const GRState *remove(typename GRStateTrait<T>::key_type K) const;
323 template<typename T>
324 const GRState *remove(typename GRStateTrait<T>::key_type K,
325 typename GRStateTrait<T>::context_type C) const;
326 template <typename T>
327 const GRState *remove() const;
329 template<typename T>
330 const GRState *set(typename GRStateTrait<T>::data_type D) const;
332 template<typename T>
333 const GRState *set(typename GRStateTrait<T>::key_type K,
334 typename GRStateTrait<T>::value_type E) const;
336 template<typename T>
337 const GRState *set(typename GRStateTrait<T>::key_type K,
338 typename GRStateTrait<T>::value_type E,
339 typename GRStateTrait<T>::context_type C) const;
341 template<typename T>
342 bool contains(typename GRStateTrait<T>::key_type key) const {
343 void* const* d = FindGDM(GRStateTrait<T>::GDMIndex());
344 return GRStateTrait<T>::Contains(GRStateTrait<T>::MakeData(d), key);
347 // State pretty-printing.
348 class Printer {
349 public:
350 virtual ~Printer() {}
351 virtual void Print(llvm::raw_ostream& Out, const GRState* state,
352 const char* nl, const char* sep) = 0;
355 // Pretty-printing.
356 void print(llvm::raw_ostream& Out, CFG &C, const char *nl = "\n",
357 const char *sep = "") const;
359 void printStdErr(CFG &C) const;
361 void printDOT(llvm::raw_ostream& Out, CFG &C) const;
364 class GRStateSet {
365 typedef llvm::SmallPtrSet<const GRState*,5> ImplTy;
366 ImplTy Impl;
367 public:
368 GRStateSet() {}
370 inline void Add(const GRState* St) {
371 Impl.insert(St);
374 typedef ImplTy::const_iterator iterator;
376 inline unsigned size() const { return Impl.size(); }
377 inline bool empty() const { return Impl.empty(); }
379 inline iterator begin() const { return Impl.begin(); }
380 inline iterator end() const { return Impl.end(); }
382 class AutoPopulate {
383 GRStateSet& S;
384 unsigned StartSize;
385 const GRState* St;
386 public:
387 AutoPopulate(GRStateSet& s, const GRState* st)
388 : S(s), StartSize(S.size()), St(st) {}
390 ~AutoPopulate() {
391 if (StartSize == S.size())
392 S.Add(St);
397 //===----------------------------------------------------------------------===//
398 // GRStateManager - Factory object for GRStates.
399 //===----------------------------------------------------------------------===//
401 class GRStateManager {
402 friend class GRState;
403 friend class GRExprEngine; // FIXME: Remove.
404 private:
405 /// Eng - The GRSubEngine that owns this state manager.
406 GRSubEngine &Eng;
408 EnvironmentManager EnvMgr;
409 llvm::OwningPtr<StoreManager> StoreMgr;
410 llvm::OwningPtr<ConstraintManager> ConstraintMgr;
412 GRState::GenericDataMap::Factory GDMFactory;
414 typedef llvm::DenseMap<void*,std::pair<void*,void (*)(void*)> > GDMContextsTy;
415 GDMContextsTy GDMContexts;
417 /// Printers - A set of printer objects used for pretty-printing a GRState.
418 /// GRStateManager owns these objects.
419 std::vector<GRState::Printer*> Printers;
421 /// StateSet - FoldingSet containing all the states created for analyzing
422 /// a particular function. This is used to unique states.
423 llvm::FoldingSet<GRState> StateSet;
425 /// Object that manages the data for all created SVals.
426 llvm::OwningPtr<SValBuilder> svalBuilder;
428 /// Alloc - A BumpPtrAllocator to allocate states.
429 llvm::BumpPtrAllocator &Alloc;
431 public:
432 GRStateManager(ASTContext& Ctx,
433 StoreManagerCreator CreateStoreManager,
434 ConstraintManagerCreator CreateConstraintManager,
435 llvm::BumpPtrAllocator& alloc,
436 GRSubEngine &subeng)
437 : Eng(subeng),
438 EnvMgr(alloc),
439 GDMFactory(alloc),
440 svalBuilder(createSimpleSValBuilder(alloc, Ctx, *this)),
441 Alloc(alloc) {
442 StoreMgr.reset((*CreateStoreManager)(*this));
443 ConstraintMgr.reset((*CreateConstraintManager)(*this, subeng));
446 ~GRStateManager();
448 const GRState *getInitialState(const LocationContext *InitLoc);
450 ASTContext &getContext() { return svalBuilder->getContext(); }
451 const ASTContext &getContext() const { return svalBuilder->getContext(); }
453 BasicValueFactory &getBasicVals() {
454 return svalBuilder->getBasicValueFactory();
456 const BasicValueFactory& getBasicVals() const {
457 return svalBuilder->getBasicValueFactory();
460 SValBuilder &getSValBuilder() {
461 return *svalBuilder;
464 SymbolManager &getSymbolManager() {
465 return svalBuilder->getSymbolManager();
467 const SymbolManager &getSymbolManager() const {
468 return svalBuilder->getSymbolManager();
471 llvm::BumpPtrAllocator& getAllocator() { return Alloc; }
473 MemRegionManager& getRegionManager() {
474 return svalBuilder->getRegionManager();
476 const MemRegionManager& getRegionManager() const {
477 return svalBuilder->getRegionManager();
480 StoreManager& getStoreManager() { return *StoreMgr; }
481 ConstraintManager& getConstraintManager() { return *ConstraintMgr; }
482 GRSubEngine& getOwningEngine() { return Eng; }
484 const GRState* RemoveDeadBindings(const GRState* St,
485 const StackFrameContext *LCtx,
486 SymbolReaper& SymReaper);
488 /// Marshal a new state for the callee in another translation unit.
489 /// 'state' is owned by the caller's engine.
490 const GRState *MarshalState(const GRState *state, const StackFrameContext *L);
492 public:
494 SVal ArrayToPointer(Loc Array) {
495 return StoreMgr->ArrayToPointer(Array);
498 // Methods that manipulate the GDM.
499 const GRState* addGDM(const GRState* St, void* Key, void* Data);
500 const GRState *removeGDM(const GRState *state, void *Key);
502 // Methods that query & manipulate the Store.
504 void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {
505 StoreMgr->iterBindings(state->getStore(), F);
508 const GRState* getPersistentState(GRState& Impl);
510 //==---------------------------------------------------------------------==//
511 // Generic Data Map methods.
512 //==---------------------------------------------------------------------==//
514 // GRStateManager and GRState support a "generic data map" that allows
515 // different clients of GRState objects to embed arbitrary data within a
516 // GRState object. The generic data map is essentially an immutable map
517 // from a "tag" (that acts as the "key" for a client) and opaque values.
518 // Tags/keys and values are simply void* values. The typical way that clients
519 // generate unique tags are by taking the address of a static variable.
520 // Clients are responsible for ensuring that data values referred to by a
521 // the data pointer are immutable (and thus are essentially purely functional
522 // data).
524 // The templated methods below use the GRStateTrait<T> class
525 // to resolve keys into the GDM and to return data values to clients.
528 // Trait based GDM dispatch.
529 template <typename T>
530 const GRState* set(const GRState* st, typename GRStateTrait<T>::data_type D) {
531 return addGDM(st, GRStateTrait<T>::GDMIndex(),
532 GRStateTrait<T>::MakeVoidPtr(D));
535 template<typename T>
536 const GRState* set(const GRState* st,
537 typename GRStateTrait<T>::key_type K,
538 typename GRStateTrait<T>::value_type V,
539 typename GRStateTrait<T>::context_type C) {
541 return addGDM(st, GRStateTrait<T>::GDMIndex(),
542 GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Set(st->get<T>(), K, V, C)));
545 template <typename T>
546 const GRState* add(const GRState* st,
547 typename GRStateTrait<T>::key_type K,
548 typename GRStateTrait<T>::context_type C) {
549 return addGDM(st, GRStateTrait<T>::GDMIndex(),
550 GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Add(st->get<T>(), K, C)));
553 template <typename T>
554 const GRState* remove(const GRState* st,
555 typename GRStateTrait<T>::key_type K,
556 typename GRStateTrait<T>::context_type C) {
558 return addGDM(st, GRStateTrait<T>::GDMIndex(),
559 GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Remove(st->get<T>(), K, C)));
562 template <typename T>
563 const GRState *remove(const GRState *st) {
564 return removeGDM(st, GRStateTrait<T>::GDMIndex());
567 void* FindGDMContext(void* index,
568 void* (*CreateContext)(llvm::BumpPtrAllocator&),
569 void (*DeleteContext)(void*));
571 template <typename T>
572 typename GRStateTrait<T>::context_type get_context() {
573 void* p = FindGDMContext(GRStateTrait<T>::GDMIndex(),
574 GRStateTrait<T>::CreateContext,
575 GRStateTrait<T>::DeleteContext);
577 return GRStateTrait<T>::MakeContext(p);
580 const llvm::APSInt* getSymVal(const GRState* St, SymbolRef sym) {
581 return ConstraintMgr->getSymVal(St, sym);
584 void EndPath(const GRState* St) {
585 ConstraintMgr->EndPath(St);
590 //===----------------------------------------------------------------------===//
591 // Out-of-line method definitions for GRState.
592 //===----------------------------------------------------------------------===//
594 inline const llvm::APSInt *GRState::getSymVal(SymbolRef sym) {
595 return getStateManager().getSymVal(this, sym);
598 inline const VarRegion* GRState::getRegion(const VarDecl *D,
599 const LocationContext *LC) const {
600 return getStateManager().getRegionManager().getVarRegion(D, LC);
603 inline const GRState *GRState::assume(DefinedOrUnknownSVal Cond,
604 bool Assumption) const {
605 if (Cond.isUnknown())
606 return this;
608 return getStateManager().ConstraintMgr->assume(this, cast<DefinedSVal>(Cond),
609 Assumption);
612 inline std::pair<const GRState*, const GRState*>
613 GRState::assume(DefinedOrUnknownSVal Cond) const {
614 if (Cond.isUnknown())
615 return std::make_pair(this, this);
617 return getStateManager().ConstraintMgr->assumeDual(this,
618 cast<DefinedSVal>(Cond));
621 inline const GRState *GRState::bindLoc(SVal LV, SVal V) const {
622 return !isa<Loc>(LV) ? this : bindLoc(cast<Loc>(LV), V);
625 inline Loc GRState::getLValue(const VarDecl* VD,
626 const LocationContext *LC) const {
627 return getStateManager().StoreMgr->getLValueVar(VD, LC);
630 inline Loc GRState::getLValue(const StringLiteral *literal) const {
631 return getStateManager().StoreMgr->getLValueString(literal);
634 inline Loc GRState::getLValue(const CompoundLiteralExpr *literal,
635 const LocationContext *LC) const {
636 return getStateManager().StoreMgr->getLValueCompoundLiteral(literal, LC);
639 inline SVal GRState::getLValue(const ObjCIvarDecl *D, SVal Base) const {
640 return getStateManager().StoreMgr->getLValueIvar(D, Base);
643 inline SVal GRState::getLValue(const FieldDecl* D, SVal Base) const {
644 return getStateManager().StoreMgr->getLValueField(D, Base);
647 inline SVal GRState::getLValue(QualType ElementType, SVal Idx, SVal Base) const{
648 if (NonLoc *N = dyn_cast<NonLoc>(&Idx))
649 return getStateManager().StoreMgr->getLValueElement(ElementType, *N, Base);
650 return UnknownVal();
653 inline const llvm::APSInt *GRState::getSymVal(SymbolRef sym) const {
654 return getStateManager().getSymVal(this, sym);
657 inline SVal GRState::getSVal(const Stmt* Ex) const {
658 return Env.getSVal(Ex, *getStateManager().svalBuilder);
661 inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
662 if (const Expr *Ex = dyn_cast<Expr>(S)) {
663 QualType T = Ex->getType();
664 if (Loc::IsLocType(T) || T->isIntegerType())
665 return getSVal(S);
668 return UnknownVal();
671 inline SVal GRState::getRawSVal(Loc LV, QualType T) const {
672 return getStateManager().StoreMgr->Retrieve(St, LV, T);
675 inline SVal GRState::getSVal(const MemRegion* R) const {
676 return getStateManager().StoreMgr->Retrieve(St, loc::MemRegionVal(R));
679 inline BasicValueFactory &GRState::getBasicVals() const {
680 return getStateManager().getBasicVals();
683 inline SymbolManager &GRState::getSymbolManager() const {
684 return getStateManager().getSymbolManager();
687 template<typename T>
688 const GRState *GRState::add(typename GRStateTrait<T>::key_type K) const {
689 return getStateManager().add<T>(this, K, get_context<T>());
692 template <typename T>
693 typename GRStateTrait<T>::context_type GRState::get_context() const {
694 return getStateManager().get_context<T>();
697 template<typename T>
698 const GRState *GRState::remove(typename GRStateTrait<T>::key_type K) const {
699 return getStateManager().remove<T>(this, K, get_context<T>());
702 template<typename T>
703 const GRState *GRState::remove(typename GRStateTrait<T>::key_type K,
704 typename GRStateTrait<T>::context_type C) const {
705 return getStateManager().remove<T>(this, K, C);
708 template <typename T>
709 const GRState *GRState::remove() const {
710 return getStateManager().remove<T>(this);
713 template<typename T>
714 const GRState *GRState::set(typename GRStateTrait<T>::data_type D) const {
715 return getStateManager().set<T>(this, D);
718 template<typename T>
719 const GRState *GRState::set(typename GRStateTrait<T>::key_type K,
720 typename GRStateTrait<T>::value_type E) const {
721 return getStateManager().set<T>(this, K, E, get_context<T>());
724 template<typename T>
725 const GRState *GRState::set(typename GRStateTrait<T>::key_type K,
726 typename GRStateTrait<T>::value_type E,
727 typename GRStateTrait<T>::context_type C) const {
728 return getStateManager().set<T>(this, K, E, C);
731 template <typename CB>
732 CB GRState::scanReachableSymbols(SVal val) const {
733 CB cb(this);
734 scanReachableSymbols(val, cb);
735 return cb;
738 template <typename CB>
739 CB GRState::scanReachableSymbols(const SVal *beg, const SVal *end) const {
740 CB cb(this);
741 scanReachableSymbols(beg, end, cb);
742 return cb;
745 template <typename CB>
746 CB GRState::scanReachableSymbols(const MemRegion * const *beg,
747 const MemRegion * const *end) const {
748 CB cb(this);
749 scanReachableSymbols(beg, end, cb);
750 return cb;
752 } // end clang namespace
754 #endif