21#include "llvm/Support/raw_ostream.h"
27namespace clang {
namespace ento {
36 assert(state->refCount > 0);
38 if (--
s->refCount == 0) {
40 Mgr.StateSet.RemoveNode(
s);
42 Mgr.freeStates.push_back(
s);
58 : stateMgr(RHS.stateMgr),
Env(RHS.
Env), store(RHS.store), GDM(RHS.GDM),
59 PosteriorlyOverconstrained(RHS.PosteriorlyOverconstrained), refCount(0) {
75 llvm::BumpPtrAllocator &alloc,
77 : Eng(ExprEng), EnvMgr(alloc), GDMFactory(alloc),
80 StoreMgr = (*CreateSMgr)(*this);
81 ConstraintMgr = (*CreateCMgr)(*
this, ExprEng);
86 for (GDMContextsTy::iterator I=GDMContexts.begin(),
E=GDMContexts.end();
88 I->second.second(I->second.first);
108 NewState.setStore(newStore);
117 bool notifyChanges)
const {
122 if (MR && notifyChanges)
174 IS = &InvalidatedSyms;
178 ITraits = &ITraitsLocal;
182 const StoreRef &NewStore = Mgr.StoreMgr->invalidateRegions(
183 getStore(), Values, S, Count, LCtx,
Call, *IS, *ITraits,
184 &TopLevelInvalidated, &Invalidated);
188 if (CausedByPointerEscape) {
190 NewState, IS, TopLevelInvalidated,
Call, *ITraits);
194 Invalidated, LCtx,
Call);
202 if (newStore.
getStore() == OldStore)
205 return makeWithStore(newStore);
211SVal ProgramState::desugarReference(
SVal Val)
const {
212 const auto *TyReg = dyn_cast_or_null<TypedValueRegion>(Val.
getAsRegion());
213 if (!TyReg || !TyReg->getValueType()->isReferenceType())
222SVal ProgramState::wrapSymbolicRegion(
SVal Val)
const {
223 const auto *BaseReg = dyn_cast_or_null<SymbolicRegion>(Val.
getAsRegion());
228 QualType ElemTy = BaseReg->getPointeeStaticType();
237 return makeWithStore(NewStore);
276 .getSymVal(
this, sym)) {
304 SVal V,
bool Invalidate)
const{
316[[nodiscard]] std::pair<ProgramStateRef, ProgramStateRef>
365 std::pair<ProgramStateRef, ProgramStateRef> R =
367 return Assumption ? R.first : R.second;
372 if (
IsNull.isUnderconstrained())
382 if (
V.isZeroConstant())
398 StoreMgr->getInitialStore(InitLoc),
399 GDMFactory.getEmptyMap());
408 NewState.GDM = GDMState->GDM;
414 llvm::FoldingSetNodeID ID;
418 if (
ProgramState *I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
422 if (!freeStates.empty()) {
423 newState = freeStates.back();
424 freeStates.pop_back();
430 StateSet.InsertNode(newState, InsertPos);
436 NewSt.setStore(store);
440ProgramStateRef ProgramState::cloneAsPosteriorlyOverconstrained()
const {
442 NewSt.PosteriorlyOverconstrained =
true;
446void ProgramState::setStore(
const StoreRef &newStore) {
452 store = newStoreStore;
469 for (
const auto *I :
D->chain()) {
470 Base =
SM.getLValueField(cast<FieldDecl>(I),
Base);
480 const char *NL,
unsigned int Space,
482 Indent(Out, Space, IsDot) <<
"\"program_state\": {" << NL;