X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FIPA%2FFindUsedTypes.cpp;h=c4fb0b9a4e3ddc8fee591159df4ed6ebe93d9012;hb=03a5f139fb7d3e9c49fe95aea4c717fab2285d82;hp=a71efb09a46a21949e6d9990c0ddaa1695db076b;hpb=dedf2bd5a34dac25e4245f58bb902ced6b64edd9;p=oota-llvm.git diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index a71efb09a46..c4fb0b9a4e3 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -17,16 +17,14 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/SymbolTable.h" -#include "llvm/Assembly/CachedWriter.h" +#include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; -static RegisterAnalysis -X("printusedtypes", "Find Used Types"); - -// stub to help linkage -void FindUsedTypes::stub() {} +char FindUsedTypes::ID = 0; +static RegisterPass +X("print-used-types", "Find Used Types", false, true); // IncorporateType - Incorporate one type and all of its subtypes into the // collection of used types. @@ -62,7 +60,8 @@ bool FindUsedTypes::runOnModule(Module &m) { UsedTypes.clear(); // reset if run multiple times... // Loop over global variables, incorporating their types - for (Module::const_global_iterator I = m.global_begin(), E = m.global_end(); I != E; ++I) { + for (Module::const_global_iterator I = m.global_begin(), E = m.global_end(); + I != E; ++I) { IncorporateType(I->getType()); if (I->hasInitializer()) IncorporateValue(I->getInitializer()); @@ -93,15 +92,12 @@ 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"; - if (M) { - CachedWriter CW(M, o); - for (std::set::const_iterator I = UsedTypes.begin(), - E = UsedTypes.end(); I != E; ++I) - CW << " " << **I << "\n"; - } else - for (std::set::const_iterator I = UsedTypes.begin(), - E = UsedTypes.end(); I != E; ++I) - o << " " << **I << "\n"; +void FindUsedTypes::print(raw_ostream &OS, const Module *M) const { + OS << "Types in use by this module:\n"; + for (std::set::const_iterator I = UsedTypes.begin(), + E = UsedTypes.end(); I != E; ++I) { + OS << " "; + WriteTypeSymbolic(OS, *I, M); + OS << '\n'; + } }