[analyzer] For locations, use isGLValue() instead of isLValue().
llvm-svn: 157088
This commit is contained in:
parent
de87c0fdb4
commit
94a7b849a2
|
|
@ -672,7 +672,7 @@ ProgramState::getSValAsScalarOrLoc(const Stmt *S,
|
||||||
const LocationContext *LCtx) const {
|
const LocationContext *LCtx) const {
|
||||||
if (const Expr *Ex = dyn_cast<Expr>(S)) {
|
if (const Expr *Ex = dyn_cast<Expr>(S)) {
|
||||||
QualType T = Ex->getType();
|
QualType T = Ex->getType();
|
||||||
if (Ex->isLValue() || Loc::isLocType(T) || T->isIntegerType())
|
if (Ex->isGLValue() || Loc::isLocType(T) || T->isIntegerType())
|
||||||
return getSVal(S, LCtx);
|
return getSVal(S, LCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1432,7 +1432,7 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
|
||||||
const LocationContext *LCtx = Pred->getLocationContext();
|
const LocationContext *LCtx = Pred->getLocationContext();
|
||||||
|
|
||||||
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
||||||
assert(Ex->isLValue());
|
assert(Ex->isGLValue());
|
||||||
SVal V = state->getLValue(VD, Pred->getLocationContext());
|
SVal V = state->getLValue(VD, Pred->getLocationContext());
|
||||||
|
|
||||||
// For references, the 'lvalue' is the pointer address stored in the
|
// For references, the 'lvalue' is the pointer address stored in the
|
||||||
|
|
@ -1449,7 +1449,7 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(D)) {
|
if (const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(D)) {
|
||||||
assert(!Ex->isLValue());
|
assert(!Ex->isGLValue());
|
||||||
SVal V = svalBuilder.makeIntVal(ED->getInitVal());
|
SVal V = svalBuilder.makeIntVal(ED->getInitVal());
|
||||||
Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V));
|
Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V));
|
||||||
return;
|
return;
|
||||||
|
|
@ -1492,7 +1492,7 @@ void ExprEngine::VisitLvalArraySubscriptExpr(const ArraySubscriptExpr *A,
|
||||||
SVal V = state->getLValue(A->getType(),
|
SVal V = state->getLValue(A->getType(),
|
||||||
state->getSVal(Idx, LCtx),
|
state->getSVal(Idx, LCtx),
|
||||||
state->getSVal(Base, LCtx));
|
state->getSVal(Base, LCtx));
|
||||||
assert(A->isLValue());
|
assert(A->isGLValue());
|
||||||
Bldr.generateNode(A, *it, state->BindExpr(A, LCtx, V),
|
Bldr.generateNode(A, *it, state->BindExpr(A, LCtx, V),
|
||||||
false, 0, ProgramPoint::PostLValueKind);
|
false, 0, ProgramPoint::PostLValueKind);
|
||||||
}
|
}
|
||||||
|
|
@ -1506,7 +1506,7 @@ void ExprEngine::VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred,
|
||||||
ExplodedNodeSet Dst;
|
ExplodedNodeSet Dst;
|
||||||
Decl *member = M->getMemberDecl();
|
Decl *member = M->getMemberDecl();
|
||||||
if (VarDecl *VD = dyn_cast<VarDecl>(member)) {
|
if (VarDecl *VD = dyn_cast<VarDecl>(member)) {
|
||||||
assert(M->isLValue());
|
assert(M->isGLValue());
|
||||||
Bldr.takeNodes(Pred);
|
Bldr.takeNodes(Pred);
|
||||||
VisitCommonDeclRefExpr(M, VD, Pred, Dst);
|
VisitCommonDeclRefExpr(M, VD, Pred, Dst);
|
||||||
Bldr.addNodes(Dst);
|
Bldr.addNodes(Dst);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
|
||||||
}
|
}
|
||||||
// Simulate the effects of a "store": bind the value of the RHS
|
// Simulate the effects of a "store": bind the value of the RHS
|
||||||
// to the L-Value represented by the LHS.
|
// to the L-Value represented by the LHS.
|
||||||
SVal ExprVal = B->isLValue() ? LeftV : RightV;
|
SVal ExprVal = B->isGLValue() ? LeftV : RightV;
|
||||||
evalStore(Tmp2, B, LHS, *it, state->BindExpr(B, LCtx, ExprVal),
|
evalStore(Tmp2, B, LHS, *it, state->BindExpr(B, LCtx, ExprVal),
|
||||||
LeftV, RightV);
|
LeftV, RightV);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -165,7 +165,7 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
|
||||||
|
|
||||||
// In C++, assignment and compound assignment operators return an
|
// In C++, assignment and compound assignment operators return an
|
||||||
// lvalue.
|
// lvalue.
|
||||||
if (B->isLValue())
|
if (B->isGLValue())
|
||||||
state = state->BindExpr(B, LCtx, location);
|
state = state->BindExpr(B, LCtx, location);
|
||||||
else
|
else
|
||||||
state = state->BindExpr(B, LCtx, Result);
|
state = state->BindExpr(B, LCtx, Result);
|
||||||
|
|
@ -332,7 +332,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
|
||||||
|
|
||||||
// Compute the type of the result.
|
// Compute the type of the result.
|
||||||
QualType resultType = CastE->getType();
|
QualType resultType = CastE->getType();
|
||||||
if (CastE->isLValue())
|
if (CastE->isGLValue())
|
||||||
resultType = getContext().getPointerType(resultType);
|
resultType = getContext().getPointerType(resultType);
|
||||||
|
|
||||||
bool Failed = false;
|
bool Failed = false;
|
||||||
|
|
@ -381,7 +381,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
|
||||||
case CK_MemberPointerToBoolean: {
|
case CK_MemberPointerToBoolean: {
|
||||||
// Recover some path-sensitivty by conjuring a new value.
|
// Recover some path-sensitivty by conjuring a new value.
|
||||||
QualType resultType = CastE->getType();
|
QualType resultType = CastE->getType();
|
||||||
if (CastE->isLValue())
|
if (CastE->isGLValue())
|
||||||
resultType = getContext().getPointerType(resultType);
|
resultType = getContext().getPointerType(resultType);
|
||||||
const LocationContext *LCtx = Pred->getLocationContext();
|
const LocationContext *LCtx = Pred->getLocationContext();
|
||||||
SVal result = svalBuilder.getConjuredSymbolVal(NULL, CastE, LCtx,
|
SVal result = svalBuilder.getConjuredSymbolVal(NULL, CastE, LCtx,
|
||||||
|
|
@ -408,7 +408,7 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
|
||||||
const LocationContext *LC = Pred->getLocationContext();
|
const LocationContext *LC = Pred->getLocationContext();
|
||||||
state = state->bindCompoundLiteral(CL, LC, ILV);
|
state = state->bindCompoundLiteral(CL, LC, ILV);
|
||||||
|
|
||||||
if (CL->isLValue())
|
if (CL->isGLValue())
|
||||||
B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC)));
|
B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC)));
|
||||||
else
|
else
|
||||||
B.generateNode(CL, Pred, state->BindExpr(CL, LC, ILV));
|
B.generateNode(CL, Pred, state->BindExpr(CL, LC, ILV));
|
||||||
|
|
@ -459,7 +459,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
|
||||||
// UnknownVal.
|
// UnknownVal.
|
||||||
if (InitVal.isUnknown()) {
|
if (InitVal.isUnknown()) {
|
||||||
QualType Ty = InitEx->getType();
|
QualType Ty = InitEx->getType();
|
||||||
if (InitEx->isLValue()) {
|
if (InitEx->isGLValue()) {
|
||||||
Ty = getContext().getPointerType(Ty);
|
Ty = getContext().getPointerType(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -689,7 +689,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U,
|
||||||
}
|
}
|
||||||
|
|
||||||
case UO_Plus:
|
case UO_Plus:
|
||||||
assert(!U->isLValue());
|
assert(!U->isGLValue());
|
||||||
// FALL-THROUGH.
|
// FALL-THROUGH.
|
||||||
case UO_Deref:
|
case UO_Deref:
|
||||||
case UO_AddrOf:
|
case UO_AddrOf:
|
||||||
|
|
@ -712,7 +712,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U,
|
||||||
case UO_LNot:
|
case UO_LNot:
|
||||||
case UO_Minus:
|
case UO_Minus:
|
||||||
case UO_Not: {
|
case UO_Not: {
|
||||||
assert (!U->isLValue());
|
assert (!U->isGLValue());
|
||||||
const Expr *Ex = U->getSubExpr()->IgnoreParens();
|
const Expr *Ex = U->getSubExpr()->IgnoreParens();
|
||||||
ProgramStateRef state = Pred->getState();
|
ProgramStateRef state = Pred->getState();
|
||||||
const LocationContext *LCtx = Pred->getLocationContext();
|
const LocationContext *LCtx = Pred->getLocationContext();
|
||||||
|
|
@ -837,7 +837,7 @@ void ExprEngine::VisitIncrementDecrementOperator(const UnaryOperator* U,
|
||||||
|
|
||||||
// Since the lvalue-to-rvalue conversion is explicit in the AST,
|
// Since the lvalue-to-rvalue conversion is explicit in the AST,
|
||||||
// we bind an l-value if the operator is prefix and an lvalue (in C++).
|
// we bind an l-value if the operator is prefix and an lvalue (in C++).
|
||||||
if (U->isLValue())
|
if (U->isGLValue())
|
||||||
state = state->BindExpr(U, LCtx, loc);
|
state = state->BindExpr(U, LCtx, loc);
|
||||||
else
|
else
|
||||||
state = state->BindExpr(U, LCtx, U->isPostfix() ? V2 : Result);
|
state = state->BindExpr(U, LCtx, U->isPostfix() ? V2 : Result);
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ void ExprEngine::VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred,
|
||||||
else
|
else
|
||||||
ResultTy = CE->getType();
|
ResultTy = CE->getType();
|
||||||
|
|
||||||
if (CE->isLValue())
|
if (CE->isGLValue())
|
||||||
ResultTy = Eng.getContext().getPointerType(ResultTy);
|
ResultTy = Eng.getContext().getPointerType(ResultTy);
|
||||||
|
|
||||||
// Conjure a symbol value to use as the result.
|
// Conjure a symbol value to use as the result.
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ QualType CallOrObjCMessage::getResultType(ASTContext &ctx) const {
|
||||||
} else {
|
} else {
|
||||||
const CallExpr *FunctionCall = CallE.get<const CallExpr *>();
|
const CallExpr *FunctionCall = CallE.get<const CallExpr *>();
|
||||||
|
|
||||||
isLVal = FunctionCall->isLValue();
|
isLVal = FunctionCall->isGLValue();
|
||||||
const Expr *Callee = FunctionCall->getCallee();
|
const Expr *Callee = FunctionCall->getCallee();
|
||||||
if (const FunctionDecl *FD = State->getSVal(Callee, LCtx).getAsFunctionDecl())
|
if (const FunctionDecl *FD = State->getSVal(Callee, LCtx).getAsFunctionDecl())
|
||||||
resultTy = FD->getResultType();
|
resultTy = FD->getResultType();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue