[cfe-commits] r79211 - /cfe/trunk/lib/Lex/LiteralSupport.cpp

Erick Tryzelaar idadesub at users.sourceforge.net
Sun Aug 16 16:36:28 PDT 2009


Author: erickt
Date: Sun Aug 16 18:36:28 2009
New Revision: 79211

URL: http://llvm.org/viewvc/llvm-project?rev=79211&view=rev
Log:
Update lexer to work with the new APFloat string parsing.

Modified:
    cfe/trunk/lib/Lex/LiteralSupport.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=79211&r1=79210&r2=79211&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sun Aug 16 18:36:28 2009
@@ -16,6 +16,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringExtras.h"
 using namespace clang;
 
@@ -604,9 +605,11 @@
 llvm::APFloat NumericLiteralParser::
 GetFloatValue(const llvm::fltSemantics &Format, bool* isExact) {
   using llvm::APFloat;
+  using llvm::StringRef;
   
   llvm::SmallVector<char,256> floatChars;
-  for (unsigned i = 0, n = ThisTokEnd-ThisTokBegin; i != n; ++i)
+  unsigned n = std::min(SuffixBegin - ThisTokBegin, ThisTokEnd - ThisTokBegin);
+  for (unsigned i = 0; i != n; ++i)
     floatChars.push_back(ThisTokBegin[i]);
   
   floatChars.push_back('\0');
@@ -614,7 +617,8 @@
   APFloat V (Format, APFloat::fcZero, false);
   APFloat::opStatus status;
   
-  status = V.convertFromString(&floatChars[0],APFloat::rmNearestTiesToEven);
+  status = V.convertFromString(StringRef(&floatChars[0], n),
+                               APFloat::rmNearestTiesToEven);
   
   if (isExact)
     *isExact = status == APFloat::opOK;





More information about the cfe-commits mailing list