[llvm] r185437 - [APFloat] Swap an early out check so we do not dereference str.end().

Michael Gottesman mgottesman at apple.com
Tue Jul 2 08:50:05 PDT 2013


Author: mgottesman
Date: Tue Jul  2 10:50:05 2013
New Revision: 185437

URL: http://llvm.org/viewvc/llvm-project?rev=185437&view=rev
Log:
[APFloat] Swap an early out check so we do not dereference str.end().

Originally if D.firstSigDigit == str.end(), we will have already dereferenced
D.firstSigDigit in the first predicate.

Modified:
    llvm/trunk/lib/Support/APFloat.cpp

Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=185437&r1=185436&r2=185437&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Tue Jul  2 10:50:05 2013
@@ -2488,7 +2488,7 @@ APFloat::convertFromDecimalString(String
   // 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()) {
+  if (D.firstSigDigit == str.end() || decDigitValue(*D.firstSigDigit) >= 10U) {
     category = fcZero;
     fs = opOK;
 





More information about the llvm-commits mailing list