зеркало из https://github.com/microsoft/clang-1.git
Implemented transfer function logic for unary '+'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d8e9f0dc73
Коммит
90e420321f
|
@ -670,6 +670,12 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U,
|
|||
break;
|
||||
}
|
||||
|
||||
case UnaryOperator::Plus: {
|
||||
const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
|
||||
Nodify(Dst, U, N1, SetValue(St, U, EvalPlus(ValMgr, U, R1)));
|
||||
break;
|
||||
}
|
||||
|
||||
case UnaryOperator::Not: {
|
||||
const NonLValue& R1 = cast<NonLValue>(GetValue(St, U->getSubExpr()));
|
||||
Nodify(Dst, U, N1, SetValue(St, U, EvalComplement(ValMgr, R1)));
|
||||
|
|
|
@ -112,6 +112,20 @@ NonLValue GRSimpleVals::EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
|
|||
}
|
||||
}
|
||||
|
||||
NonLValue GRSimpleVals::EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X) {
|
||||
|
||||
assert (!isa<UnknownVal>(X) && !isa<UninitializedVal>(X));
|
||||
|
||||
switch (X.getSubKind()) {
|
||||
case nonlval::ConcreteIntKind:
|
||||
return cast<nonlval::ConcreteInt>(X).EvalPlus(ValMgr, U);
|
||||
default:
|
||||
return cast<NonLValue>(UnknownVal());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NonLValue GRSimpleVals::EvalComplement(ValueManager& ValMgr, NonLValue X) {
|
||||
|
||||
assert (!isa<UnknownVal>(X) && !isa<UninitializedVal>(X));
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X);
|
||||
|
||||
virtual NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X);
|
||||
|
||||
virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X);
|
||||
|
||||
// Binary Operators.
|
||||
|
|
|
@ -77,6 +77,13 @@ nonlval::ConcreteInt::EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const {
|
|||
return ValMgr.getValue(-getValue());
|
||||
}
|
||||
|
||||
nonlval::ConcreteInt
|
||||
nonlval::ConcreteInt::EvalPlus(ValueManager& ValMgr, UnaryOperator* U) const {
|
||||
assert (U->getType() == U->getSubExpr()->getType());
|
||||
assert (U->getType()->isIntegerType());
|
||||
return ValMgr.getValue(getValue());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Transfer function dispatch for LValues.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -347,6 +347,14 @@ public:
|
|||
return TF->EvalMinus(ValMgr, U, X);
|
||||
}
|
||||
|
||||
inline NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X) {
|
||||
if (isa<UnknownVal>(X) || isa<UninitializedVal>(X))
|
||||
return X;
|
||||
|
||||
return TF->EvalPlus(ValMgr, U, X);
|
||||
}
|
||||
|
||||
inline NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) {
|
||||
if (isa<UnknownVal>(X) || isa<UninitializedVal>(X))
|
||||
return X;
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
virtual NonLValue EvalMinus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X) = 0;
|
||||
|
||||
virtual NonLValue EvalPlus(ValueManager& ValMgr, UnaryOperator* U,
|
||||
NonLValue X) = 0;
|
||||
|
||||
virtual NonLValue EvalComplement(ValueManager& ValMgr, NonLValue X) = 0;
|
||||
|
||||
// Binary Operators.
|
||||
|
|
|
@ -198,6 +198,7 @@ namespace nonlval {
|
|||
|
||||
ConcreteInt EvalComplement(ValueManager& ValMgr) const;
|
||||
ConcreteInt EvalMinus(ValueManager& ValMgr, UnaryOperator* U) const;
|
||||
ConcreteInt EvalPlus(ValueManager& ValMgr, UnaryOperator* U) const;
|
||||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const RValue* V) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче