1 //= ProgramState.cpp - Path-Sensitive "State" for tracking values --*- C++ -*--=
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements ProgramState and ProgramStateManager.
12 //===----------------------------------------------------------------------===//
14 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
15 #include "clang/Analysis/CFG.h"
16 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
19 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
20 #include "llvm/Support/raw_ostream.h"
22 using namespace clang;
25 namespace clang { namespace ento {
26 /// Increments the number of times this state is referenced.
28 void ProgramStateRetain(const ProgramState *state) {
29 ++const_cast<ProgramState*>(state)->refCount;
32 /// Decrement the number of times this state is referenced.
33 void ProgramStateRelease(const ProgramState *state) {
34 assert(state->refCount > 0);
35 ProgramState *s = const_cast<ProgramState*>(state);
36 if (--s->refCount == 0) {
37 ProgramStateManager &Mgr = s->getStateManager();
38 Mgr.StateSet.RemoveNode(s);
40 Mgr.freeStates.push_back(s);
45 ProgramState::ProgramState(ProgramStateManager *mgr, const Environment& env,
46 StoreRef st, GenericDataMap gdm)
52 stateMgr->getStoreManager().incrementReferenceCount(store);
55 ProgramState::ProgramState(const ProgramState &RHS)
56 : llvm::FoldingSetNode(),
57 stateMgr(RHS.stateMgr),
62 stateMgr->getStoreManager().incrementReferenceCount(store);
65 ProgramState::~ProgramState() {
67 stateMgr->getStoreManager().decrementReferenceCount(store);
70 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
71 StoreManagerCreator CreateSMgr,
72 ConstraintManagerCreator CreateCMgr,
73 llvm::BumpPtrAllocator &alloc,
75 : Eng(SubEng), EnvMgr(alloc), GDMFactory(alloc),
76 svalBuilder(createSimpleSValBuilder(alloc, Ctx, *this)),
77 CallEventMgr(new CallEventManager(alloc)), Alloc(alloc) {
78 StoreMgr.reset((*CreateSMgr)(*this));
79 ConstraintMgr.reset((*CreateCMgr)(*this, SubEng));
83 ProgramStateManager::~ProgramStateManager() {
84 for (GDMContextsTy::iterator I=GDMContexts.begin(), E=GDMContexts.end();
86 I->second.second(I->second.first);
90 ProgramStateManager::removeDeadBindings(ProgramStateRef state,
91 const StackFrameContext *LCtx,
92 SymbolReaper& SymReaper) {
94 // This code essentially performs a "mark-and-sweep" of the VariableBindings.
95 // The roots are any Block-level exprs and Decls that our liveness algorithm
96 // tells us are live. We then see what Decls they may reference, and keep
97 // those around. This code more than likely can be made faster, and the
98 // frequency of which this method is called should be experimented with
99 // for optimum performance.
100 ProgramState NewState = *state;
102 NewState.Env = EnvMgr.removeDeadBindings(NewState.Env, SymReaper, state);
104 // Clean up the store.
105 StoreRef newStore = StoreMgr->removeDeadBindings(NewState.getStore(), LCtx,
107 NewState.setStore(newStore);
108 SymReaper.setReapedStore(newStore);
110 ProgramStateRef Result = getPersistentState(NewState);
111 return ConstraintMgr->removeDeadBindings(Result, SymReaper);
114 ProgramStateRef ProgramState::bindLoc(Loc LV, SVal V, bool notifyChanges) const {
115 ProgramStateManager &Mgr = getStateManager();
116 ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(),
118 const MemRegion *MR = LV.getAsRegion();
119 if (MR && Mgr.getOwningEngine() && notifyChanges)
120 return Mgr.getOwningEngine()->processRegionChange(newState, MR);
125 ProgramStateRef ProgramState::bindDefault(SVal loc, SVal V) const {
126 ProgramStateManager &Mgr = getStateManager();
127 const MemRegion *R = loc.castAs<loc::MemRegionVal>().getRegion();
128 const StoreRef &newStore = Mgr.StoreMgr->BindDefault(getStore(), R, V);
129 ProgramStateRef new_state = makeWithStore(newStore);
130 return Mgr.getOwningEngine() ?
131 Mgr.getOwningEngine()->processRegionChange(new_state, R) :
135 typedef ArrayRef<const MemRegion *> RegionList;
136 typedef ArrayRef<SVal> ValueList;
139 ProgramState::invalidateRegions(RegionList Regions,
140 const Expr *E, unsigned Count,
141 const LocationContext *LCtx,
142 bool CausedByPointerEscape,
143 InvalidatedSymbols *IS,
144 const CallEvent *Call,
145 RegionAndSymbolInvalidationTraits *ITraits) const {
146 SmallVector<SVal, 8> Values;
147 for (RegionList::const_iterator I = Regions.begin(),
148 End = Regions.end(); I != End; ++I)
149 Values.push_back(loc::MemRegionVal(*I));
151 return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
156 ProgramState::invalidateRegions(ValueList Values,
157 const Expr *E, unsigned Count,
158 const LocationContext *LCtx,
159 bool CausedByPointerEscape,
160 InvalidatedSymbols *IS,
161 const CallEvent *Call,
162 RegionAndSymbolInvalidationTraits *ITraits) const {
164 return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
169 ProgramState::invalidateRegionsImpl(ValueList Values,
170 const Expr *E, unsigned Count,
171 const LocationContext *LCtx,
172 bool CausedByPointerEscape,
173 InvalidatedSymbols *IS,
174 RegionAndSymbolInvalidationTraits *ITraits,
175 const CallEvent *Call) const {
176 ProgramStateManager &Mgr = getStateManager();
177 SubEngine* Eng = Mgr.getOwningEngine();
178 InvalidatedSymbols ConstIS;
180 InvalidatedSymbols Invalidated;
184 RegionAndSymbolInvalidationTraits ITraitsLocal;
186 ITraits = &ITraitsLocal;
189 StoreManager::InvalidatedRegions TopLevelInvalidated;
190 StoreManager::InvalidatedRegions Invalidated;
191 const StoreRef &newStore
192 = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call,
193 *IS, *ITraits, &TopLevelInvalidated,
196 ProgramStateRef newState = makeWithStore(newStore);
198 if (CausedByPointerEscape) {
199 newState = Eng->notifyCheckersOfPointerEscape(newState, IS,
205 return Eng->processRegionChanges(newState, IS, TopLevelInvalidated,
209 const StoreRef &newStore =
210 Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call,
211 *IS, *ITraits, NULL, NULL);
212 return makeWithStore(newStore);
215 ProgramStateRef ProgramState::killBinding(Loc LV) const {
216 assert(!LV.getAs<loc::MemRegionVal>() && "Use invalidateRegion instead.");
218 Store OldStore = getStore();
219 const StoreRef &newStore =
220 getStateManager().StoreMgr->killBinding(OldStore, LV);
222 if (newStore.getStore() == OldStore)
225 return makeWithStore(newStore);
229 ProgramState::enterStackFrame(const CallEvent &Call,
230 const StackFrameContext *CalleeCtx) const {
231 const StoreRef &NewStore =
232 getStateManager().StoreMgr->enterStackFrame(getStore(), Call, CalleeCtx);
233 return makeWithStore(NewStore);
236 SVal ProgramState::getSValAsScalarOrLoc(const MemRegion *R) const {
237 // We only want to do fetches from regions that we can actually bind
238 // values. For example, SymbolicRegions of type 'id<...>' cannot
239 // have direct bindings (but their can be bindings on their subregions).
240 if (!R->isBoundable())
243 if (const TypedValueRegion *TR = dyn_cast<TypedValueRegion>(R)) {
244 QualType T = TR->getValueType();
245 if (Loc::isLocType(T) || T->isIntegralOrEnumerationType())
252 SVal ProgramState::getSVal(Loc location, QualType T) const {
253 SVal V = getRawSVal(cast<Loc>(location), T);
255 // If 'V' is a symbolic value that is *perfectly* constrained to
256 // be a constant value, use that value instead to lessen the burden
257 // on later analysis stages (so we have less symbolic values to reason
260 if (SymbolRef sym = V.getAsSymbol()) {
261 if (const llvm::APSInt *Int = getStateManager()
262 .getConstraintManager()
263 .getSymVal(this, sym)) {
264 // FIXME: Because we don't correctly model (yet) sign-extension
265 // and truncation of symbolic values, we need to convert
266 // the integer value to the correct signedness and bitwidth.
268 // This shows up in the following:
271 // unsigned x = foo();
275 // The symbolic value stored to 'x' is actually the conjured
276 // symbol for the call to foo(); the type of that symbol is 'char',
278 const llvm::APSInt &NewV = getBasicVals().Convert(T, *Int);
281 return loc::ConcreteInt(NewV);
283 return nonloc::ConcreteInt(NewV);
291 ProgramStateRef ProgramState::BindExpr(const Stmt *S,
292 const LocationContext *LCtx,
293 SVal V, bool Invalidate) const{
295 getStateManager().EnvMgr.bindExpr(Env, EnvironmentEntry(S, LCtx), V,
300 ProgramState NewSt = *this;
302 return getStateManager().getPersistentState(NewSt);
305 ProgramStateRef ProgramState::assumeInBound(DefinedOrUnknownSVal Idx,
306 DefinedOrUnknownSVal UpperBound,
308 QualType indexTy) const {
309 if (Idx.isUnknown() || UpperBound.isUnknown())
312 // Build an expression for 0 <= Idx < UpperBound.
313 // This is the same as Idx + MIN < UpperBound + MIN, if overflow is allowed.
314 // FIXME: This should probably be part of SValBuilder.
315 ProgramStateManager &SM = getStateManager();
316 SValBuilder &svalBuilder = SM.getSValBuilder();
317 ASTContext &Ctx = svalBuilder.getContext();
319 // Get the offset: the minimum value of the array index type.
320 BasicValueFactory &BVF = svalBuilder.getBasicValueFactory();
321 // FIXME: This should be using ValueManager::ArrayindexTy...somehow.
322 if (indexTy.isNull())
324 nonloc::ConcreteInt Min(BVF.getMinValue(indexTy));
327 SVal newIdx = svalBuilder.evalBinOpNN(this, BO_Add,
328 Idx.castAs<NonLoc>(), Min, indexTy);
329 if (newIdx.isUnknownOrUndef())
332 // Adjust the upper bound.
334 svalBuilder.evalBinOpNN(this, BO_Add, UpperBound.castAs<NonLoc>(),
337 if (newBound.isUnknownOrUndef())
340 // Build the actual comparison.
341 SVal inBound = svalBuilder.evalBinOpNN(this, BO_LT, newIdx.castAs<NonLoc>(),
342 newBound.castAs<NonLoc>(), Ctx.IntTy);
343 if (inBound.isUnknownOrUndef())
346 // Finally, let the constraint manager take care of it.
347 ConstraintManager &CM = SM.getConstraintManager();
348 return CM.assume(this, inBound.castAs<DefinedSVal>(), Assumption);
351 ConditionTruthVal ProgramState::isNull(SVal V) const {
352 if (V.isZeroConstant())
358 SymbolRef Sym = V.getAsSymbol(/* IncludeBaseRegion */ true);
360 return ConditionTruthVal();
362 return getStateManager().ConstraintMgr->isNull(this, Sym);
365 ProgramStateRef ProgramStateManager::getInitialState(const LocationContext *InitLoc) {
366 ProgramState State(this,
367 EnvMgr.getInitialEnvironment(),
368 StoreMgr->getInitialStore(InitLoc),
369 GDMFactory.getEmptyMap());
371 return getPersistentState(State);
374 ProgramStateRef ProgramStateManager::getPersistentStateWithGDM(
375 ProgramStateRef FromState,
376 ProgramStateRef GDMState) {
377 ProgramState NewState(*FromState);
378 NewState.GDM = GDMState->GDM;
379 return getPersistentState(NewState);
382 ProgramStateRef ProgramStateManager::getPersistentState(ProgramState &State) {
384 llvm::FoldingSetNodeID ID;
388 if (ProgramState *I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
391 ProgramState *newState = 0;
392 if (!freeStates.empty()) {
393 newState = freeStates.back();
394 freeStates.pop_back();
397 newState = (ProgramState*) Alloc.Allocate<ProgramState>();
399 new (newState) ProgramState(State);
400 StateSet.InsertNode(newState, InsertPos);
404 ProgramStateRef ProgramState::makeWithStore(const StoreRef &store) const {
405 ProgramState NewSt(*this);
406 NewSt.setStore(store);
407 return getStateManager().getPersistentState(NewSt);
410 void ProgramState::setStore(const StoreRef &newStore) {
411 Store newStoreStore = newStore.getStore();
413 stateMgr->getStoreManager().incrementReferenceCount(newStoreStore);
415 stateMgr->getStoreManager().decrementReferenceCount(store);
416 store = newStoreStore;
419 //===----------------------------------------------------------------------===//
420 // State pretty-printing.
421 //===----------------------------------------------------------------------===//
423 void ProgramState::print(raw_ostream &Out,
424 const char *NL, const char *Sep) const {
426 ProgramStateManager &Mgr = getStateManager();
427 Mgr.getStoreManager().print(getStore(), Out, NL, Sep);
429 // Print out the environment.
430 Env.print(Out, NL, Sep);
432 // Print out the constraints.
433 Mgr.getConstraintManager().print(this, Out, NL, Sep);
435 // Print checker-specific data.
436 Mgr.getOwningEngine()->printState(Out, this, NL, Sep);
439 void ProgramState::printDOT(raw_ostream &Out) const {
440 print(Out, "\\l", "\\|");
443 void ProgramState::dump() const {
447 void ProgramState::printTaint(raw_ostream &Out,
448 const char *NL, const char *Sep) const {
449 TaintMapImpl TM = get<TaintMap>();
452 Out <<"Tainted Symbols:" << NL;
454 for (TaintMapImpl::iterator I = TM.begin(), E = TM.end(); I != E; ++I) {
455 Out << I->first << " : " << I->second << NL;
459 void ProgramState::dumpTaint() const {
460 printTaint(llvm::errs());
463 //===----------------------------------------------------------------------===//
465 //===----------------------------------------------------------------------===//
467 void *const* ProgramState::FindGDM(void *K) const {
468 return GDM.lookup(K);
472 ProgramStateManager::FindGDMContext(void *K,
473 void *(*CreateContext)(llvm::BumpPtrAllocator&),
474 void (*DeleteContext)(void*)) {
476 std::pair<void*, void (*)(void*)>& p = GDMContexts[K];
478 p.first = CreateContext(Alloc);
479 p.second = DeleteContext;
485 ProgramStateRef ProgramStateManager::addGDM(ProgramStateRef St, void *Key, void *Data){
486 ProgramState::GenericDataMap M1 = St->getGDM();
487 ProgramState::GenericDataMap M2 = GDMFactory.add(M1, Key, Data);
492 ProgramState NewSt = *St;
494 return getPersistentState(NewSt);
497 ProgramStateRef ProgramStateManager::removeGDM(ProgramStateRef state, void *Key) {
498 ProgramState::GenericDataMap OldM = state->getGDM();
499 ProgramState::GenericDataMap NewM = GDMFactory.remove(OldM, Key);
504 ProgramState NewState = *state;
506 return getPersistentState(NewState);
509 bool ScanReachableSymbols::scan(nonloc::LazyCompoundVal val) {
510 bool wasVisited = !visited.insert(val.getCVData()).second;
514 StoreManager &StoreMgr = state->getStateManager().getStoreManager();
515 // FIXME: We don't really want to use getBaseRegion() here because pointer
516 // arithmetic doesn't apply, but scanReachableSymbols only accepts base
517 // regions right now.
518 const MemRegion *R = val.getRegion()->getBaseRegion();
519 return StoreMgr.scanReachableSymbols(val.getStore(), R, *this);
522 bool ScanReachableSymbols::scan(nonloc::CompoundVal val) {
523 for (nonloc::CompoundVal::iterator I=val.begin(), E=val.end(); I!=E; ++I)
530 bool ScanReachableSymbols::scan(const SymExpr *sym) {
531 bool wasVisited = !visited.insert(sym).second;
535 if (!visitor.VisitSymbol(sym))
538 // TODO: should be rewritten using SymExpr::symbol_iterator.
539 switch (sym->getKind()) {
540 case SymExpr::RegionValueKind:
541 case SymExpr::ConjuredKind:
542 case SymExpr::DerivedKind:
543 case SymExpr::ExtentKind:
544 case SymExpr::MetadataKind:
546 case SymExpr::CastSymbolKind:
547 return scan(cast<SymbolCast>(sym)->getOperand());
548 case SymExpr::SymIntKind:
549 return scan(cast<SymIntExpr>(sym)->getLHS());
550 case SymExpr::IntSymKind:
551 return scan(cast<IntSymExpr>(sym)->getRHS());
552 case SymExpr::SymSymKind: {
553 const SymSymExpr *x = cast<SymSymExpr>(sym);
554 return scan(x->getLHS()) && scan(x->getRHS());
560 bool ScanReachableSymbols::scan(SVal val) {
561 if (Optional<loc::MemRegionVal> X = val.getAs<loc::MemRegionVal>())
562 return scan(X->getRegion());
564 if (Optional<nonloc::LazyCompoundVal> X =
565 val.getAs<nonloc::LazyCompoundVal>())
568 if (Optional<nonloc::LocAsInteger> X = val.getAs<nonloc::LocAsInteger>())
569 return scan(X->getLoc());
571 if (SymbolRef Sym = val.getAsSymbol())
574 if (const SymExpr *Sym = val.getAsSymbolicExpression())
577 if (Optional<nonloc::CompoundVal> X = val.getAs<nonloc::CompoundVal>())
583 bool ScanReachableSymbols::scan(const MemRegion *R) {
584 if (isa<MemSpaceRegion>(R))
587 bool wasVisited = !visited.insert(R).second;
591 if (!visitor.VisitMemRegion(R))
594 // If this is a symbolic region, visit the symbol for the region.
595 if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R))
596 if (!visitor.VisitSymbol(SR->getSymbol()))
599 // If this is a subregion, also visit the parent regions.
600 if (const SubRegion *SR = dyn_cast<SubRegion>(R)) {
601 const MemRegion *Super = SR->getSuperRegion();
605 // When we reach the topmost region, scan all symbols in it.
606 if (isa<MemSpaceRegion>(Super)) {
607 StoreManager &StoreMgr = state->getStateManager().getStoreManager();
608 if (!StoreMgr.scanReachableSymbols(state->getStore(), SR, *this))
613 // Regions captured by a block are also implicitly reachable.
614 if (const BlockDataRegion *BDR = dyn_cast<BlockDataRegion>(R)) {
615 BlockDataRegion::referenced_vars_iterator I = BDR->referenced_vars_begin(),
616 E = BDR->referenced_vars_end();
617 for ( ; I != E; ++I) {
618 if (!scan(I.getCapturedRegion()))
626 bool ProgramState::scanReachableSymbols(SVal val, SymbolVisitor& visitor) const {
627 ScanReachableSymbols S(this, visitor);
631 bool ProgramState::scanReachableSymbols(const SVal *I, const SVal *E,
632 SymbolVisitor &visitor) const {
633 ScanReachableSymbols S(this, visitor);
634 for ( ; I != E; ++I) {
641 bool ProgramState::scanReachableSymbols(const MemRegion * const *I,
642 const MemRegion * const *E,
643 SymbolVisitor &visitor) const {
644 ScanReachableSymbols S(this, visitor);
645 for ( ; I != E; ++I) {
652 ProgramStateRef ProgramState::addTaint(const Stmt *S,
653 const LocationContext *LCtx,
654 TaintTagType Kind) const {
655 if (const Expr *E = dyn_cast_or_null<Expr>(S))
656 S = E->IgnoreParens();
658 SymbolRef Sym = getSVal(S, LCtx).getAsSymbol();
660 return addTaint(Sym, Kind);
662 const MemRegion *R = getSVal(S, LCtx).getAsRegion();
665 // Cannot add taint, so just return the state.
669 ProgramStateRef ProgramState::addTaint(const MemRegion *R,
670 TaintTagType Kind) const {
671 if (const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
672 return addTaint(SR->getSymbol(), Kind);
676 ProgramStateRef ProgramState::addTaint(SymbolRef Sym,
677 TaintTagType Kind) const {
678 // If this is a symbol cast, remove the cast before adding the taint. Taint
680 while (const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
681 Sym = SC->getOperand();
683 ProgramStateRef NewState = set<TaintMap>(Sym, Kind);
688 bool ProgramState::isTainted(const Stmt *S, const LocationContext *LCtx,
689 TaintTagType Kind) const {
690 if (const Expr *E = dyn_cast_or_null<Expr>(S))
691 S = E->IgnoreParens();
693 SVal val = getSVal(S, LCtx);
694 return isTainted(val, Kind);
697 bool ProgramState::isTainted(SVal V, TaintTagType Kind) const {
698 if (const SymExpr *Sym = V.getAsSymExpr())
699 return isTainted(Sym, Kind);
700 if (const MemRegion *Reg = V.getAsRegion())
701 return isTainted(Reg, Kind);
705 bool ProgramState::isTainted(const MemRegion *Reg, TaintTagType K) const {
709 // Element region (array element) is tainted if either the base or the offset
711 if (const ElementRegion *ER = dyn_cast<ElementRegion>(Reg))
712 return isTainted(ER->getSuperRegion(), K) || isTainted(ER->getIndex(), K);
714 if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg))
715 return isTainted(SR->getSymbol(), K);
717 if (const SubRegion *ER = dyn_cast<SubRegion>(Reg))
718 return isTainted(ER->getSuperRegion(), K);
723 bool ProgramState::isTainted(SymbolRef Sym, TaintTagType Kind) const {
727 // Traverse all the symbols this symbol depends on to see if any are tainted.
728 bool Tainted = false;
729 for (SymExpr::symbol_iterator SI = Sym->symbol_begin(), SE =Sym->symbol_end();
731 if (!isa<SymbolData>(*SI))
734 const TaintTagType *Tag = get<TaintMap>(*SI);
735 Tainted = (Tag && *Tag == Kind);
737 // If this is a SymbolDerived with a tainted parent, it's also tainted.
738 if (const SymbolDerived *SD = dyn_cast<SymbolDerived>(*SI))
739 Tainted = Tainted || isTainted(SD->getParentSymbol(), Kind);
741 // If memory region is tainted, data is also tainted.
742 if (const SymbolRegionValue *SRV = dyn_cast<SymbolRegionValue>(*SI))
743 Tainted = Tainted || isTainted(SRV->getRegion(), Kind);
745 // If If this is a SymbolCast from a tainted value, it's also tainted.
746 if (const SymbolCast *SC = dyn_cast<SymbolCast>(*SI))
747 Tainted = Tainted || isTainted(SC->getOperand(), Kind);
756 /// The GDM component containing the dynamic type info. This is a map from a
757 /// symbol to its most likely type.
758 REGISTER_TRAIT_WITH_PROGRAMSTATE(DynamicTypeMap,
759 CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *,
762 DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
763 Reg = Reg->StripCasts();
765 // Look up the dynamic type in the GDM.
766 const DynamicTypeInfo *GDMType = get<DynamicTypeMap>(Reg);
770 // Otherwise, fall back to what we know about the region.
771 if (const TypedRegion *TR = dyn_cast<TypedRegion>(Reg))
772 return DynamicTypeInfo(TR->getLocationType(), /*CanBeSubclass=*/false);
774 if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) {
775 SymbolRef Sym = SR->getSymbol();
776 return DynamicTypeInfo(Sym->getType());
779 return DynamicTypeInfo();
782 ProgramStateRef ProgramState::setDynamicTypeInfo(const MemRegion *Reg,
783 DynamicTypeInfo NewTy) const {
784 Reg = Reg->StripCasts();
785 ProgramStateRef NewState = set<DynamicTypeMap>(Reg, NewTy);