[analyzer]Fixup r146336.

Forgot to commit the Header files. 
Rename generateUnknownVal -> makeGenericVal.

llvm-svn: 146337
This commit is contained in:
Anna Zaks 2011-12-10 23:42:38 +00:00
parent ecd730085d
commit 170fdf1b5a
4 changed files with 58 additions and 10 deletions

View File

@ -109,7 +109,7 @@ public:
/// handle the given binary expression. Depending on the state, decides to
/// either keep the expression or forget the history and generate an
/// UnknownVal.
SVal generateUnknownVal(const ProgramState *state, BinaryOperator::Opcode op,
SVal makeGenericVal(const ProgramState *state, BinaryOperator::Opcode op,
NonLoc lhs, NonLoc rhs, QualType resultTy);
SVal evalBinOp(const ProgramState *state, BinaryOperator::Opcode op,
@ -253,6 +253,9 @@ public:
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
const llvm::APSInt& rhs, QualType type);
NonLoc makeNonLoc(const llvm::APSInt& rhs, BinaryOperator::Opcode op,
const SymExpr *lhs, QualType type);
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType type);

View File

@ -48,7 +48,7 @@ public:
MetadataKind,
BEGIN_SYMBOLS = RegionValueKind,
END_SYMBOLS = MetadataKind,
SymIntKind, SymSymKind, CastSymbolKind };
SymIntKind, IntSymKind, SymSymKind, CastSymbolKind };
private:
Kind K;
@ -379,6 +379,47 @@ public:
}
};
/// IntSymExpr - Represents symbolic expression like 3 - 'x'.
class IntSymExpr : public SymExpr {
const llvm::APSInt& LHS;
BinaryOperator::Opcode Op;
const SymExpr *RHS;
QualType T;
public:
IntSymExpr(const llvm::APSInt& lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType t)
: SymExpr(IntSymKind), LHS(lhs), Op(op), RHS(rhs), T(t) {}
QualType getType(ASTContext &C) const { return T; }
BinaryOperator::Opcode getOpcode() const { return Op; }
void dumpToStream(raw_ostream &os) const;
const SymExpr *getRHS() const { return RHS; }
const llvm::APSInt &getLHS() const { return LHS; }
static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
BinaryOperator::Opcode op, const SymExpr *rhs,
QualType t) {
ID.AddInteger((unsigned) IntSymKind);
ID.AddPointer(&lhs);
ID.AddInteger(op);
ID.AddPointer(rhs);
ID.Add(t);
}
void Profile(llvm::FoldingSetNodeID& ID) {
Profile(ID, LHS, Op, RHS, T);
}
// Implement isa<T> support.
static inline bool classof(const SymExpr *SE) {
return SE->getKind() == IntSymKind;
}
};
/// SymSymExpr - Represents symbolic expression like 'x' + 'y'.
class SymSymExpr : public SymExpr {
const SymExpr *LHS;
@ -479,6 +520,10 @@ public:
return getSymIntExpr(&lhs, op, rhs, t);
}
const IntSymExpr *getIntSymExpr(const llvm::APSInt& lhs,
BinaryOperator::Opcode op,
const SymExpr *rhs, QualType t);
const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType t);

View File

@ -167,7 +167,7 @@ DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block,
//===----------------------------------------------------------------------===//
SVal SValBuilder::generateUnknownVal(const ProgramState *State,
SVal SValBuilder::makeGenericVal(const ProgramState *State,
BinaryOperator::Opcode Op,
NonLoc LHS, NonLoc RHS,
QualType ResultTy) {

View File

@ -303,7 +303,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
while (1) {
switch (lhs.getSubKind()) {
default:
return generateUnknownVal(state, op, lhs, rhs, resultTy);
return makeGenericVal(state, op, lhs, rhs, resultTy);
case nonloc::LocAsIntegerKind: {
Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
switch (rhs.getSubKind()) {
@ -326,7 +326,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
return makeTruthVal(true, resultTy);
default:
// This case also handles pointer arithmetic.
return generateUnknownVal(state, op, lhs, rhs, resultTy);
return makeGenericVal(state, op, lhs, rhs, resultTy);
}
}
}
@ -388,9 +388,9 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
if (lhsValue == 0)
// At this point lhs and rhs have been swapped.
return rhs;
return generateUnknownVal(state, op, rhs, lhs, resultTy);
return makeGenericVal(state, op, rhs, lhs, resultTy);
default:
return generateUnknownVal(state, op, rhs, lhs, resultTy);
return makeGenericVal(state, op, rhs, lhs, resultTy);
}
}
}
@ -405,7 +405,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
dyn_cast<SymIntExpr>(selhs->getSymbol());
if (!symIntExpr)
return generateUnknownVal(state, op, lhs, rhs, resultTy);
return makeGenericVal(state, op, lhs, rhs, resultTy);
// Is this a logical not? (!x is represented as x == 0.)
if (op == BO_EQ && rhs.isZeroConstant()) {
@ -453,7 +453,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
// For now, only handle expressions whose RHS is a constant.
const nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs);
if (!rhsInt)
return generateUnknownVal(state, op, lhs, rhs, resultTy);
return makeGenericVal(state, op, lhs, rhs, resultTy);
// If both the LHS and the current expression are additive,
// fold their constants.
@ -538,7 +538,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
resultTy);
}
return generateUnknownVal(state, op, lhs, rhs, resultTy);
return makeGenericVal(state, op, lhs, rhs, resultTy);
}
}
}