From: Zhongxing Xu Date: Mon, 8 Feb 2010 09:30:02 +0000 (+0000) Subject: Rename: GRState::getSVal(Stmt*) => getExprVal(), X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f8c430a95279ef048a356d6283871477b4ad351;p=clang Rename: GRState::getSVal(Stmt*) => getExprVal(), GRState::getSVal(MemRegion*) => Load(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Checker/PathSensitive/GRState.h b/include/clang/Checker/PathSensitive/GRState.h index 4e44697a27..9e4ed02d5a 100644 --- a/include/clang/Checker/PathSensitive/GRState.h +++ b/include/clang/Checker/PathSensitive/GRState.h @@ -252,15 +252,15 @@ public: const llvm::APSInt *getSymVal(SymbolRef sym) const; - SVal getSVal(const Stmt* Ex) const; + SVal getExprVal(const Stmt* Ex) const; - SVal getSValAsScalarOrLoc(const Stmt *Ex) const; + SVal getExprValAsScalarOrLoc(const Stmt *Ex) const; - SVal getSVal(Loc LV, QualType T = QualType()) const; + SVal Load(Loc LV, QualType T = QualType()) const; - SVal getSVal(const MemRegion* R) const; + SVal Load(const MemRegion* R) const; - SVal getSValAsScalarOrLoc(const MemRegion *R) const; + SVal LoadAsScalarOrLoc(const MemRegion *R) const; const llvm::APSInt *getSymVal(SymbolRef sym); @@ -661,25 +661,25 @@ inline const llvm::APSInt *GRState::getSymVal(SymbolRef sym) const { return getStateManager().getSymVal(this, sym); } -inline SVal GRState::getSVal(const Stmt* Ex) const { +inline SVal GRState::getExprVal(const Stmt* Ex) const { return Env.GetSVal(Ex, getStateManager().ValueMgr); } -inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const { +inline SVal GRState::getExprValAsScalarOrLoc(const Stmt *S) const { if (const Expr *Ex = dyn_cast(S)) { QualType T = Ex->getType(); if (Loc::IsLocType(T) || T->isIntegerType()) - return getSVal(S); + return getExprVal(S); } return UnknownVal(); } -inline SVal GRState::getSVal(Loc LV, QualType T) const { +inline SVal GRState::Load(Loc LV, QualType T) const { return getStateManager().StoreMgr->Retrieve(St, LV, T); } -inline SVal GRState::getSVal(const MemRegion* R) const { +inline SVal GRState::Load(const MemRegion* R) const { return getStateManager().StoreMgr->Retrieve(St, loc::MemRegionVal(R)); } diff --git a/lib/Checker/AdjustedReturnValueChecker.cpp b/lib/Checker/AdjustedReturnValueChecker.cpp index e95a86b838..3abaa5f33f 100644 --- a/lib/Checker/AdjustedReturnValueChecker.cpp +++ b/lib/Checker/AdjustedReturnValueChecker.cpp @@ -49,7 +49,7 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, // Fetch the signature of the called function. const GRState *state = C.getState(); - SVal V = state->getSVal(CE); + SVal V = state->getExprVal(CE); if (V.isUnknown()) return; @@ -60,7 +60,7 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, return; } - const MemRegion *callee = state->getSVal(CE->getCallee()).getAsRegion(); + const MemRegion *callee = state->getExprVal(CE->getCallee()).getAsRegion(); if (!callee) return; diff --git a/lib/Checker/AttrNonNullChecker.cpp b/lib/Checker/AttrNonNullChecker.cpp index 83dc13e92b..496c67c9ec 100644 --- a/lib/Checker/AttrNonNullChecker.cpp +++ b/lib/Checker/AttrNonNullChecker.cpp @@ -41,7 +41,7 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C, const GRState *state = C.getState(); // Check if the callee has a 'nonnull' attribute. - SVal X = state->getSVal(CE->getCallee()); + SVal X = state->getExprVal(CE->getCallee()); const FunctionDecl* FD = X.getAsFunctionDecl(); if (!FD) @@ -60,7 +60,7 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C, if (!Att->isNonNull(idx)) continue; - const SVal &V = state->getSVal(*I); + const SVal &V = state->getExprVal(*I); const DefinedSVal *DV = dyn_cast(&V); if (!DV) diff --git a/lib/Checker/BasicObjCFoundationChecks.cpp b/lib/Checker/BasicObjCFoundationChecks.cpp index b1ecfeb144..42cfb1e545 100644 --- a/lib/Checker/BasicObjCFoundationChecks.cpp +++ b/lib/Checker/BasicObjCFoundationChecks.cpp @@ -135,7 +135,7 @@ bool BasicObjCFoundationChecks::CheckNilArg(ExplodedNode* N, unsigned Arg) { const Expr * E = ME->getArg(Arg); - if (isNil(N->getState()->getSVal(E))) { + if (isNil(N->getState()->getExprVal(E))) { WarnNilArg(N, ME, Arg); return true; } @@ -349,14 +349,14 @@ bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){ const CallExpr* CE = cast(cast(N->getLocation()).getStmt()); const Expr* Callee = CE->getCallee(); - SVal CallV = N->getState()->getSVal(Callee); + SVal CallV = N->getState()->getExprVal(Callee); const FunctionDecl* FD = CallV.getAsFunctionDecl(); if (!FD || FD->getIdentifier() != II || CE->getNumArgs()!=3) return false; // Get the value of the "theType" argument. - SVal TheTypeVal = N->getState()->getSVal(CE->getArg(1)); + SVal TheTypeVal = N->getState()->getExprVal(CE->getArg(1)); // FIXME: We really should allow ranges of valid theType values, and // bifurcate the state appropriately. @@ -375,7 +375,7 @@ bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){ // Look at the value of the integer being passed by reference. Essentially // we want to catch cases where the value passed in is not equal to the // size of the type being created. - SVal TheValueExpr = N->getState()->getSVal(CE->getArg(2)); + SVal TheValueExpr = N->getState()->getExprVal(CE->getArg(2)); // FIXME: Eventually we should handle arbitrary locations. We can do this // by having an enhanced memory model that does low-level typing. @@ -482,7 +482,7 @@ bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) { // Check if we called CFRetain/CFRelease. const GRState* state = N->getState(); - SVal X = state->getSVal(CE->getCallee()); + SVal X = state->getExprVal(CE->getCallee()); const FunctionDecl* FD = X.getAsFunctionDecl(); if (!FD) diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp index 0cf593b260..34d05f995b 100644 --- a/lib/Checker/BugReporter.cpp +++ b/lib/Checker/BugReporter.cpp @@ -350,7 +350,7 @@ GetMostRecentVarDeclBinding(const ExplodedNode* N, if (!DR) continue; - SVal Y = N->getState()->getSVal(DR); + SVal Y = N->getState()->getExprVal(DR); if (X != Y) continue; @@ -394,7 +394,7 @@ public: return true; // Check if the previous state has this binding. - SVal X = PrevSt->getSVal(loc::MemRegionVal(R)); + SVal X = PrevSt->Load(loc::MemRegionVal(R)); if (X == V) // Same binding? return true; diff --git a/lib/Checker/BugReporterVisitors.cpp b/lib/Checker/BugReporterVisitors.cpp index b8f657b31b..31a2e658e9 100644 --- a/lib/Checker/BugReporterVisitors.cpp +++ b/lib/Checker/BugReporterVisitors.cpp @@ -113,7 +113,7 @@ public: } } - if (Node->getState()->getSVal(R) != V) + if (Node->getState()->Load(R) != V) break; } @@ -319,7 +319,7 @@ void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC, StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext()); // What did we load? - SVal V = state->getSVal(S); + SVal V = state->getExprVal(S); if (isa(V) || isa(V) || V.isUndef()) { @@ -328,7 +328,7 @@ void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC, } } - SVal V = state->getSValAsScalarOrLoc(S); + SVal V = state->getExprValAsScalarOrLoc(S); // Uncomment this to find cases where we aren't properly getting the // base value that was dereferenced. diff --git a/lib/Checker/BuiltinFunctionChecker.cpp b/lib/Checker/BuiltinFunctionChecker.cpp index 8711492049..9739b3d9ad 100644 --- a/lib/Checker/BuiltinFunctionChecker.cpp +++ b/lib/Checker/BuiltinFunctionChecker.cpp @@ -35,7 +35,7 @@ void clang::RegisterBuiltinFunctionChecker(GRExprEngine &Eng) { bool BuiltinFunctionChecker::EvalCallExpr(CheckerContext &C,const CallExpr *CE){ const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); const FunctionDecl *FD = L.getAsFunctionDecl(); if (!FD) @@ -50,7 +50,7 @@ bool BuiltinFunctionChecker::EvalCallExpr(CheckerContext &C,const CallExpr *CE){ case Builtin::BI__builtin_expect: { // For __builtin_expect, just return the value of the subexpression. assert (CE->arg_begin() != CE->arg_end()); - SVal X = state->getSVal(*(CE->arg_begin())); + SVal X = state->getExprVal(*(CE->arg_begin())); C.GenerateNode(state->BindExpr(CE, X)); return true; } @@ -65,7 +65,7 @@ bool BuiltinFunctionChecker::EvalCallExpr(CheckerContext &C,const CallExpr *CE){ // Set the extent of the region in bytes. This enables us to use the // SVal of the argument directly. If we save the extent in bits, we // cannot represent values like symbol*8. - SVal Extent = state->getSVal(*(CE->arg_begin())); + SVal Extent = state->getExprVal(*(CE->arg_begin())); state = C.getStoreManager().setExtent(state, R, Extent); C.GenerateNode(state->BindExpr(CE, loc::MemRegionVal(R))); return true; diff --git a/lib/Checker/CFRefCount.cpp b/lib/Checker/CFRefCount.cpp index 85d9dbdce1..79440e5ab1 100644 --- a/lib/Checker/CFRefCount.cpp +++ b/lib/Checker/CFRefCount.cpp @@ -1399,7 +1399,7 @@ RetainSummaryManager::getInstanceMethodSummary(const ObjCMessageExpr *ME, // FIXME: Is this really working as expected? There are cases where // we just use the 'ID' from the message expression. - SVal receiverV = state->getSValAsScalarOrLoc(Receiver); + SVal receiverV = state->getExprValAsScalarOrLoc(Receiver); // FIXME: Eventually replace the use of state->get with // a generic API for reasoning about the Objective-C types of symbolic @@ -1428,7 +1428,7 @@ RetainSummaryManager::getInstanceMethodSummary(const ObjCMessageExpr *ME, if (const loc::MemRegionVal *L = dyn_cast(&receiverV)) { // Get the region associated with 'self'. if (const ImplicitParamDecl *SelfDecl = LC->getSelfDecl()) { - SVal SelfVal = state->getSVal(state->getRegion(SelfDecl, LC)); + SVal SelfVal = state->Load(state->getRegion(SelfDecl, LC)); if (L->StripCasts() == SelfVal.getAsRegion()) { // Update the summary to make the default argument effect // 'StopTracking'. @@ -2140,7 +2140,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, if (const CallExpr *CE = dyn_cast(S)) { // Get the name of the callee (if it is available). - SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee()); + SVal X = CurrSt->getExprValAsScalarOrLoc(CE->getCallee()); if (const FunctionDecl* FD = X.getAsFunctionDecl()) os << "Call to function '" << FD->getNameAsString() <<'\''; else @@ -2197,7 +2197,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, // Retrieve the value of the argument. Is it the symbol // we are interested in? - if (CurrSt->getSValAsScalarOrLoc(*AI).getAsLocSymbol() != Sym) + if (CurrSt->getExprValAsScalarOrLoc(*AI).getAsLocSymbol() != Sym) continue; // We have an argument. Get the effect! @@ -2206,7 +2206,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, } else if (const ObjCMessageExpr *ME = dyn_cast(S)) { if (const Expr *receiver = ME->getReceiver()) - if (CurrSt->getSValAsScalarOrLoc(receiver).getAsLocSymbol() == Sym) { + if (CurrSt->getExprValAsScalarOrLoc(receiver).getAsLocSymbol() == Sym) { // The symbol we are tracking is the receiver. AEffects.push_back(Summ->getReceiverEffect()); } @@ -2234,7 +2234,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, if (contains(AEffects, MakeCollectable)) { // Get the name of the function. const Stmt* S = cast(N->getLocation()).getStmt(); - SVal X = CurrSt->getSValAsScalarOrLoc(cast(S)->getCallee()); + SVal X = CurrSt->getExprValAsScalarOrLoc(cast(S)->getCallee()); const FunctionDecl* FD = X.getAsFunctionDecl(); const std::string& FName = FD->getNameAsString(); @@ -2346,7 +2346,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I) if (const Expr* Exp = dyn_cast_or_null(*I)) - if (CurrSt->getSValAsScalarOrLoc(Exp).getAsLocSymbol() == Sym) { + if (CurrSt->getExprValAsScalarOrLoc(Exp).getAsLocSymbol() == Sym) { P->addRange(Exp->getSourceRange()); break; } @@ -2597,7 +2597,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, llvm::SmallVector RegionsToInvalidate; for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) { - SVal V = state->getSValAsScalarOrLoc(*I); + SVal V = state->getExprValAsScalarOrLoc(*I); SymbolRef Sym = V.getAsLocSymbol(); if (Sym) @@ -2698,7 +2698,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, // Evaluate the effect on the message receiver. if (!ErrorExpr && Receiver) { - SymbolRef Sym = state->getSValAsScalarOrLoc(Receiver).getAsLocSymbol(); + SymbolRef Sym = state->getExprValAsScalarOrLoc(Receiver).getAsLocSymbol(); if (Sym) { if (const RefVal* T = state->get(Sym)) { state = Update(state, Sym, *T, Summ.getReceiverEffect(), hasErr); @@ -2722,7 +2722,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, if (RE.getKind() == RetEffect::OwnedWhenTrackedReceiver) { assert(Receiver); - SVal V = state->getSValAsScalarOrLoc(Receiver); + SVal V = state->getExprValAsScalarOrLoc(Receiver); bool found = false; if (SymbolRef Sym = V.getAsLocSymbol()) if (state->get(Sym)) { @@ -2751,7 +2751,8 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, // For CallExpr, use the result type to know if it returns a reference. if (const CallExpr *CE = dyn_cast(Ex)) { const Expr *Callee = CE->getCallee(); - if (const FunctionDecl *FD = state->getSVal(Callee).getAsFunctionDecl()) + if (const FunctionDecl *FD = + state->getExprVal(Callee).getAsFunctionDecl()) T = FD->getResultType(); } else if (const ObjCMessageExpr *ME = dyn_cast(Ex)) { @@ -2773,14 +2774,14 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, unsigned idx = RE.getIndex(); assert (arg_end >= arg_beg); assert (idx < (unsigned) (arg_end - arg_beg)); - SVal V = state->getSValAsScalarOrLoc(*(arg_beg+idx)); + SVal V = state->getExprValAsScalarOrLoc(*(arg_beg+idx)); state = state->BindExpr(Ex, V, false); break; } case RetEffect::ReceiverAlias: { assert (Receiver); - SVal V = state->getSValAsScalarOrLoc(Receiver); + SVal V = state->getExprValAsScalarOrLoc(Receiver); state = state->BindExpr(Ex, V, false); break; } @@ -2937,7 +2938,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, return; const GRState *state = Builder.GetState(Pred); - SymbolRef Sym = state->getSValAsScalarOrLoc(RetE).getAsLocSymbol(); + SymbolRef Sym = state->getExprValAsScalarOrLoc(RetE).getAsLocSymbol(); if (!Sym) return; @@ -3492,7 +3493,7 @@ void RetainReleaseChecker::PostVisitBlockExpr(CheckerContext &C, const GRState *state = C.getState(); const BlockDataRegion *R = - cast(state->getSVal(BE).getAsRegion()); + cast(state->getExprVal(BE).getAsRegion()); BlockDataRegion::referenced_vars_iterator I = R->referenced_vars_begin(), E = R->referenced_vars_end(); diff --git a/lib/Checker/CallAndMessageChecker.cpp b/lib/Checker/CallAndMessageChecker.cpp index 9013c3818b..9ae5dc54a8 100644 --- a/lib/Checker/CallAndMessageChecker.cpp +++ b/lib/Checker/CallAndMessageChecker.cpp @@ -73,7 +73,7 @@ void CallAndMessageChecker::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE){ const Expr *Callee = CE->getCallee()->IgnoreParens(); - SVal L = C.getState()->getSVal(Callee); + SVal L = C.getState()->getExprVal(Callee); if (L.isUndef()) { if (!BT_call_undef) @@ -92,7 +92,7 @@ void CallAndMessageChecker::PreVisitCallExpr(CheckerContext &C, for (CallExpr::const_arg_iterator I = CE->arg_begin(), E = CE->arg_end(); I != E; ++I) { - if (C.getState()->getSVal(*I).isUndef()) { + if (C.getState()->getExprVal(*I).isUndef()) { if (ExplodedNode *N = C.GenerateSink()) { if (!BT_call_arg) BT_call_arg = new BuiltinBug("Pass-by-value argument in function call" @@ -115,7 +115,7 @@ void CallAndMessageChecker::PreVisitObjCMessageExpr(CheckerContext &C, const GRState *state = C.getState(); if (const Expr *receiver = ME->getReceiver()) - if (state->getSVal(receiver).isUndef()) { + if (state->getExprVal(receiver).isUndef()) { if (ExplodedNode *N = C.GenerateSink()) { if (!BT_msg_undef) BT_msg_undef = @@ -133,7 +133,7 @@ void CallAndMessageChecker::PreVisitObjCMessageExpr(CheckerContext &C, // Check for any arguments that are uninitialized/undefined. for (ObjCMessageExpr::const_arg_iterator I = ME->arg_begin(), E = ME->arg_end(); I != E; ++I) { - if (state->getSVal(*I).isUndef()) { + if (state->getExprVal(*I).isUndef()) { if (ExplodedNode *N = C.GenerateSink()) { if (!BT_msg_arg) BT_msg_arg = diff --git a/lib/Checker/CallInliner.cpp b/lib/Checker/CallInliner.cpp index d94994b194..3feca9784b 100644 --- a/lib/Checker/CallInliner.cpp +++ b/lib/Checker/CallInliner.cpp @@ -37,7 +37,7 @@ void clang::RegisterCallInliner(GRExprEngine &Eng) { bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); const FunctionDecl *FD = L.getAsFunctionDecl(); if (!FD) diff --git a/lib/Checker/DivZeroChecker.cpp b/lib/Checker/DivZeroChecker.cpp index e1346e11b6..39fdeaba2b 100644 --- a/lib/Checker/DivZeroChecker.cpp +++ b/lib/Checker/DivZeroChecker.cpp @@ -49,7 +49,7 @@ void DivZeroChecker::PreVisitBinaryOperator(CheckerContext &C, !B->getRHS()->getType()->isScalarType()) return; - SVal Denom = C.getState()->getSVal(B->getRHS()); + SVal Denom = C.getState()->getExprVal(B->getRHS()); const DefinedSVal *DV = dyn_cast(&Denom); // Divide-by-undefined handled in the generic checking for uses of diff --git a/lib/Checker/FixedAddressChecker.cpp b/lib/Checker/FixedAddressChecker.cpp index 04c17d6d7a..6ed31a788b 100644 --- a/lib/Checker/FixedAddressChecker.cpp +++ b/lib/Checker/FixedAddressChecker.cpp @@ -48,7 +48,7 @@ void FixedAddressChecker::PreVisitBinaryOperator(CheckerContext &C, const GRState *state = C.getState(); - SVal RV = state->getSVal(B->getRHS()); + SVal RV = state->getExprVal(B->getRHS()); if (!RV.isConstant() || RV.isZeroConstant()) return; diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 978be8dc64..72456cc311 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -392,7 +392,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { if (!R) break; - SVal V = state->getSVal(loc::MemRegionVal(R)); + SVal V = state->Load(loc::MemRegionVal(R)); SVal Constraint_untested = EvalBinOp(state, BinaryOperator::GT, V, ValMgr.makeZeroVal(T), getContext().IntTy); @@ -414,7 +414,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { // method. const ImplicitParamDecl *SelfD = MD->getSelfDecl(); const MemRegion *R = state->getRegion(SelfD, InitLoc); - SVal V = state->getSVal(loc::MemRegionVal(R)); + SVal V = state->Load(loc::MemRegionVal(R)); if (const Loc *LV = dyn_cast(&V)) { // Assume that the pointer value in 'self' is non-null. @@ -633,7 +633,8 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) { } else if (B->getOpcode() == BinaryOperator::Comma) { const GRState* state = GetState(Pred); - MakeNode(Dst, B, Pred, state->BindExpr(B, state->getSVal(B->getRHS()))); + MakeNode(Dst, B, Pred, state->BindExpr(B, + state->getExprVal(B->getRHS()))); break; } @@ -764,7 +765,8 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) { if (Expr* LastExpr = dyn_cast(*SE->getSubStmt()->body_rbegin())) { const GRState* state = GetState(Pred); - MakeNode(Dst, SE, Pred, state->BindExpr(SE, state->getSVal(LastExpr))); + MakeNode(Dst, SE, Pred, state->BindExpr(SE, + state->getExprVal(LastExpr))); } else Dst.Add(Pred); @@ -1043,7 +1045,7 @@ static SVal RecoverCastedSymbol(GRStateManager& StateMgr, const GRState* state, if (!bitsInit || !T->isIntegerType() || Ctx.getTypeSize(T) > bits) return UnknownVal(); - return state->getSVal(Ex); + return state->getExprVal(Ex); } void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term, @@ -1070,7 +1072,7 @@ void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term, return; const GRState* PrevState = builder.getState(); - SVal X = PrevState->getSVal(Condition); + SVal X = PrevState->getExprVal(Condition); if (X.isUnknown()) { // Give it a chance to recover from unknown. @@ -1121,7 +1123,7 @@ void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term, void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) { const GRState *state = builder.getState(); - SVal V = state->getSVal(builder.getTarget()); + SVal V = state->getExprVal(builder.getTarget()); // Three possibilities: // @@ -1169,13 +1171,13 @@ void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, Pred->getLocationContext()->getCFG()->isBlkExpr(Ex)); const GRState* state = GetState(Pred); - SVal X = state->getSVal(Ex); + SVal X = state->getExprVal(Ex); assert (X.isUndef()); Expr *SE = (Expr*) cast(X).getData(); assert(SE); - X = state->getSVal(SE); + X = state->getExprVal(SE); // Make sure that we invalidate the previous binding. MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, X, true)); @@ -1199,7 +1201,7 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) { typedef GRSwitchNodeBuilder::iterator iterator; const GRState* state = builder.getState(); Expr* CondE = builder.getCondition(); - SVal CondV_untested = state->getSVal(CondE); + SVal CondV_untested = state->getExprVal(CondE); if (CondV_untested.isUndef()) { //ExplodedNode* N = builder.generateDefaultCaseNode(state, true); @@ -1300,14 +1302,14 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred, assert(B==CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(B)); const GRState* state = GetState(Pred); - SVal X = state->getSVal(B); + SVal X = state->getExprVal(B); assert(X.isUndef()); const Expr *Ex = (const Expr*) cast(X).getData(); assert(Ex); if (Ex == B->getRHS()) { - X = state->getSVal(Ex); + X = state->getExprVal(Ex); // Handle undefined values. if (X.isUndef()) { @@ -1387,7 +1389,7 @@ void GRExprEngine::VisitCommonDeclRefExpr(Expr *Ex, const NamedDecl *D, // reference region. if (VD->getType()->isReferenceType()) { if (const MemRegion *R = V.getAsRegion()) - V = state->getSVal(R); + V = state->Load(R); else V = UnknownVal(); } @@ -1446,8 +1448,8 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, for (ExplodedNodeSet::iterator I2=Tmp3.begin(),E2=Tmp3.end();I2!=E2; ++I2) { const GRState* state = GetState(*I2); - SVal V = state->getLValue(A->getType(), state->getSVal(Idx), - state->getSVal(Base)); + SVal V = state->getLValue(A->getType(), state->getExprVal(Idx), + state->getExprVal(Base)); if (asLValue) MakeNode(Dst, A, *I2, state->BindExpr(A, V), @@ -1479,7 +1481,7 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred, // FIXME: Should we insert some assumption logic in here to determine // if "Base" is a valid piece of memory? Before we put this assumption // later when using FieldOffset lvals (which we no longer have). - SVal L = state->getLValue(Field, state->getSVal(Base)); + SVal L = state->getLValue(Field, state->getExprVal(Base)); if (asLValue) MakeNode(Dst, M, *I, state->BindExpr(M, L), ProgramPoint::PostLValueKind); @@ -1591,7 +1593,7 @@ void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr *Ex, ExplodedNode* Pred, // Perform the load from the referenced value. for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end() ; I!=E; ++I) { state = GetState(*I); - location = state->getSVal(Ex); + location = state->getExprVal(Ex); EvalLoadCommon(Dst, Ex, *I, state, location, tag, LoadTy); } return; @@ -1627,7 +1629,7 @@ void GRExprEngine::EvalLoadCommon(ExplodedNodeSet& Dst, Expr *Ex, ProgramPoint::PostLoadKind, tag); } else { - SVal V = state->getSVal(cast(location), LoadTy.isNull() ? + SVal V = state->Load(cast(location), LoadTy.isNull() ? Ex->getType() : LoadTy); MakeNode(Dst, Ex, *NI, state->BindExpr(Ex, V), ProgramPoint::PostLoadKind, tag); @@ -1760,7 +1762,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred, DI != DE; ++DI) { const GRState* state = GetState(*DI); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); // FIXME: Add support for symbolic function calls (calls involving // function pointer values that are symbolic). @@ -1815,7 +1817,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred, for (ExplodedNodeSet::iterator NI = DstTmp4.begin(), NE = DstTmp4.end(); NI!=NE; ++NI) { const GRState *state = GetState(*NI); - EvalLoad(Dst, CE, *NI, state, state->getSVal(CE), + EvalLoad(Dst, CE, *NI, state, state->getExprVal(CE), &ConvertToRvalueTag, LoadTy); } } @@ -1842,7 +1844,7 @@ void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, } const GRState* state = Pred->getState(); - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); if (nonloc::SymExprVal *SEV = dyn_cast(&V)) { // First assume that the condition is true. if (const GRState *stateTrue = state->Assume(*SEV, true)) { @@ -1880,7 +1882,7 @@ void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - SVal BaseVal = state->getSVal(Base); + SVal BaseVal = state->getExprVal(Base); SVal location = state->getLValue(Ex->getDecl(), BaseVal); if (asLValue) @@ -1938,7 +1940,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - VisitObjCForCollectionStmtAux(S, *I, Dst, state->getSVal(elem)); + VisitObjCForCollectionStmtAux(S, *I, Dst, state->getExprVal(elem)); } } @@ -2062,7 +2064,7 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, // Bifurcate the state into nil and non-nil ones. DefinedOrUnknownSVal receiverVal = - cast(state->getSVal(Receiver)); + cast(state->getExprVal(Receiver)); const GRState *notNilState, *nilState; llvm::tie(notNilState, nilState) = state->Assume(receiverVal); @@ -2164,7 +2166,7 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, NE = DstRValueConvert.end(); NI!=NE; ++NI) { const GRState *state = GetState(*NI); - EvalLoad(Dst, ME, *NI, state, state->getSVal(ME), + EvalLoad(Dst, ME, *NI, state, state->getExprVal(ME), &ConvertToRvalueTag, LoadTy); } } @@ -2212,7 +2214,7 @@ void GRExprEngine::VisitCast(CastExpr *CastE, Expr *Ex, ExplodedNode *Pred, // Copy the SVal of Ex to CastE. ExplodedNode *N = *I; const GRState *state = GetState(N); - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); state = state->BindExpr(CastE, V); MakeNode(Dst, CastE, N, state); } @@ -2234,7 +2236,7 @@ void GRExprEngine::VisitCast(CastExpr *CastE, Expr *Ex, ExplodedNode *Pred, for (ExplodedNodeSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) { ExplodedNode* N = *I; const GRState* state = GetState(N); - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); V = SVator.EvalCast(V, T, ExTy); state = state->BindExpr(CastE, V); MakeNode(Dst, CastE, N, state); @@ -2257,7 +2259,7 @@ void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) { const GRState* state = GetState(*I); - SVal ILV = state->getSVal(ILE); + SVal ILV = state->getExprVal(ILE); const LocationContext *LC = (*I)->getLocationContext(); state = state->bindCompoundLiteral(CL, LC, ILV); @@ -2305,7 +2307,7 @@ void GRExprEngine::VisitDeclStmt(DeclStmt *DS, ExplodedNode *Pred, const LocationContext *LC = N->getLocationContext(); if (InitEx) { - SVal InitVal = state->getSVal(InitEx); + SVal InitVal = state->getExprVal(InitEx); // Recover some path-sensitivity if a scalar value evaluated to // UnknownVal. @@ -2337,7 +2339,7 @@ void GRExprEngine::VisitCondInit(VarDecl *VD, Stmt *S, const GRState *state = GetState(N); const LocationContext *LC = N->getLocationContext(); - SVal InitVal = state->getSVal(InitEx); + SVal InitVal = state->getExprVal(InitEx); // Recover some path-sensitivity if a scalar value evaluated to // UnknownVal. @@ -2408,7 +2410,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred, for (ExplodedNodeSet::iterator NI=Tmp.begin(),NE=Tmp.end();NI!=NE;++NI) { // Get the last initializer value. state = GetState(*NI); - SVal InitV = state->getSVal(cast(*X.Itr)); + SVal InitV = state->getExprVal(cast(*X.Itr)); // Construct the new list of values by prepending the new value to // the already constructed list. @@ -2439,7 +2441,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred, Visit(Init, Pred, Tmp); for (ExplodedNodeSet::iterator I=Tmp.begin(), EI=Tmp.end(); I != EI; ++I) { state = GetState(*I); - MakeNode(Dst, E, *I, state->BindExpr(E, state->getSVal(Init))); + MakeNode(Dst, E, *I, state->BindExpr(E, state->getExprVal(Init))); } return; } @@ -2502,7 +2504,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - SVal location = state->getSVal(Ex); + SVal location = state->getExprVal(Ex); if (asLValue) MakeNode(Dst, U, *I, state->BindExpr(U, location), @@ -2532,7 +2534,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, // For all other types, UnaryOperator::Real is an identity operation. assert (U->getType() == Ex->getType()); const GRState* state = GetState(*I); - MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex))); + MakeNode(Dst, U, *I, state->BindExpr(U, state->getExprVal(Ex))); } return; @@ -2592,7 +2594,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex))); + MakeNode(Dst, U, *I, state->BindExpr(U, state->getExprVal(Ex))); } return; @@ -2607,7 +2609,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); state = state->BindExpr(U, V); MakeNode(Dst, U, *I, state); } @@ -2628,7 +2630,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, const GRState* state = GetState(*I); // Get the value of the subexpression. - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); if (V.isUnknownOrUndef()) { MakeNode(Dst, U, *I, state->BindExpr(U, V)); @@ -2702,7 +2704,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) { const GRState* state = GetState(*I); - SVal V1 = state->getSVal(Ex); + SVal V1 = state->getExprVal(Ex); // Perform a load. ExplodedNodeSet Tmp2; @@ -2711,7 +2713,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred, for (ExplodedNodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end();I2!=E2;++I2) { state = GetState(*I2); - SVal V2_untested = state->getSVal(Ex); + SVal V2_untested = state->getExprVal(Ex); // Propagate unknown and undefined values. if (V2_untested.isUnknownOrUndef()) { @@ -2780,7 +2782,7 @@ void GRExprEngine::VisitCXXThisExpr(CXXThisExpr *TE, ExplodedNode *Pred, Pred->getLocationContext()); const GRState *state = GetState(Pred); - SVal V = state->getSVal(loc::MemRegionVal(R)); + SVal V = state->Load(loc::MemRegionVal(R)); MakeNode(Dst, TE, Pred, state->BindExpr(TE, V)); } @@ -2826,7 +2828,7 @@ void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A, for (AsmStmt::outputs_iterator OI = A->begin_outputs(), OE = A->end_outputs(); OI != OE; ++OI) { - SVal X = state->getSVal(*OI); + SVal X = state->getExprVal(*OI); assert (!isa(X)); // Should be an Lval, or unknown, undef. if (isa(X)) @@ -2906,7 +2908,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, ExplodedNodeSet Tmp3; for (ExplodedNodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1!=E1; ++I1) { - SVal LeftV = (*I1)->getState()->getSVal(LHS); + SVal LeftV = (*I1)->getState()->getExprVal(LHS); ExplodedNodeSet Tmp2; Visit(RHS, *I1, Tmp2); @@ -2920,7 +2922,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, const GRState *state = GetState(*I2); const GRState *OldSt = state; - SVal RightV = state->getSVal(RHS); + SVal RightV = state->getExprVal(RHS); BinaryOperator::Opcode Op = B->getOpcode(); @@ -2985,13 +2987,13 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, // Perform a load (the LHS). This performs the checks for // null dereferences, and so on. ExplodedNodeSet Tmp4; - SVal location = state->getSVal(LHS); + SVal location = state->getExprVal(LHS); EvalLoad(Tmp4, LHS, *I2, state, location); for (ExplodedNodeSet::iterator I4=Tmp4.begin(), E4=Tmp4.end(); I4!=E4; ++I4) { state = GetState(*I4); - SVal V = state->getSVal(LHS); + SVal V = state->getExprVal(LHS); // Get the computation type. QualType CTy = @@ -3056,7 +3058,7 @@ void GRExprEngine::CreateCXXTemporaryObject(Expr *Ex, ExplodedNode *Pred, // Bind the temporary object to the value of the expression. Then bind // the expression to the location of the object. - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); const MemRegion *R = ValMgr.getRegionManager().getCXXObjectRegion(Ex, diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp index 592f930316..c533dceee5 100644 --- a/lib/Checker/GRState.cpp +++ b/lib/Checker/GRState.cpp @@ -69,7 +69,7 @@ const GRState *GRState::unbindLoc(Loc LV) const { return getStateManager().getPersistentState(NewSt); } -SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const { +SVal GRState::LoadAsScalarOrLoc(const MemRegion *R) const { // We only want to do fetches from regions that we can actually bind // values. For example, SymbolicRegions of type 'id<...>' cannot // have direct bindings (but their can be bindings on their subregions). @@ -79,7 +79,7 @@ SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const { if (const TypedRegion *TR = dyn_cast(R)) { QualType T = TR->getValueType(getStateManager().getContext()); if (Loc::IsLocType(T) || T->isIntegerType()) - return getSVal(R); + return Load(R); } return UnknownVal(); @@ -297,7 +297,7 @@ bool ScanReachableSymbols::scan(const MemRegion *R) { return false; // Now look at the binding to this region (if any). - if (!scan(state->getSValAsScalarOrLoc(R))) + if (!scan(state->LoadAsScalarOrLoc(R))) return false; // Now look at the subregions. @@ -341,7 +341,7 @@ bool GRState::scanReachableSymbols(const MemRegion * const *I, bool GRStateManager::isEqual(const GRState* state, const Expr* Ex, const llvm::APSInt& Y) { - SVal V = state->getSVal(Ex); + SVal V = state->getExprVal(Ex); if (loc::ConcreteInt* X = dyn_cast(&V)) return X->getValue() == Y; diff --git a/lib/Checker/MallocChecker.cpp b/lib/Checker/MallocChecker.cpp index 3be2e0299b..7f36f74578 100644 --- a/lib/Checker/MallocChecker.cpp +++ b/lib/Checker/MallocChecker.cpp @@ -103,7 +103,7 @@ void *MallocChecker::getTag() { bool MallocChecker::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); const FunctionDecl *FD = L.getAsFunctionDecl(); if (!FD) @@ -149,7 +149,7 @@ const GRState *MallocChecker::MallocMemAux(CheckerContext &C, SVal RetVal = ValMgr.getConjuredSymbolVal(NULL, CE, CE->getType(), Count); - SVal Size = state->getSVal(SizeEx); + SVal Size = state->getExprVal(SizeEx); state = C.getEngine().getStoreManager().setExtent(state, RetVal.getAsRegion(), Size); @@ -171,7 +171,7 @@ void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) { const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE, const GRState *state) { - SVal ArgVal = state->getSVal(CE->getArg(0)); + SVal ArgVal = state->getExprVal(CE->getArg(0)); SymbolRef Sym = ArgVal.getAsLocSymbol(); assert(Sym); @@ -205,7 +205,8 @@ const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE, void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) { const GRState *state = C.getState(); const Expr *Arg0 = CE->getArg(0); - DefinedOrUnknownSVal Arg0Val=cast(state->getSVal(Arg0)); + DefinedOrUnknownSVal Arg0Val = + cast(state->getExprVal(Arg0)); ValueManager &ValMgr = C.getValueManager(); SValuator &SVator = C.getSValuator(); @@ -229,7 +230,7 @@ void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) { if (const GRState *stateNotEqual = state->Assume(PtrEQ, false)) { const Expr *Arg1 = CE->getArg(1); DefinedOrUnknownSVal Arg1Val = - cast(stateNotEqual->getSVal(Arg1)); + cast(stateNotEqual->getExprVal(Arg1)); DefinedOrUnknownSVal SizeZero = SVator.EvalEQ(stateNotEqual, Arg1Val, ValMgr.makeIntValWithPtrWidth(0, false)); @@ -304,7 +305,7 @@ void MallocChecker::PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S) { const GRState *state = C.getState(); - SymbolRef Sym = state->getSVal(RetE).getAsSymbol(); + SymbolRef Sym = state->getExprVal(RetE).getAsSymbol(); if (!Sym) return; diff --git a/lib/Checker/NSErrorChecker.cpp b/lib/Checker/NSErrorChecker.cpp index e428e2e83f..7e680a632b 100644 --- a/lib/Checker/NSErrorChecker.cpp +++ b/lib/Checker/NSErrorChecker.cpp @@ -199,7 +199,7 @@ void NSErrorChecker::CheckParamDeref(const VarDecl *Param, SVal ParamL = rootState->getLValue(Param, LC); const MemRegion* ParamR = cast(ParamL).getRegionAs(); assert (ParamR && "Parameters always have VarRegions."); - SVal ParamSVal = rootState->getSVal(ParamR); + SVal ParamSVal = rootState->Load(ParamR); // FIXME: For now assume that ParamSVal is symbolic. We need to generalize // this later. @@ -212,7 +212,8 @@ void NSErrorChecker::CheckParamDeref(const VarDecl *Param, llvm::tie(I, E) = GetImplicitNullDereferences(Eng); for ( ; I != E; ++I) { const GRState *state = (*I)->getState(); - SVal location = state->getSVal((*I)->getLocationAs()->getStmt()); + SVal location = + state->getExprVal((*I)->getLocationAs()->getStmt()); if (location.getAsSymbol() != ParamSym) continue; diff --git a/lib/Checker/NoReturnFunctionChecker.cpp b/lib/Checker/NoReturnFunctionChecker.cpp index 1455d87665..6204ee65cf 100644 --- a/lib/Checker/NoReturnFunctionChecker.cpp +++ b/lib/Checker/NoReturnFunctionChecker.cpp @@ -36,7 +36,7 @@ bool NoReturnFunctionChecker::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); const FunctionDecl *FD = L.getAsFunctionDecl(); if (!FD) return false; diff --git a/lib/Checker/OSAtomicChecker.cpp b/lib/Checker/OSAtomicChecker.cpp index 7f4aeca331..ac5f30041a 100644 --- a/lib/Checker/OSAtomicChecker.cpp +++ b/lib/Checker/OSAtomicChecker.cpp @@ -38,7 +38,7 @@ void clang::RegisterOSAtomicChecker(GRExprEngine &Eng) { bool OSAtomicChecker::EvalCallExpr(CheckerContext &C,const CallExpr *CE) { const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); + SVal L = state->getExprVal(Callee); const FunctionDecl* FD = L.getAsFunctionDecl(); if (!FD) @@ -100,7 +100,7 @@ bool OSAtomicChecker::EvalOSAtomicCompareAndSwap(CheckerContext &C, GRExprEngine &Engine = C.getEngine(); const GRState *state = C.getState(); ExplodedNodeSet Tmp; - SVal location = state->getSVal(theValueExpr); + SVal location = state->getExprVal(theValueExpr); // Here we should use the value type of the region as the load type. QualType LoadTy; if (const TypedRegion *TR = @@ -124,8 +124,8 @@ bool OSAtomicChecker::EvalOSAtomicCompareAndSwap(CheckerContext &C, ExplodedNode *N = *I; const GRState *stateLoad = N->getState(); - SVal theValueVal_untested = stateLoad->getSVal(theValueExpr); - SVal oldValueVal_untested = stateLoad->getSVal(oldValueExpr); + SVal theValueVal_untested = stateLoad->getExprVal(theValueExpr); + SVal oldValueVal_untested = stateLoad->getExprVal(oldValueExpr); // FIXME: Issue an error. if (theValueVal_untested.isUndef() || oldValueVal_untested.isUndef()) { @@ -148,7 +148,7 @@ bool OSAtomicChecker::EvalOSAtomicCompareAndSwap(CheckerContext &C, if (stateEqual) { // Perform the store. ExplodedNodeSet TmpStore; - SVal val = stateEqual->getSVal(newValueExpr); + SVal val = stateEqual->getExprVal(newValueExpr); // Handle implicit value casts. if (const TypedRegion *R = diff --git a/lib/Checker/PointerArithChecker.cpp b/lib/Checker/PointerArithChecker.cpp index 3d62d0c7b9..b3d957af08 100644 --- a/lib/Checker/PointerArithChecker.cpp +++ b/lib/Checker/PointerArithChecker.cpp @@ -40,8 +40,8 @@ void PointerArithChecker::PreVisitBinaryOperator(CheckerContext &C, return; const GRState *state = C.getState(); - SVal LV = state->getSVal(B->getLHS()); - SVal RV = state->getSVal(B->getRHS()); + SVal LV = state->getExprVal(B->getLHS()); + SVal RV = state->getExprVal(B->getRHS()); const MemRegion *LR = LV.getAsRegion(); diff --git a/lib/Checker/PointerSubChecker.cpp b/lib/Checker/PointerSubChecker.cpp index acc848ac8e..99deee9238 100644 --- a/lib/Checker/PointerSubChecker.cpp +++ b/lib/Checker/PointerSubChecker.cpp @@ -42,8 +42,8 @@ void PointerSubChecker::PreVisitBinaryOperator(CheckerContext &C, return; const GRState *state = C.getState(); - SVal LV = state->getSVal(B->getLHS()); - SVal RV = state->getSVal(B->getRHS()); + SVal LV = state->getExprVal(B->getLHS()); + SVal RV = state->getExprVal(B->getRHS()); const MemRegion *LR = LV.getAsRegion(); const MemRegion *RR = RV.getAsRegion(); diff --git a/lib/Checker/PthreadLockChecker.cpp b/lib/Checker/PthreadLockChecker.cpp index 74e266c3ed..35453d13ae 100644 --- a/lib/Checker/PthreadLockChecker.cpp +++ b/lib/Checker/PthreadLockChecker.cpp @@ -60,7 +60,7 @@ void PthreadLockChecker::PostVisitCallExpr(CheckerContext &C, const GRState *state = C.getState(); const Expr *Callee = CE->getCallee(); const FunctionTextRegion *R = - dyn_cast_or_null(state->getSVal(Callee).getAsRegion()); + dyn_cast_or_null(state->getExprVal(Callee).getAsRegion()); if (!R) return; @@ -70,17 +70,17 @@ void PthreadLockChecker::PostVisitCallExpr(CheckerContext &C, if (FName == "pthread_mutex_lock") { if (CE->getNumArgs() != 1) return; - AcquireLock(C, CE, state->getSVal(CE->getArg(0)), false); + AcquireLock(C, CE, state->getExprVal(CE->getArg(0)), false); } else if (FName == "pthread_mutex_trylock") { if (CE->getNumArgs() != 1) return; - AcquireLock(C, CE, state->getSVal(CE->getArg(0)), true); + AcquireLock(C, CE, state->getExprVal(CE->getArg(0)), true); } else if (FName == "pthread_mutex_unlock") { if (CE->getNumArgs() != 1) return; - ReleaseLock(C, CE, state->getSVal(CE->getArg(0))); + ReleaseLock(C, CE, state->getExprVal(CE->getArg(0))); } } @@ -93,7 +93,7 @@ void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE, const GRState *state = C.getState(); - SVal X = state->getSVal(CE); + SVal X = state->getExprVal(CE); if (X.isUnknownOrUndef()) return; diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index c08be0cff6..05b385cc58 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -1859,7 +1859,7 @@ GRState const *RegionStoreManager::EnterStackFrame(GRState const *state, // Copy the arg expression value to the arg variables. Store store = state->getStore(); for (; AI != AE; ++AI, ++PI) { - SVal ArgVal = state->getSVal(*AI); + SVal ArgVal = state->getExprVal(*AI); store = Bind(store, ValMgr.makeLoc(MRMgr.getVarRegion(*PI, frame)), ArgVal); } diff --git a/lib/Checker/ReturnPointerRangeChecker.cpp b/lib/Checker/ReturnPointerRangeChecker.cpp index 949ded507c..8a4d6014ae 100644 --- a/lib/Checker/ReturnPointerRangeChecker.cpp +++ b/lib/Checker/ReturnPointerRangeChecker.cpp @@ -46,7 +46,7 @@ void ReturnPointerRangeChecker::PreVisitReturnStmt(CheckerContext &C, if (!RetE) return; - SVal V = state->getSVal(RetE); + SVal V = state->getExprVal(RetE); const MemRegion *R = V.getAsRegion(); if (!R) return; diff --git a/lib/Checker/ReturnStackAddressChecker.cpp b/lib/Checker/ReturnStackAddressChecker.cpp index 9cbabba4a5..74995bfd92 100644 --- a/lib/Checker/ReturnStackAddressChecker.cpp +++ b/lib/Checker/ReturnStackAddressChecker.cpp @@ -112,7 +112,7 @@ void ReturnStackAddressChecker::PreVisitReturnStmt(CheckerContext &C, if (!RetE) return; - SVal V = C.getState()->getSVal(RetE); + SVal V = C.getState()->getExprVal(RetE); const MemRegion *R = V.getAsRegion(); if (!R || !R->hasStackStorage()) diff --git a/lib/Checker/ReturnUndefChecker.cpp b/lib/Checker/ReturnUndefChecker.cpp index ee259883e4..5574c22612 100644 --- a/lib/Checker/ReturnUndefChecker.cpp +++ b/lib/Checker/ReturnUndefChecker.cpp @@ -47,7 +47,7 @@ void ReturnUndefChecker::PreVisitReturnStmt(CheckerContext &C, if (!RetE) return; - if (!C.getState()->getSVal(RetE).isUndef()) + if (!C.getState()->getExprVal(RetE).isUndef()) return; ExplodedNode *N = C.GenerateSink(); diff --git a/lib/Checker/UndefBranchChecker.cpp b/lib/Checker/UndefBranchChecker.cpp index e047b187b1..793f5e06fd 100644 --- a/lib/Checker/UndefBranchChecker.cpp +++ b/lib/Checker/UndefBranchChecker.cpp @@ -41,7 +41,7 @@ class UndefBranchChecker : public Checker { return Ex; } - bool MatchesCriteria(Expr* Ex) { return St->getSVal(Ex).isUndef(); } + bool MatchesCriteria(Expr* Ex) { return St->getExprVal(Ex).isUndef(); } }; public: @@ -66,7 +66,7 @@ void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder, GRExprEngine &Eng, Stmt *Condition, void *tag) { const GRState *state = Builder.getState(); - SVal X = state->getSVal(Condition); + SVal X = state->getExprVal(Condition); if (X.isUndef()) { ExplodedNode *N = Builder.generateNode(state, true); if (N) { diff --git a/lib/Checker/UndefResultChecker.cpp b/lib/Checker/UndefResultChecker.cpp index fb2283a620..98f513ef44 100644 --- a/lib/Checker/UndefResultChecker.cpp +++ b/lib/Checker/UndefResultChecker.cpp @@ -39,7 +39,7 @@ void clang::RegisterUndefResultChecker(GRExprEngine &Eng) { void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B) { const GRState *state = C.getState(); - if (state->getSVal(B).isUndef()) { + if (state->getExprVal(B).isUndef()) { // Generate an error node. ExplodedNode *N = C.GenerateSink(); if (!N) @@ -53,11 +53,11 @@ void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C, const Expr *Ex = NULL; bool isLeft = true; - if (state->getSVal(B->getLHS()).isUndef()) { + if (state->getExprVal(B->getLHS()).isUndef()) { Ex = B->getLHS()->IgnoreParenCasts(); isLeft = true; } - else if (state->getSVal(B->getRHS()).isUndef()) { + else if (state->getExprVal(B->getRHS()).isUndef()) { Ex = B->getRHS()->IgnoreParenCasts(); isLeft = false; } diff --git a/lib/Checker/UndefinedArraySubscriptChecker.cpp b/lib/Checker/UndefinedArraySubscriptChecker.cpp index a2792ad17b..aa03561810 100644 --- a/lib/Checker/UndefinedArraySubscriptChecker.cpp +++ b/lib/Checker/UndefinedArraySubscriptChecker.cpp @@ -40,7 +40,7 @@ void clang::RegisterUndefinedArraySubscriptChecker(GRExprEngine &Eng) { void UndefinedArraySubscriptChecker::PreVisitArraySubscriptExpr(CheckerContext &C, const ArraySubscriptExpr *A) { - if (C.getState()->getSVal(A->getIdx()).isUndef()) { + if (C.getState()->getExprVal(A->getIdx()).isUndef()) { if (ExplodedNode *N = C.GenerateSink()) { if (!BT) BT = new BuiltinBug("Array subscript is undefined"); diff --git a/lib/Checker/VLASizeChecker.cpp b/lib/Checker/VLASizeChecker.cpp index 51ad1e2daf..cb08e8ce6f 100644 --- a/lib/Checker/VLASizeChecker.cpp +++ b/lib/Checker/VLASizeChecker.cpp @@ -51,7 +51,7 @@ void VLASizeChecker::PreVisitDeclStmt(CheckerContext &C, const DeclStmt *DS) { // FIXME: Handle multi-dimensional VLAs. const Expr* SE = VLA->getSizeExpr(); const GRState *state = C.getState(); - SVal sizeV = state->getSVal(SE); + SVal sizeV = state->getExprVal(SE); if (sizeV.isUndef()) { // Generate an error node.