2008-02-01 03:34:24 +08:00
|
|
|
//= RValues.cpp - Abstract RValues for Path-Sens. Value Tracking -*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This files defines RValue, LValue, and NonLValue, classes that represent
|
|
|
|
// abstract r-values for use with path-sensitive value tracking.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "RValues.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
using llvm::dyn_cast;
|
|
|
|
using llvm::cast;
|
|
|
|
using llvm::APSInt;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SymbolManager.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
SymbolID SymbolManager::getSymbol(ParmVarDecl* D) {
|
|
|
|
SymbolID& X = DataToSymbol[D];
|
|
|
|
|
|
|
|
if (!X.isInitialized()) {
|
|
|
|
X = SymbolToData.size();
|
|
|
|
SymbolToData.push_back(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
|
|
|
SymbolManager::SymbolManager() {}
|
|
|
|
SymbolManager::~SymbolManager() {}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-02-06 05:32:43 +08:00
|
|
|
// Values and ValueManager.
|
2008-02-01 03:34:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
ValueManager::~ValueManager() {
|
|
|
|
// Note that the dstor for the contents of APSIntSet will never be called,
|
|
|
|
// so we iterate over the set and invoke the dstor for each APSInt. This
|
|
|
|
// frees an aux. memory allocated to represent very large constants.
|
|
|
|
for (APSIntSetTy::iterator I=APSIntSet.begin(), E=APSIntSet.end(); I!=E; ++I)
|
|
|
|
I->getValue().~APSInt();
|
|
|
|
}
|
|
|
|
|
2008-02-06 05:32:43 +08:00
|
|
|
const APSInt& ValueManager::getValue(const APSInt& X) {
|
2008-02-01 03:34:24 +08:00
|
|
|
llvm::FoldingSetNodeID ID;
|
|
|
|
void* InsertPos;
|
|
|
|
typedef llvm::FoldingSetNodeWrapper<APSInt> FoldNodeTy;
|
|
|
|
|
|
|
|
X.Profile(ID);
|
|
|
|
FoldNodeTy* P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
|
|
|
|
|
|
|
|
if (!P) {
|
|
|
|
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
|
|
|
|
new (P) FoldNodeTy(X);
|
|
|
|
APSIntSet.InsertNode(P, InsertPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *P;
|
|
|
|
}
|
|
|
|
|
2008-02-06 05:32:43 +08:00
|
|
|
const APSInt& ValueManager::getValue(uint64_t X, unsigned BitWidth,
|
|
|
|
bool isUnsigned) {
|
2008-02-01 03:34:24 +08:00
|
|
|
APSInt V(BitWidth, isUnsigned);
|
|
|
|
V = X;
|
|
|
|
return getValue(V);
|
|
|
|
}
|
|
|
|
|
2008-02-06 05:32:43 +08:00
|
|
|
const APSInt& ValueManager::getValue(uint64_t X, QualType T,
|
|
|
|
SourceLocation Loc) {
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
unsigned bits = Ctx.getTypeSize(T, Loc);
|
|
|
|
APSInt V(bits, T->isUnsignedIntegerType());
|
|
|
|
V = X;
|
|
|
|
return getValue(V);
|
|
|
|
}
|
|
|
|
|
2008-02-06 05:32:43 +08:00
|
|
|
const SymIntConstraint&
|
|
|
|
ValueManager::getConstraint(SymbolID sym, BinaryOperator::Opcode Op,
|
|
|
|
const llvm::APSInt& V) {
|
|
|
|
|
|
|
|
llvm::FoldingSetNodeID ID;
|
|
|
|
SymIntConstraint::Profile(ID, sym, Op, V);
|
|
|
|
void* InsertPos;
|
|
|
|
|
|
|
|
SymIntConstraint* C = SymIntCSet.FindNodeOrInsertPos(ID, InsertPos);
|
|
|
|
|
|
|
|
if (!C) {
|
|
|
|
C = (SymIntConstraint*) BPAlloc.Allocate<SymIntConstraint>();
|
|
|
|
new (C) SymIntConstraint(sym, Op, V);
|
|
|
|
SymIntCSet.InsertNode(C, InsertPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *C;
|
|
|
|
}
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-02-01 14:36:40 +08:00
|
|
|
// Transfer function for Casts.
|
2008-02-01 03:34:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
RValue RValue::Cast(ValueManager& ValMgr, Expr* CastExpr) const {
|
2008-02-01 14:36:40 +08:00
|
|
|
switch (getBaseKind()) {
|
|
|
|
default: assert(false && "Invalid RValue."); break;
|
|
|
|
case LValueKind: return cast<LValue>(this)->Cast(ValMgr, CastExpr);
|
|
|
|
case NonLValueKind: return cast<NonLValue>(this)->Cast(ValMgr, CastExpr);
|
|
|
|
case UninitializedKind: case InvalidKind: break;
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
2008-02-01 14:36:40 +08:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
RValue LValue::Cast(ValueManager& ValMgr, Expr* CastExpr) const {
|
|
|
|
if (CastExpr->getType()->isPointerType())
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
assert (CastExpr->getType()->isIntegerType());
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
if (!isa<lval::ConcreteInt>(*this))
|
2008-02-01 14:36:40 +08:00
|
|
|
return InvalidValue();
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
APSInt V = cast<lval::ConcreteInt>(this)->getValue();
|
2008-02-01 14:36:40 +08:00
|
|
|
QualType T = CastExpr->getType();
|
|
|
|
V.setIsUnsigned(T->isUnsignedIntegerType());
|
|
|
|
V.extOrTrunc(ValMgr.getContext().getTypeSize(T, CastExpr->getLocStart()));
|
2008-02-06 05:52:21 +08:00
|
|
|
return nonlval::ConcreteInt(ValMgr.getValue(V));
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
2008-02-01 14:36:40 +08:00
|
|
|
RValue NonLValue::Cast(ValueManager& ValMgr, Expr* CastExpr) const {
|
2008-02-06 05:52:21 +08:00
|
|
|
if (!isa<nonlval::ConcreteInt>(this))
|
2008-02-01 14:36:40 +08:00
|
|
|
return InvalidValue();
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
APSInt V = cast<nonlval::ConcreteInt>(this)->getValue();
|
2008-02-01 14:36:40 +08:00
|
|
|
QualType T = CastExpr->getType();
|
2008-02-06 12:31:33 +08:00
|
|
|
V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType());
|
2008-02-01 14:36:40 +08:00
|
|
|
V.extOrTrunc(ValMgr.getContext().getTypeSize(T, CastExpr->getLocStart()));
|
|
|
|
|
|
|
|
if (CastExpr->getType()->isPointerType())
|
2008-02-06 05:52:21 +08:00
|
|
|
return lval::ConcreteInt(ValMgr.getValue(V));
|
2008-02-01 14:36:40 +08:00
|
|
|
else
|
2008-02-06 05:52:21 +08:00
|
|
|
return nonlval::ConcreteInt(ValMgr.getValue(V));
|
2008-02-01 14:36:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Transfer function dispatch for Non-LValues.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
NonLValue NonLValue::UnaryMinus(ValueManager& ValMgr, UnaryOperator* U) const {
|
|
|
|
switch (getSubKind()) {
|
2008-02-06 05:52:21 +08:00
|
|
|
case nonlval::ConcreteIntKind:
|
|
|
|
return cast<nonlval::ConcreteInt>(this)->UnaryMinus(ValMgr, U);
|
2008-02-01 03:34:24 +08:00
|
|
|
default:
|
|
|
|
return cast<NonLValue>(InvalidValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-05 00:58:30 +08:00
|
|
|
NonLValue NonLValue::BitwiseComplement(ValueManager& ValMgr) const {
|
|
|
|
switch (getSubKind()) {
|
2008-02-06 05:52:21 +08:00
|
|
|
case nonlval::ConcreteIntKind:
|
|
|
|
return cast<nonlval::ConcreteInt>(this)->BitwiseComplement(ValMgr);
|
2008-02-05 00:58:30 +08:00
|
|
|
default:
|
|
|
|
return cast<NonLValue>(InvalidValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
#define NONLVALUE_DISPATCH_CASE(k1,k2,Op)\
|
2008-02-06 05:52:21 +08:00
|
|
|
case (k1##Kind*nonlval::NumKind+k2##Kind):\
|
2008-02-01 03:34:24 +08:00
|
|
|
return cast<k1>(*this).Op(ValMgr,cast<k2>(RHS));
|
|
|
|
|
|
|
|
#define NONLVALUE_DISPATCH(Op)\
|
2008-02-06 05:52:21 +08:00
|
|
|
switch (getSubKind()*nonlval::NumKind+RHS.getSubKind()){\
|
|
|
|
NONLVALUE_DISPATCH_CASE(nonlval::ConcreteInt,nonlval::ConcreteInt,Op)\
|
2008-02-01 03:34:24 +08:00
|
|
|
default:\
|
|
|
|
if (getBaseKind() == UninitializedKind ||\
|
|
|
|
RHS.getBaseKind() == UninitializedKind)\
|
|
|
|
return cast<NonLValue>(UninitializedValue());\
|
|
|
|
assert (!isValid() || !RHS.isValid() && "Missing case.");\
|
|
|
|
break;\
|
|
|
|
}\
|
|
|
|
return cast<NonLValue>(InvalidValue());
|
|
|
|
|
|
|
|
NonLValue NonLValue::Add(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(Add)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::Sub(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(Sub)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::Mul(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(Mul)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::Div(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(Div)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::Rem(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(Rem)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::EQ(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(EQ)
|
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::NE(ValueManager& ValMgr, const NonLValue& RHS) const {
|
|
|
|
NONLVALUE_DISPATCH(NE)
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NONLVALUE_DISPATCH_CASE
|
|
|
|
#undef NONLVALUE_DISPATCH
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Transfer function dispatch for LValues.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
NonLValue LValue::EQ(ValueManager& ValMgr, const LValue& RHS) const {
|
|
|
|
switch (getSubKind()) {
|
|
|
|
default:
|
|
|
|
assert(false && "EQ not implemented for this LValue.");
|
|
|
|
return cast<NonLValue>(InvalidValue());
|
2008-02-01 14:36:40 +08:00
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
case lval::ConcreteIntKind:
|
|
|
|
if (isa<lval::ConcreteInt>(RHS)) {
|
|
|
|
bool b = cast<lval::ConcreteInt>(this)->getValue() ==
|
|
|
|
cast<lval::ConcreteInt>(RHS).getValue();
|
|
|
|
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, b);
|
|
|
|
}
|
|
|
|
else if (isa<lval::SymbolVal>(RHS)) {
|
|
|
|
|
|
|
|
const SymIntConstraint& C =
|
|
|
|
ValMgr.getConstraint(cast<lval::SymbolVal>(RHS).getSymbol(),
|
|
|
|
BinaryOperator::EQ,
|
|
|
|
cast<lval::ConcreteInt>(this)->getValue());
|
|
|
|
|
|
|
|
return nonlval::SymIntConstraintVal(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lval::SymbolValKind: {
|
|
|
|
if (isa<lval::ConcreteInt>(RHS)) {
|
|
|
|
|
|
|
|
const SymIntConstraint& C =
|
|
|
|
ValMgr.getConstraint(cast<lval::SymbolVal>(this)->getSymbol(),
|
|
|
|
BinaryOperator::EQ,
|
|
|
|
cast<lval::ConcreteInt>(RHS).getValue());
|
|
|
|
|
|
|
|
return nonlval::SymIntConstraintVal(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert (!isa<lval::SymbolVal>(RHS) && "FIXME: Implement unification.");
|
2008-02-01 03:34:24 +08:00
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
break;
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
2008-02-06 07:08:41 +08:00
|
|
|
|
|
|
|
case lval::DeclValKind:
|
|
|
|
if (isa<lval::DeclVal>(RHS)) {
|
|
|
|
bool b = cast<lval::DeclVal>(*this) == cast<lval::DeclVal>(RHS);
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
2008-02-06 07:08:41 +08:00
|
|
|
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, false);
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue LValue::NE(ValueManager& ValMgr, const LValue& RHS) const {
|
|
|
|
switch (getSubKind()) {
|
|
|
|
default:
|
2008-02-06 07:08:41 +08:00
|
|
|
assert(false && "NE not implemented for this LValue.");
|
2008-02-01 03:34:24 +08:00
|
|
|
return cast<NonLValue>(InvalidValue());
|
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
case lval::ConcreteIntKind:
|
|
|
|
if (isa<lval::ConcreteInt>(RHS)) {
|
|
|
|
bool b = cast<lval::ConcreteInt>(this)->getValue() !=
|
|
|
|
cast<lval::ConcreteInt>(RHS).getValue();
|
|
|
|
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, b);
|
|
|
|
}
|
|
|
|
else if (isa<lval::SymbolVal>(RHS)) {
|
|
|
|
|
|
|
|
const SymIntConstraint& C =
|
|
|
|
ValMgr.getConstraint(cast<lval::SymbolVal>(RHS).getSymbol(),
|
|
|
|
BinaryOperator::NE,
|
|
|
|
cast<lval::ConcreteInt>(this)->getValue());
|
|
|
|
|
|
|
|
return nonlval::SymIntConstraintVal(C);
|
|
|
|
}
|
2008-02-01 14:36:40 +08:00
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
break;
|
2008-02-01 14:36:40 +08:00
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
case lval::SymbolValKind: {
|
|
|
|
if (isa<lval::ConcreteInt>(RHS)) {
|
|
|
|
|
|
|
|
const SymIntConstraint& C =
|
|
|
|
ValMgr.getConstraint(cast<lval::SymbolVal>(this)->getSymbol(),
|
|
|
|
BinaryOperator::NE,
|
|
|
|
cast<lval::ConcreteInt>(RHS).getValue());
|
|
|
|
|
|
|
|
return nonlval::SymIntConstraintVal(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert (!isa<lval::SymbolVal>(RHS) && "FIXME: Implement sym !=.");
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case lval::DeclValKind:
|
|
|
|
if (isa<lval::DeclVal>(RHS)) {
|
|
|
|
bool b = cast<lval::DeclVal>(*this) == cast<lval::DeclVal>(RHS);
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
2008-02-06 07:08:41 +08:00
|
|
|
|
|
|
|
return NonLValue::GetIntTruthValue(ValMgr, true);
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Utility methods for constructing Non-LValues.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
NonLValue NonLValue::GetValue(ValueManager& ValMgr, uint64_t X, QualType T,
|
|
|
|
SourceLocation Loc) {
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
return nonlval::ConcreteInt(ValMgr.getValue(X, T, Loc));
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NonLValue NonLValue::GetValue(ValueManager& ValMgr, IntegerLiteral* I) {
|
2008-02-06 05:52:21 +08:00
|
|
|
return nonlval::ConcreteInt(ValMgr.getValue(APSInt(I->getValue(),
|
|
|
|
I->getType()->isUnsignedIntegerType())));
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
RValue RValue::GetSymbolValue(SymbolManager& SymMgr, ParmVarDecl* D) {
|
|
|
|
QualType T = D->getType();
|
|
|
|
|
|
|
|
if (T->isPointerType() || T->isReferenceType())
|
2008-02-06 05:52:21 +08:00
|
|
|
return lval::SymbolVal(SymMgr.getSymbol(D));
|
2008-02-01 03:34:24 +08:00
|
|
|
else
|
2008-02-06 05:52:21 +08:00
|
|
|
return nonlval::SymbolVal(SymMgr.getSymbol(D));
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pretty-Printing.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void RValue::print(std::ostream& Out) const {
|
|
|
|
switch (getBaseKind()) {
|
|
|
|
case InvalidKind:
|
|
|
|
Out << "Invalid";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NonLValueKind:
|
|
|
|
cast<NonLValue>(this)->print(Out);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LValueKind:
|
|
|
|
cast<LValue>(this)->print(Out);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UninitializedKind:
|
|
|
|
Out << "Uninitialized";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
assert (false && "Invalid RValue.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
static void printOpcode(std::ostream& Out, BinaryOperator::Opcode Op) {
|
|
|
|
switch (Op) {
|
|
|
|
case BinaryOperator::EQ: Out << "=="; break;
|
|
|
|
case BinaryOperator::NE: Out << "!="; break;
|
|
|
|
default: assert(false && "Not yet implemented.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
void NonLValue::print(std::ostream& Out) const {
|
|
|
|
switch (getSubKind()) {
|
2008-02-06 05:52:21 +08:00
|
|
|
case nonlval::ConcreteIntKind:
|
|
|
|
Out << cast<nonlval::ConcreteInt>(this)->getValue().toString();
|
2008-02-01 03:34:24 +08:00
|
|
|
break;
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
case nonlval::SymbolValKind:
|
2008-02-06 07:08:41 +08:00
|
|
|
Out << '$' << cast<nonlval::SymbolVal>(this)->getSymbol();
|
2008-02-01 03:34:24 +08:00
|
|
|
break;
|
2008-02-06 07:08:41 +08:00
|
|
|
|
|
|
|
case nonlval::SymIntConstraintValKind: {
|
|
|
|
const nonlval::SymIntConstraintVal& C =
|
|
|
|
*cast<nonlval::SymIntConstraintVal>(this);
|
|
|
|
|
|
|
|
Out << '$' << C.getConstraint().getSymbol() << ' ';
|
|
|
|
printOpcode(Out, C.getConstraint().getOpcode());
|
|
|
|
Out << ' ' << C.getConstraint().getInt().toString();
|
|
|
|
break;
|
|
|
|
}
|
2008-02-01 03:34:24 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
assert (false && "Pretty-printed not implemented for this NonLValue.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-06 07:08:41 +08:00
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
void LValue::print(std::ostream& Out) const {
|
2008-02-01 14:36:40 +08:00
|
|
|
switch (getSubKind()) {
|
2008-02-06 05:52:21 +08:00
|
|
|
case lval::ConcreteIntKind:
|
|
|
|
Out << cast<lval::ConcreteInt>(this)->getValue().toString()
|
2008-02-01 14:36:40 +08:00
|
|
|
<< " (LValue)";
|
|
|
|
break;
|
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
case lval::SymbolValKind:
|
2008-02-06 07:08:41 +08:00
|
|
|
Out << '$' << cast<lval::SymbolVal>(this)->getSymbol();
|
2008-02-01 03:34:24 +08:00
|
|
|
break;
|
2008-02-06 12:31:33 +08:00
|
|
|
|
2008-02-06 05:52:21 +08:00
|
|
|
case lval::DeclValKind:
|
2008-02-01 03:34:24 +08:00
|
|
|
Out << '&'
|
2008-02-06 05:52:21 +08:00
|
|
|
<< cast<lval::DeclVal>(this)->getDecl()->getIdentifier()->getName();
|
2008-02-01 03:34:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
assert (false && "Pretty-printed not implemented for this LValue.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|