diff options
author | Erick Tryzelaar <idadesub@users.sourceforge.net> | 2009-08-16 23:36:28 +0000 |
---|---|---|
committer | Erick Tryzelaar <idadesub@users.sourceforge.net> | 2009-08-16 23:36:28 +0000 |
commit | e9f195f15ffe96d0a220c872ab12d0630a633c44 (patch) | |
tree | 5a19f10d43e1fd22b24a208491b30ab79c1bfe01 /lib/Lex/LiteralSupport.cpp | |
parent | 60e282cc1e508be327b0481cecedc206873cb86a (diff) |
Update lexer to work with the new APFloat string parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79211 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 5da0e9c3ef..cb04e00305 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -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 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { 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 @@ GetFloatValue(const llvm::fltSemantics &Format, bool* isExact) { 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; |