diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h index c9f8edb3524..8e79b272b08 100644 --- a/include/llvm/Assembly/Writer.h +++ b/include/llvm/Assembly/Writer.h @@ -27,10 +27,9 @@ class Value; class raw_ostream; // WriteTypeSymbolic - This attempts to write the specified type as a symbolic -// type, iff there is an entry in the Module's symbol table for the specified -// type or one of its component types. This is slower than a simple x << Type; +// type, if there is an entry in the Module's symbol table for the specified +// type or one of its component types. // -void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); void WriteTypeSymbolic(raw_ostream &, const Type *, const Module *M); // WriteAsOperand - Write the name of the specified value out to the specified diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 88a180ae521..920ee374555 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; char FindUsedTypes::ID = 0; @@ -91,11 +92,13 @@ bool FindUsedTypes::runOnModule(Module &m) { // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. // -void FindUsedTypes::print(std::ostream &o, const Module *M) const { - o << "Types in use by this module:\n"; +void FindUsedTypes::print(std::ostream &OS, const Module *M) const { + raw_os_ostream RO(OS); + RO << "Types in use by this module:\n"; for (std::set::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) { - WriteTypeSymbolic(o << " ", *I, M); - o << "\n"; + RO << " "; + WriteTypeSymbolic(RO, *I, M); + RO << '\n'; } } diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 7a4dcbce800..bd3f0b7df95 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -259,7 +259,7 @@ void TypePrinting::CalcTypeName(const Type *Ty, } case Type::ArrayTyID: { const ArrayType *ATy = cast(Ty); - Result << "[" << ATy->getNumElements() << " x "; + Result << '[' << ATy->getNumElements() << " x "; CalcTypeName(ATy->getElementType(), TypeStack, Result); Result << ']'; break; @@ -307,8 +307,6 @@ void TypePrinting::print(const Type *Ty) { std::string TypeName; raw_string_ostream TypeOS(TypeName); - - CalcTypeName(Ty, TypeStack, TypeOS); OS << TypeOS.str(); @@ -340,23 +338,12 @@ void TypePrinting::printAtLeastOneLevel(const Type *Ty) { /// WriteTypeSymbolic - This attempts to write the specified type as a symbolic /// type, iff there is an entry in the modules symbol table for the specified -/// type or one of it's component types. This is slower than a simple x << Type +/// type or one of it's component types. /// void llvm::WriteTypeSymbolic(raw_ostream &Out, const Type *Ty, const Module *M){ - // FIXME: Remove this space. - Out << ' '; - TypePrinting(M, Out).print(Ty); } -// std::ostream adaptor. -void llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty, - const Module *M) { - raw_os_ostream RO(Out); - WriteTypeSymbolic(RO, Ty, M); -} - - //===----------------------------------------------------------------------===// // SlotTracker Class: Enumerate slot numbers for unnamed values //===----------------------------------------------------------------------===// @@ -1712,9 +1699,6 @@ void Value::print(std::ostream &O, AssemblyAnnotationWriter *AAW) const { // Value::dump - allow easy printing of Values from the debugger. void Value::dump() const { print(errs()); errs() << '\n'; errs().flush(); } -// Type::dump - allow easy printing of Types from the debugger. -void Type::dump() const { print(errs()); errs() << '\n'; errs().flush(); } - // Type::dump - allow easy printing of Types from the debugger. // This one uses type names from the given context module void Type::dump(const Module *Context) const { @@ -1723,6 +1707,10 @@ void Type::dump(const Module *Context) const { errs().flush(); } +// Type::dump - allow easy printing of Types from the debugger. +void Type::dump() const { dump(0); } + + // Module::dump() - Allow printing of Modules from the debugger. void Module::dump() const { print(errs(), 0); errs().flush(); } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 99a5b92e5ff..784a66fa09d 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -61,6 +61,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/raw_ostream.h" #include #include #include @@ -290,8 +291,10 @@ namespace { } void WriteType(const Type *T) { - if ( !T ) return; - WriteTypeSymbolic(msgs, T, Mod ); + if (!T) return; + raw_os_ostream RO(msgs); + RO << ' '; + WriteTypeSymbolic(RO, T, Mod); }