<div dir="rtl"><div dir="ltr">Hello,</div><div dir="ltr"><br></div><div dir="ltr">Attached is a patch I made to make clang warn where division of two integer literals loses precision. For instance:</div><div dir="ltr"><br>

</div><div dir="ltr"><font face="courier new, monospace">double x = 1/2;</font></div><div dir="ltr"><br></div><div dir="ltr">Which results in x being 0. This is not the programmer's intention. </div><div dir="ltr">While experienced users will know to code 1.0/2 to force floating division, new C/C++ programmers will fall in this trap.</div>

<div dir="ltr"><br></div><div dir="ltr">The patch computes the reminder in the division operation and if only if it is non-zero, warns and suggests a fix.<br></div><div dir="ltr"><br></div><div dir="ltr">This is the first code I write for LLVM so please review it carefully. Specifically, I was not sure whether to create another warning group in DiagnosticSemaKinds.td or reuse an existing one. Maybe the group should be renamed from "DivZero" to "DivProblems".</div>

<div dir="ltr"><br></div><div dir="ltr">Yaron<br></div><div dir="ltr"><br></div></div>