SVal GetLValue(const GRState* St, const VarDecl* D) {
return StoreMgr->getLValueVar(St, D);
}
+
+ // Get the lvalue for a StringLiteral.
+ SVal GetLValue(const GRState* St, const StringLiteral* E) {
+ return StoreMgr->getLValueString(St, E);
+ }
// Get the lvalue for an ivar reference.
SVal GetLValue(const GRState* St, const ObjCIvarDecl* D, SVal Base) {
virtual Store getInitialStore() = 0;
virtual MemRegionManager& getRegionManager() = 0;
- virtual SVal getLValueVar(const GRState* St, const VarDecl* VD) = 0;
+ virtual SVal getLValueVar(const GRState* St, const VarDecl* VD) = 0;
+
+ virtual SVal getLValueString(const GRState* St, const StringLiteral* S) = 0;
virtual SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
SVal Base) = 0;
}
SVal getLValueVar(const GRState* St, const VarDecl* VD);
+ SVal getLValueString(const GRState* St, const StringLiteral* S);
SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);
SVal getLValueElement(const GRState* St, SVal Base, SVal Offset);
SVal BasicStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
return loc::MemRegionVal(MRMgr.getVarRegion(VD));
}
+
+SVal BasicStoreManager::getLValueString(const GRState* St,
+ const StringLiteral* S) {
+ return loc::MemRegionVal(MRMgr.getStringRegion(S));
+}
SVal BasicStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
SVal Base) {
return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(E));
}
- case Stmt::StringLiteralClass:
- return Loc::MakeVal(cast<StringLiteral>(E));
-
- // Casts where the source and target type are the same
- // are no-ops. We blast through these to get the descendant
- // subexpression that has a value.
-
+ // Casts where the source and target type are the same
+ // are no-ops. We blast through these to get the descendant
+ // subexpression that has a value.
+
case Stmt::ImplicitCastExprClass:
case Stmt::ExplicitCastExprClass: {
CastExpr* C = cast<CastExpr>(E);
// have "locations" in the sense that we can take their address.
Dst.Add(Pred);
return;
+
+ case Stmt::StringLiteralClass: {
+ const GRState* St = GetState(Pred);
+ SVal V = StateMgr.GetLValue(St, cast<StringLiteral>(Ex));
+ MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V));
+ return;
+ }
default:
// Arbitrary subexpressions can return aggregate temporaries that
return Retrieve(St, loc::MemRegionVal(R));
}
+ SVal getLValueString(const GRState* St, const StringLiteral* S);
+
SVal getLValueVar(const GRState* St, const VarDecl* VD);
SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
return new RegionStoreManager(StMgr);
}
+SVal RegionStoreManager::getLValueString(const GRState* St,
+ const StringLiteral* S) {
+ return loc::MemRegionVal(MRMgr.getStringRegion(S));
+}
+
SVal RegionStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
return loc::MemRegionVal(MRMgr.getVarRegion(VD));
}
SVal RegionStoreManager::ArrayToPointer(SVal Array) {
const MemRegion* ArrayR = cast<loc::MemRegionVal>(&Array)->getRegion();
+ BasicValueFactory& BasicVals = StateMgr.getBasicVals();
+
+ if (const StringRegion* StringR = dyn_cast<StringRegion>(ArrayR)) {
+ // FIXME: Find a better way to get bit width.
+ nonloc::ConcreteInt Idx(BasicVals.getValue(0, 32, false));
+ ElementRegion* ER = MRMgr.getElementRegion(Idx, ArrayR);
+
+ return loc::MemRegionVal(ER);
+ }
const Decl* D = cast<DeclRegion>(ArrayR)->getDecl();
if (const ConstantArrayType* CAT =
dyn_cast<ConstantArrayType>(ArrayTy.getTypePtr())) {
-
- BasicValueFactory& BasicVals = StateMgr.getBasicVals();
nonloc::ConcreteInt Idx(BasicVals.getValue(0, CAT->getSize().getBitWidth(),
false));
-
ElementRegion* ER = MRMgr.getElementRegion(Idx, ArrayR);
return loc::MemRegionVal(ER);