about summary refs log tree commit diff homepage
path: root/lib/Module/Passes.h
diff options
context:
space:
mode:
authorPaul <paulmar@users.noreply.github.com>2013-10-29 07:02:39 -0700
committerPaul <paulmar@users.noreply.github.com>2013-10-29 07:02:39 -0700
commitb2070cfe978396aad21f22c8aae4910d45295bee (patch)
tree269288c7db4a344430da249e3b19e4b87b8493d4 /lib/Module/Passes.h
parent99d864996eb7768f55d210cb7c286f316c5a8187 (diff)
parent4b477f8108a2a92012ff138725f6c6f26ccb23e5 (diff)
downloadklee-b2070cfe978396aad21f22c8aae4910d45295bee.tar.gz
Merge pull request #26 from delcypher/fix_divide_by_zero
Fixed bug where divide by zero bugs would only be detected once in a program
Diffstat (limited to 'lib/Module/Passes.h')
-rw-r--r--lib/Module/Passes.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h
index d83e57ec..0c294daa 100644
--- a/lib/Module/Passes.h
+++ b/lib/Module/Passes.h
@@ -143,6 +143,31 @@ public:
   virtual bool runOnModule(llvm::Module &M);
 };
 
+/// This pass injects checks to check for overshifting.
+///
+/// Overshifting is where a Shl, LShr or AShr is performed
+/// where the shift amount is greater than width of the bitvector
+/// being shifted.
+/// In LLVM (and in C/C++) this undefined behaviour!
+///
+/// Example:
+/// \code
+///     unsigned char x=15;
+///     x << 4 ; // Defined behaviour
+///     x << 8 ; // Undefined behaviour
+///     x << 255 ; // Undefined behaviour
+/// \endcode
+class OvershiftCheckPass : public llvm::ModulePass {
+  static char ID;
+public:
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
+  OvershiftCheckPass(): ModulePass((intptr_t) &ID) {}
+#else
+  OvershiftCheckPass(): ModulePass(ID) {}
+#endif
+  virtual bool runOnModule(llvm::Module &M);
+};
+
 /// LowerSwitchPass - Replace all SwitchInst instructions with chained branch
 /// instructions.  Note that this cannot be a BasicBlock pass because it
 /// modifies the CFG!