Add an assert to catch user errors like:
authorTorok Edwin <edwintorok@gmail.com>
Fri, 31 Oct 2008 17:27:41 +0000 (17:27 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Fri, 31 Oct 2008 17:27:41 +0000 (17:27 +0000)
MyFunctionPass() : FunctionPass(ID) {}

when the user actually meant to write:
MyFunctionPass() : FunctionPass(&ID) {}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58518 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Pass.h

index 305ac37b17d80d5d925d88d121f3492f4a561584..247805f4dbfa8eafcef1c2716048cde4c9a321d1 100644 (file)
@@ -81,8 +81,12 @@ class Pass {
   void operator=(const Pass&);  // DO NOT IMPLEMENT
   Pass(const Pass &);           // DO NOT IMPLEMENT
 public:
-  explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {}
-  explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {}
+  explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {
+    assert(pid && "pid cannot be 0");
+  }
+  explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {
+    assert(pid && "pid cannot be 0"); 
+  }
   virtual ~Pass();
 
   /// getPassName - Return a nice clean name for a pass.  This usually