"llvm/git@repo.hca.bsc.es:rferrer/llvm-epi-0.8.git" did not exist on "56f7cd255b1e8a34d1b50776abb5bb45e0aae378"
Newer
Older
Ted Kremenek
committed
return;
}
switch (S->getStmtClass()) {
case Stmt::BinaryOperatorClass:
case Stmt::CompoundAssignOperatorClass:
Ted Kremenek
committed
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst);
break;
case Stmt::UnaryOperatorClass:
VisitUnaryOperator(cast<UnaryOperator>(S), Pred, Dst);
break;
Ted Kremenek
committed
case Stmt::ParenExprClass:
Visit(cast<ParenExpr>(S)->getSubExpr(), Pred, Dst);
break;
case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
VisitCast(C, C->getSubExpr(), Pred, Dst);
break;
}
case Stmt::CastExprClass: {
CastExpr* C = cast<CastExpr>(S);
VisitCast(C, C->getSubExpr(), Pred, Dst);
break;
}
Ted Kremenek
committed
default:
Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
break;
}
//===----------------------------------------------------------------------===//
// Driver.
//===----------------------------------------------------------------------===//
#ifndef NDEBUG
namespace llvm {
template<>
struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
public DefaultDOTGraphTraits {
Ted Kremenek
committed
static void PrintKind(std::ostringstream& Out, ValueKey::Kind kind) {
switch (kind) {
case ValueKey::IsSubExp: Out << "Sub-Expressions:\\l"; break;
case ValueKey::IsDecl: Out << "Variables:\\l"; break;
case ValueKey::IsBlkExpr: Out << "Block-level Expressions:\\l"; break;
default: assert (false && "Unknown ValueKey type.");
}
}
static std::string getNodeLabel(const GRConstants::NodeTy* N, void*) {
std::ostringstream Out;
Ted Kremenek
committed
// Program Location.
ProgramPoint Loc = N->getLocation();
switch (Loc.getKind()) {
case ProgramPoint::BlockEntranceKind:
Out << "Block Entrance: B"
<< cast<BlockEntrance>(Loc).getBlock()->getBlockID();
break;
case ProgramPoint::BlockExitKind:
assert (false);
break;
case ProgramPoint::PostStmtKind: {
const PostStmt& L = cast<PostStmt>(Loc);
Ted Kremenek
committed
Out << "(" << (void*) L.getStmt() << ") ";
L.getStmt()->printPretty(Out);
break;
}
default: {
const BlockEdge& E = cast<BlockEdge>(Loc);
Out << "Edge: (B" << E.getSrc()->getBlockID() << ", B"
<< E.getDst()->getBlockID() << ')';
}
}
Ted Kremenek
committed
Out << "\\|";
GRConstants::StateTy M = N->getState();
bool isFirst = true;
Ted Kremenek
committed
ValueKey::Kind kind;
for (GRConstants::StateTy::iterator I=M.begin(), E=M.end(); I!=E; ++I) {
Ted Kremenek
committed
if (!isFirst) {
ValueKey::Kind newKind = I.getKey().getKind();
if (newKind != kind) {
Out << "\\l\\l";
PrintKind(Out, newKind);
}
else
Out << "\\l";
kind = newKind;
}
else {
kind = I.getKey().getKind();
PrintKind(Out, kind);
isFirst = false;
Ted Kremenek
committed
}
Out << ' ';
if (ValueDecl* V = dyn_cast<ValueDecl>(I.getKey())) {
Ted Kremenek
committed
Out << V->getName();
}
else {
Stmt* E = cast<Stmt>(I.getKey());
Ted Kremenek
committed
Out << " (" << (void*) E << ") ";
E->printPretty(Out);
}
Ted Kremenek
committed
Out << " : ";
Ted Kremenek
committed
I.getData().print(Out);
}
Ted Kremenek
committed
Out << "\\l";
return Out.str();
}
};
} // end llvm namespace
#endif
void RunGRConstants(CFG& cfg, ASTContext& Ctx) {
GREngine<GRConstants> Engine(cfg, Ctx);
Engine.ExecuteWorkList();
#ifndef NDEBUG
llvm::ViewGraph(*Engine.getGraph().roots_begin(),"GRConstants");
#endif
Ted Kremenek
committed
} // end clang namespace