using std::vector;
using std::ostream;
-static RegisterPass<PrintModulePass> X("printm", "Print module to stderr");
-static RegisterPass<PrintFunctionPass> Y("print", "Print function to stderr");
+static RegisterPass<PrintModulePass>
+X("printm", "Print module to stderr",PassInfo::Analysis|PassInfo::Optimization);
+static RegisterPass<PrintFunctionPass>
+Y("print","Print function to stderr",PassInfo::Analysis|PassInfo::Optimization);
static void WriteAsOperandInternal(ostream &Out, const Value *V, bool PrintName,
map<const Type *, string> &TypeTable,
(unsigned char)cast<ConstantSInt>(CA->getOperand(i))->getValue() :
(unsigned char)cast<ConstantUInt>(CA->getOperand(i))->getValue();
- if (isprint(C) && C != '"') {
+ if (isprint(C) && C != '"' && C != '\\') {
Out << C;
} else {
Out << '\\'
Out << "<pointer reference without context info>";
}
- } else if (const ConstantExpr *CE=dyn_cast<ConstantExpr>(CV)) {
+ } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
Out << CE->getOpcodeName();
bool isGEP = CE->getOpcode() == Instruction::GetElementPtr;
- Out << (isGEP? " (" : " ");
+ Out << " (";
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
printTypeInt(Out, (*OI)->getType(), TypeTable);
WriteAsOperandInternal(Out, *OI, PrintName, TypeTable, Table);
if (OI+1 != CE->op_end())
- Out << ", "; // ((isGEP && OI == CE->op_begin())? " " : ", ");
+ Out << ", ";
}
- if (isGEP)
- Out << ")";
+ if (CE->getOpcode() == Instruction::Cast) {
+ Out << " to ";
+ printTypeInt(Out, CE->getType(), TypeTable);
+ }
+ Out << ")";
+
} else {
Out << "<placeholder or erroneous Constant>";
}