Change WriteTypeSymbolic to not put a space out before types, also, remove

the old std::ostream version.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65720 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-02-28 21:05:51 +00:00
parent 534361e7e1
commit c287137ce7
4 changed files with 20 additions and 27 deletions

View File

@ -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

View File

@ -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 Type *>::const_iterator I = UsedTypes.begin(),
E = UsedTypes.end(); I != E; ++I) {
WriteTypeSymbolic(o << " ", *I, M);
o << "\n";
RO << " ";
WriteTypeSymbolic(RO, *I, M);
RO << '\n';
}
}

View File

@ -259,7 +259,7 @@ void TypePrinting::CalcTypeName(const Type *Ty,
}
case Type::ArrayTyID: {
const ArrayType *ATy = cast<ArrayType>(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(); }

View File

@ -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 <algorithm>
#include <sstream>
#include <cstdarg>
@ -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);
}