Skip to content

Commit acdde6f

Browse files
committed
Rename IsPointerType to LVal::IsLValType, and update CFRefCount::EvalSummary to use IsLValType when conjuring symbols for return values (this fixes a bug with an assertion firing in the analyzer when two qualified objective-c types were compared).
llvm-svn: 50924
1 parent fa8e15b commit acdde6f

File tree

5 files changed

+21
-29
lines changed

5 files changed

+21
-29
lines changed

clang/include/clang/Analysis/PathSensitive/GRExprEngine.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -648,18 +648,6 @@ class GRExprEngine {
648648

649649
ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
650650
};
651-
} // end clang namespace
652-
653-
654-
//===----------------------------------------------------------------------===//
655-
// Utility
656-
//===----------------------------------------------------------------------===//
657-
658-
namespace clang {
659-
660-
static inline bool IsPointerType(QualType T) {
661-
return T->isPointerType() || T->isObjCQualifiedIdType();
662-
}
663651

664652
} // end clang namespace
665653

clang/include/clang/Analysis/PathSensitive/RValues.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ class LVal : public RVal {
157157
static inline bool classof(const RVal* V) {
158158
return V->getBaseKind() == LValKind;
159159
}
160+
161+
static inline bool IsLValType(QualType T) {
162+
return T->isPointerType() || T->isObjCQualifiedIdType();
163+
}
160164
};
161165

162166
//==------------------------------------------------------------------------==//

clang/lib/Analysis/CFRefCount.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,9 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<ValueState>& Dst,
12301230
unsigned Count = Builder.getCurrentBlockCount();
12311231
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count);
12321232

1233-
RVal X = Ex->getType()->isPointerType()
1234-
? cast<RVal>(lval::SymbolVal(Sym))
1235-
: cast<RVal>(nonlval::SymbolVal(Sym));
1233+
RVal X = LVal::IsLValType(Ex->getType())
1234+
? cast<RVal>(lval::SymbolVal(Sym))
1235+
: cast<RVal>(nonlval::SymbolVal(Sym));
12361236

12371237
St = StateMgr.SetRVal(St, Ex, X, Eng.getCFG().isBlkExpr(Ex), false);
12381238
}

clang/lib/Analysis/GRExprEngine.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred,
795795
// abstract address of the base object.
796796
NodeSet Tmp;
797797

798-
if (IsPointerType(Base->getType())) // Base always is an LVal.
798+
if (LVal::IsLValType(Base->getType())) // Base always is an LVal.
799799
Visit(Base, Pred, Tmp);
800800
else
801801
VisitLVal(Base, Pred, Tmp);
@@ -842,7 +842,7 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
842842

