[Lldb-commits] [lldb] r187996 - Check for division by zero when performing modulus
Sean Callanan
scallanan at apple.com
Thu Aug 8 10:57:00 PDT 2013
Author: spyffe
Date: Thu Aug 8 12:57:00 2013
New Revision: 187996
URL: http://llvm.org/viewvc/llvm-project?rev=187996&view=rev
Log:
Check for division by zero when performing modulus
operations.
<rdar://problem/14656908>
Modified:
lldb/trunk/source/Core/Scalar.cpp
Modified: lldb/trunk/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=187996&r1=187995&r2=187996&view=diff
==============================================================================
--- lldb/trunk/source/Core/Scalar.cpp (original)
+++ lldb/trunk/source/Core/Scalar.cpp Thu Aug 8 12:57:00 2013
@@ -1690,22 +1690,16 @@ lldb_private::operator% (const Scalar& l
{
switch (result.m_type)
{
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint % b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint % b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong % b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong % b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong % b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong % b->m_data.ulonglong; break;
-
- case Scalar::e_void:
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
- // No bitwise AND on floats, doubles of long doubles
- result.m_type = Scalar::e_void;
- break;
+ default: break;
+ case Scalar::e_sint: if (b->m_data.sint != 0) { result.m_data.sint = a->m_data.sint % b->m_data.sint; return result; } break;
+ case Scalar::e_uint: if (b->m_data.uint != 0) { result.m_data.uint = a->m_data.uint % b->m_data.uint; return result; } break;
+ case Scalar::e_slong: if (b->m_data.slong != 0) { result.m_data.slong = a->m_data.slong % b->m_data.slong; return result; } break;
+ case Scalar::e_ulong: if (b->m_data.ulong != 0) { result.m_data.ulong = a->m_data.ulong % b->m_data.ulong; return result; } break;
+ case Scalar::e_slonglong: if (b->m_data.slonglong != 0) { result.m_data.slonglong = a->m_data.slonglong % b->m_data.slonglong; return result; } break;
+ case Scalar::e_ulonglong: if (b->m_data.ulonglong != 0) { result.m_data.ulonglong = a->m_data.ulonglong % b->m_data.ulonglong; return result; } break;
}
}
+ result.m_type = Scalar::e_void;
return result;
}
More information about the lldb-commits
mailing list