#include "llvm/Constants.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
-#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
using namespace llvm;
-namespace llvm {
-
typedef std::vector<Constant *> GVVectorTy;
-class InternalGlobalMapper : public Pass {
-public:
- bool run (Module &M);
-};
+namespace {
+ struct InternalGlobalMapper : public ModulePass {
+ bool runOnModule(Module &M);
+ };
+}
-Pass *llvm::createInternalGlobalMapperPass () {
- return new InternalGlobalMapper ();
+namespace llvm {
+ ModulePass *createInternalGlobalMapperPass() {
+ return new InternalGlobalMapper();
+ }
}
static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){
// be mangled), then put the GV, casted to sbyte*, in the vector. Otherwise
// add a null.
if (GV.hasInternalLinkage () && GV.hasName ())
- Vector.push_back (ConstantExpr::getCast
- (&GV, PointerType::get (Type::SByteTy)));
+ Vector.push_back(ConstantExpr::getCast(&GV,
+ PointerType::get(Type::SByteTy)));
else
Vector.push_back (ConstantPointerNull::get (PointerType::get
(Type::SByteTy)));
}
-bool InternalGlobalMapper::run (Module &M) {
+bool InternalGlobalMapper::runOnModule(Module &M) {
GVVectorTy gvvector;
// Populate the vector with internal global values and their names.
- for (Module::giterator i = M.gbegin (), e = M.gend (); i != e; ++i)
+ for (Module::global_iterator i = M.global_begin (), e = M.global_end (); i != e; ++i)
maybeAddInternalValueToVector (gvvector, *i);
// Add an extra global for _llvm_internalGlobals itself (null,
// because it's not internal)
return true; // Module was modified.
}
-
-} // end namespace llvm