diff tools/bugpoint-passes/TestPasses.cpp @ 95:afa8332a0e37 LLVM3.8

LLVM 3.8
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 13 Oct 2015 17:48:58 +0900
parents 54457678186b
children 7d135dc70f03
line wrap: on
line diff
--- a/tools/bugpoint-passes/TestPasses.cpp	Wed Feb 18 14:56:07 2015 +0900
+++ b/tools/bugpoint-passes/TestPasses.cpp	Tue Oct 13 17:48:58 2015 +0900
@@ -68,8 +68,32 @@
     }
   };
 }
- 
+
 char DeleteCalls::ID = 0;
 static RegisterPass<DeleteCalls>
   Y("bugpoint-deletecalls",
     "BugPoint Test Pass - Intentionally 'misoptimize' CallInsts");
+
+namespace {
+  /// CrashOnDeclFunc - This pass is used to test bugpoint.  It intentionally
+  /// crash if the module has an undefined function (ie a function that is
+  /// defined in an external module).
+  class CrashOnDeclFunc : public ModulePass {
+  public:
+    static char ID; // Pass ID, replacement for typeid
+    CrashOnDeclFunc() : ModulePass(ID) {}
+  private:
+    bool runOnModule(Module &M) override {
+      for (auto &F : M.functions()) {
+        if (F.isDeclaration())
+          abort();
+      }
+      return false;
+    }
+  };
+}
+
+char CrashOnDeclFunc::ID = 0;
+static RegisterPass<CrashOnDeclFunc>
+  Z("bugpoint-crash-decl-funcs",
+    "BugPoint Test Pass - Intentionally crash on declared functions");