843843
if (asLVal) {
844844

845-
if (IsPointerType(Base->getType())) // Base always is an LVal.
845+
if (LVal::IsLValType(Base->getType())) // Base always is an LVal.
846846
Visit(Base, Pred, Tmp);
847847
else
848848
VisitLVal(Base, Pred, Tmp);
@@ -869,7 +869,7 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
869869
ValueState* St = GetState(*I);
870870
RVal BaseV = GetRVal(St, Base);
871871

872-
if (IsPointerType(Base->getType())) {
872+
if (LVal::IsLValType(Base->getType())) {
873873

874874
assert (M->isArrow());
875875

@@ -1389,7 +1389,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
13891389
}
13901390

13911391
// Check for casts from pointers to integers.
1392-
if (T->isIntegerType() && IsPointerType(ExTy)) {
1392+
if (T->isIntegerType() && LVal::IsLValType(ExTy)) {
13931393
unsigned bits = getContext().getTypeSize(ExTy);
13941394

13951395
// FIXME: Determine if the number of bits of the target type is
@@ -1402,7 +1402,7 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
14021402
}
14031403

14041404
// Check for casts from integers to pointers.
1405-
if (IsPointerType(T) && ExTy->isIntegerType())
1405+
if (LVal::IsLValType(T) && ExTy->isIntegerType())
14061406
if (nonlval::LValAsInteger *LV = dyn_cast<nonlval::LValAsInteger>(&V)) {
14071407
// Just unpackage the lval and return it.
14081408
V = LV->getLVal();
@@ -1481,7 +1481,7 @@ void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D,
14811481

14821482
QualType T = VD->getType();
14831483

1484-
if (IsPointerType(T))
1484+
if (LVal::IsLValType(T))
14851485
St = SetRVal(St, lval::DeclVal(VD),
14861486
lval::ConcreteInt(BasicVals.getValue(0, T)));
14871487
else if (T->isIntegerType())
@@ -1499,7 +1499,7 @@ void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D,
14991499

15001500
QualType T = VD->getType();
15011501

1502-
if (IsPointerType(T) || T->isIntegerType()) {
1502+
if (LVal::IsLValType(T) || T->isIntegerType()) {
15031503

15041504
RVal V = Ex ? GetRVal(St, Ex) : UndefinedVal();
15051505

@@ -1510,7 +1510,7 @@ void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D,
15101510
unsigned Count = Builder->getCurrentBlockCount();
15111511
SymbolID Sym = SymMgr.getConjuredSymbol(Ex, Count);
15121512

1513-
V = IsPointerType(Ex->getType())
1513+
V = LVal::IsLValType(Ex->getType())
15141514
? cast<RVal>(lval::SymbolVal(Sym))
15151515
: cast<RVal>(nonlval::SymbolVal(Sym));
15161516
}
@@ -1965,7 +1965,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
19651965
unsigned Count = Builder->getCurrentBlockCount();
19661966
SymbolID Sym = SymMgr.getConjuredSymbol(B->getRHS(), Count);
19671967

1968-
RightV = IsPointerType(B->getRHS()->getType())
1968+
RightV = LVal::IsLValType(B->getRHS()->getType())
19691969
? cast<RVal>(lval::SymbolVal(Sym))
19701970
: cast<RVal>(nonlval::SymbolVal(Sym));
19711971
}

clang/lib/Analysis/GRSimpleVals.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, NonLVal X, QualType T) {
379379
BasicValueFactory& BasicVals = Eng.getBasicVals();
380380

381381
llvm::APSInt V = cast<nonlval::ConcreteInt>(X).getValue();
382-
V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
382+
V.setIsUnsigned(T->isUnsignedIntegerType() || LVal::IsLValType(T));
383383
V.extOrTrunc(Eng.getContext().getTypeSize(T));
384384

385-
if (IsPointerType(T))
385+
if (LVal::IsLValType(T))
386386
return lval::ConcreteInt(BasicVals.getValue(V));
387387
else
388388
return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -398,7 +398,7 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
398398
// can be introduced by the frontend for corner cases, e.g
399399
// casting from va_list* to __builtin_va_list&.
400400
//
401-
if (IsPointerType(T) || T->isReferenceType())
401+
if (LVal::IsLValType(T) || T->isReferenceType())
402402
return X;
403403

404404
assert (T->isIntegerType());
@@ -409,7 +409,7 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
409409
BasicValueFactory& BasicVals = Eng.getBasicVals();
410410

411411
llvm::APSInt V = cast<lval::ConcreteInt>(X).getValue();
412-
V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
412+
V.setIsUnsigned(T->isUnsignedIntegerType() || LVal::IsLValType(T));
413413
V.extOrTrunc(Eng.getContext().getTypeSize(T));
414414

415415
return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -672,7 +672,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<ValueState>& Dst,
672672
unsigned Count = Builder.getCurrentBlockCount();
673673
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count);
674674

675-
RVal X = IsPointerType(CE->getType())
675+
RVal X = LVal::IsLValType(CE->getType())
676676
? cast<RVal>(lval::SymbolVal(Sym))
677677
: cast<RVal>(nonlval::SymbolVal(Sym));
678678

0 commit comments

Comments
 (0)