[llvm] r185397 - [APFloat] Ensure that we can properly parse strings that do not have null terminators.
Michael Gottesman
mgottesman at apple.com
Tue Jul 2 08:51:54 PDT 2013
Thanks. Fixed in r185437.
On Jul 1, 2013, at 7:37 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Mon, Jul 1, 2013 at 4:54 PM, Michael Gottesman <mgottesman at apple.com> wrote:
> Author: mgottesman
> Date: Mon Jul 1 18:54:08 2013
> New Revision: 185397
>
> URL: http://llvm.org/viewvc/llvm-project?rev=185397&view=rev
> Log:
> [APFloat] Ensure that we can properly parse strings that do not have null terminators.
>
> rdar://14323230
>
> Modified:
> llvm/trunk/lib/Support/APFloat.cpp
> llvm/trunk/unittests/ADT/APFloatTest.cpp
>
> Modified: llvm/trunk/lib/Support/APFloat.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=185397&r1=185396&r2=185397&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/APFloat.cpp (original)
> +++ llvm/trunk/lib/Support/APFloat.cpp Mon Jul 1 18:54:08 2013
> @@ -2481,7 +2481,14 @@ APFloat::convertFromDecimalString(String
> 42039/12655 < L < 28738/8651 [ numerator <= 65536 ]
> */
>
> - if (decDigitValue(*D.firstSigDigit) >= 10U) {
> + // Test if we have a zero number allowing for strings with no null terminators
> + // and zero decimals with non-zero exponents.
> + //
> + // We computed firstSigDigit by ignoring all zeros and dots. Thus if
> + // D->firstSigDigit equals str.end(), every digit must be a zero and there can
> + // be at most one dot. On the other hand, if we have a zero with a non-zero
> + // exponent, then we know that D.firstSigDigit will be non-numeric.
> + if (decDigitValue(*D.firstSigDigit) >= 10U || D.firstSigDigit == str.end()) {
> category = fcZero;
> fs = opOK;
>
>
> Aren't these checks in the wrong order? It would be nice to avoid dereferencing str.end().
>
> -Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130702/232684c1/attachment.html>
More information about the llvm-commits
mailing list