mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04:00
[MC] Fix floating-point literal lexing.
This patch has three related fixes to improve float literal lexing: 1. Make AsmLexer::LexDigit handle floats without a decimal point more consistently. 2. Make AsmLexer::LexFloatLiteral print an error for floats which are apparently missing an "e". 3. Make APFloat::convertFromString use binutils-compatible exponent parsing. Together, this fixes some cases where a float would be incorrectly rejected, fixes some cases where the compiler would crash, and improves diagnostics in some cases. Patch by Brandon Jones. Differential Revision: https://reviews.llvm.org/D57321 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -198,7 +198,10 @@ readExponent(StringRef::iterator begin, StringRef::iterator end)
|
||||
const unsigned int overlargeExponent = 24000; /* FIXME. */
|
||||
StringRef::iterator p = begin;
|
||||
|
||||
assert(p != end && "Exponent has no digits");
|
||||
// Treat no exponent as 0 to match binutils
|
||||
if (p == end || ((*p == '-' || *p == '+') && (p + 1) == end)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
isNegative = (*p == '-');
|
||||
if (*p == '-' || *p == '+') {
|
||||
|
||||
Reference in New Issue
Block a user