#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;
-static RegisterPass<FindUsedTypes>
-X("printusedtypes", "Find Used Types");
+INITIALIZE_PASS(FindUsedTypes, "print-used-types",
+ "Find Used Types", false, true);
// IncorporateType - Incorporate one type and all of its subtypes into the
// collection of used types.
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());
// 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(raw_ostream &OS, const Module *M) const {
+ OS << "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) << "\n";
+ E = UsedTypes.end(); I != E; ++I) {
+ OS << " ";
+ WriteTypeSymbolic(OS, *I, M);
+ OS << '\n';
+ }
}
-
-// Ensure that this file gets linked in when FindUsedTypes.h is used.
-DEFINING_FILE_FOR(FindUsedTypes)