MEGAPATCH checkin.
[oota-llvm.git] / lib / Analysis / IPA / FindUnsafePointerTypes.cpp
index d689d93cd4433f8b29a6779d33d2d2443eb4168b..8cad60d1787f55d8d2c20edc571384cfd0024b75 100644 (file)
@@ -19,8 +19,6 @@
 #include "llvm/Analysis/FindUnsafePointerTypes.h"
 #include "llvm/Assembly/CachedWriter.h"
 #include "llvm/Type.h"
-#include "llvm/Instruction.h"
-#include "llvm/Function.h"
 #include "llvm/Module.h"
 #include "llvm/Support/InstIterator.h"
 #include "Support/CommandLine.h"
@@ -51,21 +49,20 @@ static inline bool isSafeInstruction(const Instruction *I) {
 }
 
 
-bool FindUnsafePointerTypes::run(Module *Mod) {
-  for (Module::iterator MI = Mod->begin(), ME = Mod->end();
-       MI != ME; ++MI) {
-    const Function *M = *MI;  // We don't need/want write access
-    for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
-      const Instruction *Inst = *I;
-      const Type *ITy = Inst->getType();
-      if (ITy->isPointerType() && !UnsafeTypes.count((PointerType*)ITy))
-        if (!isSafeInstruction(Inst)) {
+bool FindUnsafePointerTypes::run(Module &Mod) {
+  for (Module::iterator FI = Mod.begin(), E = Mod.end();
+       FI != E; ++FI) {
+    const Function *F = FI;  // We don't need/want write access
+    for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
+      const Type *ITy = I->getType();
+      if (isa<PointerType>(ITy) && !UnsafeTypes.count((PointerType*)ITy))
+        if (!isSafeInstruction(*I)) {
           UnsafeTypes.insert((PointerType*)ITy);
 
           if (PrintFailures) {
-            CachedWriter CW(M->getParent(), std::cerr);
+            CachedWriter CW(F->getParent(), std::cerr);
             CW << "FindUnsafePointerTypes: Type '" << ITy
-               << "' marked unsafe in '" << M->getName() << "' by:\n" << Inst;
+               << "' marked unsafe in '" << F->getName() << "' by:\n" << **I;
           }
         }
     }
@@ -95,11 +92,3 @@ void FindUnsafePointerTypes::printResults(const Module *M,
     CW << " #" << Counter << ". " << (Value*)*I << "\n";
   }
 }
-
-// getAnalysisUsageInfo - Of course, we provide ourself...
-//
-void FindUnsafePointerTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required,
-                                                  Pass::AnalysisSet &Destroyed,
-                                                  Pass::AnalysisSet &Provided) {
-  Provided.push_back(FindUnsafePointerTypes::ID);
-}