[llvm] [AsmParser] Revamp how floating-point literals work in LLVM IR. (PR #190641)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 11:39:23 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-nvptx

Author: Joshua Cranmer (jcranmer-intel)

<details>
<summary>Changes</summary>

This adds support for the following kinds of formats:
* Hexadecimal literals like 0x1.fp13
* Special values +inf/-inf, +qnan/-qnan
* NaN values with payloads like +nan(0x1)

Additionally, the floating-point hexadecimal format that records the bitpattern exactly no longer requires the 0xL or 0xK or similar code for the floating-point type. The current hexadecimal syntax is retained for the moment, but it is expected to be ripped out after the next release of LLVM.

---

Patch is 31.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/190641.diff


13 Files Affected:

- (modified) llvm/docs/LangRef.rst (+54-30) 
- (modified) llvm/docs/ReleaseNotes.md (+9) 
- (modified) llvm/include/llvm/ADT/APFloat.h (+19-1) 
- (modified) llvm/include/llvm/AsmParser/LLLexer.h (+1) 
- (modified) llvm/include/llvm/AsmParser/LLToken.h (+4-2) 
- (modified) llvm/lib/AsmParser/LLLexer.cpp (+163-38) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+32-2) 
- (modified) llvm/lib/CodeGen/MIRParser/MILexer.cpp (+18) 
- (modified) llvm/lib/Support/APFloat.cpp (+1-1) 
- (modified) llvm/test/Assembler/2006-09-28-CrashOnInvalid.ll (+1-1) 
- (added) llvm/test/Assembler/float-literals.ll (+44) 
- (modified) llvm/test/CodeGen/MIR/NVPTX/floating-point-invalid-type-error.mir (+1-1) 
- (modified) llvm/unittests/AsmParser/AsmParserTest.cpp (+70-1) 


``````````diff
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 5584e0828d3cd..9772dea1762bb 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -4958,11 +4958,13 @@ Simple Constants
     ``store b8 42, ptr %p`` is equivalent to ``store i8 42, ptr %p``.
 **Floating-point constants**
     Floating-point constants use standard decimal notation (e.g.
-    123.421), exponential notation (e.g., 1.23421e+2), or a more precise
-    hexadecimal notation (see below). The assembler requires the exact
-    decimal value of a floating-point constant. For example, the
-    assembler accepts 1.25 but rejects 1.3 because 1.3 is a repeating
-    decimal in binary. Floating-point constants must have a
+    123.421), exponential notation (e.g. 1.23421e+2), standard hexadecimal
+    notation (e.g., 0x1.3effp-43), one of several special values, or a
+    precise bitstring for the underlying value. When converting decimal and
+    hexadecimal literals to the floating-point type, the value is converted
+    using the default rounding mode (round to nearest, half to even). String
+    conversions that underflow to 0 or overflow to infinity are not permitted.
+    Floating-point constants must have a
     :ref:`floating-point <t_floating>` type.
 **Null pointer constants**
     The identifier '``null``' is recognized as a null pointer constant
@@ -4971,31 +4973,53 @@ Simple Constants
     The identifier '``none``' is recognized as an empty token constant
     and must be of :ref:`token type <t_token>`.
 
-The one non-intuitive notation for constants is the hexadecimal form of
-floating-point constants. For example, the form
-'``double    0x432ff973cafa8000``' is equivalent to (but harder to read
-than) '``double 4.5e+15``'. The only time hexadecimal floating-point
-constants are required (and the only time that they are generated by the
-disassembler) is when a floating-point constant must be emitted but it
-cannot be represented as a decimal floating-point number in a reasonable
-number of digits. For example, NaN's, infinities, and other special
-values are represented in their IEEE hexadecimal format so that assembly
-and disassembly do not cause any bits to change in the constants.
-
-When using the hexadecimal form, constants of types bfloat, half, float, and
-double are represented using the 16-digit form shown above (which matches the
-IEEE 754 representation for double); bfloat, half and float values must, however,
-be exactly representable as bfloat, IEEE 754 half, and IEEE 754 single
-precision respectively. Hexadecimal format is always used for long double, and
-there are three forms of long double. The 80-bit format used by x86 is
-represented as ``0xK`` followed by 20 hexadecimal digits. The 128-bit format
-used by PowerPC (two adjacent doubles) is represented by ``0xM`` followed by 32
-hexadecimal digits. The IEEE 128-bit format is represented by ``0xL`` followed
-by 32 hexadecimal digits. Long doubles will only work if they match the long
-double format on your target.  The IEEE 16-bit format (half precision) is
-represented by ``0xH`` followed by 4 hexadecimal digits. The bfloat 16-bit
-format is represented by ``0xR`` followed by 4 hexadecimal digits. All
-hexadecimal formats are big-endian (sign bit at the left).
+Floating-point constants support the following kinds of strings:
+
+   +----------------+---------------------------------------------------+
+   | Syntax         | Description                                       |
+   +================+===================================================+
+   | ``+4.5e-13``   | Common decimal literal. Signs are optional, as is |
+   |                | the exponent portion. The decimal point is        |
+   |                | required, as is one or more leading digits before |
+   |                | the decimal point.                                |
+   +----------------+---------------------------------------------------+
+   | ``-0x1.fp13``  | Common hexadecimal literal. Signs are optional.   |
+   |                | The decimal point is required, as is the exponent |
+   |                | portion of the literal (after the ``p``).         |
+   +----------------+---------------------------------------------------+
+   | ``+inf``,      | Positive or negative infinity. The sign is        |
+   | ``-inf``       | required.                                         |
+   +----------------+---------------------------------------------------+
+   | ``+qnan``,     | Positive or negative preferred quiet NaN, i.e.,   |
+   | ``-qnan``      | the quiet bit is set, and all other payload bits  |
+   |                | are 0. The sign is required.                      |
+   +----------------+---------------------------------------------------+
+   | ``+nan(0x1)``  | qNaN value with a particular payload, specified   |
+   |                | as hexadecimal (not including the quiet bit as    |
+   |                | part of the payload). The sign is required.       |
+   +----------------+---------------------------------------------------+
+   | ``+snan(0x1)`` | sNaN value with a particular payload, specified   |
+   |                | as hexadecimal (not including the quiet bit as    |
+   |                | part of the payload). The sign is required.       |
+   +----------------+---------------------------------------------------+
+   | ``f0x3c00``    | Value of the floating-point number if bitcast to  |
+   |                | an integer. The number must have exactly as many  |
+   |                | hexadecimal digits as is necessary for the size   |
+   |                | of the floating-point number.                     |
+   +----------------+---------------------------------------------------+
+
+There is a legacy syntax for hexadecimal floating-point literals that will be
+removed in the future. In this format, constants are represented as their
+underlying integer representation as in the ``f0x3c00`` syntax, but instead
+use slightly different prefixes. ``float`` and ``double`` use ``0x`` followed
+by 16 hexadecimal digits representing the equivalent ``double`` value bitcast
+to an integer type. ``bfloat`` uses ``0xR`` followed by 4 hexadecimal digits.
+``half`` uses ``0xH`` followed by 4 hexadecimal digits. ``x86_fp80`` uses
+``0xK`` followed by 20 hexadecimal digits. ``ppc_fp128`` uses ``0xM``
+followed by 32 hexadecimal digits. ``fp128`` uses ``0xL`` followed by 32
+hexadecimal digits. For the last two types only, the bits are not fully
+written in big-endian order but rather with the low 64 bits written in
+big-endian then the high 64 bits written in big-endian.
 
 There are no constants of type x86_amx.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index d0d8b9f4ddabc..6323e9bc9c13e 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -69,6 +69,15 @@ Changes to the LLVM IR
 * The `"nooutline"` attribute is now writen as `nooutline`. Existing IR and
   bitcode will be automatically updated.
 
+* LLVM IR floating-point literals have greatly changed:
+
+  * The old hexadecimal bitwise representation is deprecated and will be removed
+    in the next revision. It is replaced with a unified `f0x` prefix.
+
+  * Hexadecimal literals akin to C99's syntax are supported.
+
+  * Special values for infinities and NaNs, including NaN payloads, are added.
+
 Changes to LLVM infrastructure
 ------------------------------
 
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index f1645729c115c..5a557ab5d4e5d 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1404,7 +1404,25 @@ class APFloat : public APFloatBase {
     APFLOAT_DISPATCH_ON_SEMANTICS(convertFromAPInt(Input, IsSigned, RM));
   }
 
-  LLVM_ABI Expected<opStatus> convertFromString(StringRef, roundingMode);
+  /// Fill this APFloat with the result of a string conversion.
+  ///
+  /// The following strings are accepted for conversion purposes:
+  /// * Decimal floating-point literals (e.g., `0.1e-5`)
+  /// * Hexadecimal floating-point literals (e.g., `0x1.0p-5`)
+  /// * Positive infinity via "inf", "INFINITY", "Inf", "+Inf", or "+inf".
+  /// * Negative infinity via "-inf", "-INFINITY", or "-Inf".
+  /// * Quiet NaNs via "nan", "NaN", "nan(...)", or "NaN(...)", where the
+  ///   "..." is either a decimal or hexadecimal integer representing the
+  ///   payload. A negative sign may be optionally provided.
+  /// * Signaling NaNs via "snan", "sNaN", "snan(...)", or "sNaN(...)", where
+  ///   the "..." is either a decimal or hexadecimal integer representing the
+  ///   payload. A negative sign may be optionally provided.
+  ///
+  /// If the input string is none of these forms, then an error is returned.
+  ///
+  /// If a floating-point exception occurs during conversion, then no error is
+  /// returned, and the exception is indicated via opStatus.
+  Expected<opStatus> convertFromString(StringRef, roundingMode);
   APInt bitcastToAPInt() const {
     APFLOAT_DISPATCH_ON_SEMANTICS(bitcastToAPInt());
   }
diff --git a/llvm/include/llvm/AsmParser/LLLexer.h b/llvm/include/llvm/AsmParser/LLLexer.h
index 0e379e5a75e65..639fd5c06e0a6 100644
--- a/llvm/include/llvm/AsmParser/LLLexer.h
+++ b/llvm/include/llvm/AsmParser/LLLexer.h
@@ -126,6 +126,7 @@ namespace llvm {
     lltok::Kind Lex0x();
     lltok::Kind LexHash();
     lltok::Kind LexCaret();
+    lltok::Kind LexFloatStr();
 
     uint64_t atoull(const char *Buffer, const char *End);
     uint64_t HexIntToVal(const char *Buffer, const char *End);
diff --git a/llvm/include/llvm/AsmParser/LLToken.h b/llvm/include/llvm/AsmParser/LLToken.h
index c138fb5ccc55b..593f66900e613 100644
--- a/llvm/include/llvm/AsmParser/LLToken.h
+++ b/llvm/include/llvm/AsmParser/LLToken.h
@@ -523,12 +523,14 @@ enum Kind {
   ChecksumKind,        // CSK_foo
   DbgRecordType,       // dbg_foo
   DwarfEnumKind,       // DW_APPLE_ENUM_KIND_foo
+  FloatLiteral,        // Unparsed float literal
 
   // Type valued tokens (TyVal).
   Type,
 
-  APFloat, // APFloatVal
-  APSInt   // APSInt
+  FloatHexLiteral, // f0x..., stored as APSInt
+  APFloat,         // APFloatVal
+  APSInt           // APSInt
 };
 } // end namespace lltok
 } // end namespace llvm
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 60050ae477a01..69f681374fd14 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -494,6 +494,7 @@ lltok::Kind LLLexer::LexHash() {
 ///    IntegerType     i[0-9]+
 ///    Keyword         sdiv, float, ...
 ///    HexIntConstant  [us]0x[0-9A-Fa-f]+
+///    HexFloatConstant f0x[0-9A-Fa-f]+
 lltok::Kind LLLexer::LexIdentifier() {
   const char *StartChar = CurPtr;
   const char IntOrByteIdentifier = CurPtr[-1];
@@ -1066,24 +1067,26 @@ lltok::Kind LLLexer::LexIdentifier() {
   }
 
   // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
-  // the CFE to avoid forcing it to deal with 64-bit numbers.
-  if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
+  // the CFE to avoid forcing it to deal with 64-bit numbers. Also check for
+  // f0x[0-9A-Fa-f]+, which is the floating-point hexadecimal literal constant.
+  if ((TokStart[0] == 'u' || TokStart[0] == 's' || TokStart[0] == 'f') &&
       TokStart[1] == '0' && TokStart[2] == 'x' &&
       isxdigit(static_cast<unsigned char>(TokStart[3]))) {
-    int len = CurPtr-TokStart-3;
-    uint32_t bits = len * 4;
-    StringRef HexStr(TokStart + 3, len);
+    bool IsFloatConst = TokStart[0] == 'f';
+    size_t Len = CurPtr - TokStart - 3;
+    uint32_t Bits = Len * 4;
+    StringRef HexStr(TokStart + 3, Len);
     if (!all_of(HexStr, isxdigit)) {
       // Bad token, return it as an error.
-      CurPtr = TokStart+3;
+      CurPtr = TokStart + 3;
       return lltok::Error;
     }
-    APInt Tmp(bits, HexStr, 16);
-    uint32_t activeBits = Tmp.getActiveBits();
-    if (activeBits > 0 && activeBits < bits)
-      Tmp = Tmp.trunc(activeBits);
-    APSIntVal = APSInt(Tmp, TokStart[0] == 'u');
-    return lltok::APSInt;
+    APInt Tmp(Bits, HexStr, 16);
+    uint32_t ActiveBits = Tmp.getActiveBits();
+    if (!IsFloatConst && ActiveBits > 0 && ActiveBits < Bits)
+      Tmp = Tmp.trunc(ActiveBits);
+    APSIntVal = APSInt(Tmp, TokStart[0] != 's');
+    return IsFloatConst ? lltok::FloatHexLiteral : lltok::APSInt;
   }
 
   // If this is "cc1234", return this as just "cc".
@@ -1099,6 +1102,7 @@ lltok::Kind LLLexer::LexIdentifier() {
 
 /// Lex all tokens that start with a 0x prefix, knowing they match and are not
 /// labels.
+///    HexFPLiteral      [-+]?0x[0-9A-Fa-f]+.[0-9A-Fa-f]*[pP][-+]?[0-9]+
 ///    HexFPConstant     0x[0-9A-Fa-f]+
 ///    HexFP80Constant   0xK[0-9A-Fa-f]+
 ///    HexFP128Constant  0xL[0-9A-Fa-f]+
@@ -1125,6 +1129,11 @@ lltok::Kind LLLexer::Lex0x() {
   while (isxdigit(static_cast<unsigned char>(CurPtr[0])))
     ++CurPtr;
 
+  if (*CurPtr == '.') {
+    // HexFPLiteral, following C's %a syntax
+    return LexFloatStr();
+  }
+
   if (Kind == 'J') {
     // HexFPConstant - Floating point constant represented in IEEE format as a
     // hexadecimal number for when exponential notation is not precise enough.
@@ -1136,30 +1145,31 @@ lltok::Kind LLLexer::Lex0x() {
 
   uint64_t Pair[2];
   switch (Kind) {
-  default: llvm_unreachable("Unknown kind!");
+  default:
+    llvm_unreachable("Unknown kind!");
   case 'K':
     // F80HexFPConstant - x87 long double in hexadecimal format (10 bytes)
-    FP80HexToIntPair(TokStart+3, CurPtr, Pair);
-    APFloatVal = APFloat(APFloat::x87DoubleExtended(), APInt(80, Pair));
-    return lltok::APFloat;
+    FP80HexToIntPair(TokStart + 3, CurPtr, Pair);
+    APSIntVal = APInt(80, Pair);
+    return lltok::FloatHexLiteral;
   case 'L':
     // F128HexFPConstant - IEEE 128-bit in hexadecimal format (16 bytes)
-    HexToIntPair(TokStart+3, CurPtr, Pair);
-    APFloatVal = APFloat(APFloat::IEEEquad(), APInt(128, Pair));
-    return lltok::APFloat;
+    HexToIntPair(TokStart + 3, CurPtr, Pair);
+    APSIntVal = APInt(128, Pair);
+    return lltok::FloatHexLiteral;
   case 'M':
     // PPC128HexFPConstant - PowerPC 128-bit in hexadecimal format (16 bytes)
-    HexToIntPair(TokStart+3, CurPtr, Pair);
-    APFloatVal = APFloat(APFloat::PPCDoubleDouble(), APInt(128, Pair));
-    return lltok::APFloat;
+    HexToIntPair(TokStart + 3, CurPtr, Pair);
+    APSIntVal = APInt(128, Pair);
+    return lltok::FloatHexLiteral;
   case 'H': {
     uint64_t Val = HexIntToVal(TokStart + 3, CurPtr);
     if (!llvm::isUInt<16>(Val)) {
       LexError("hexadecimal constant too large for half (16-bit)");
       return lltok::Error;
     }
-    APFloatVal = APFloat(APFloat::IEEEhalf(), APInt(16, Val));
-    return lltok::APFloat;
+    APSIntVal = APInt(16, Val);
+    return lltok::FloatHexLiteral;
   }
   case 'R': {
     // Brain floating point
@@ -1168,8 +1178,8 @@ lltok::Kind LLLexer::Lex0x() {
       LexError("hexadecimal constant too large for bfloat (16-bit)");
       return lltok::Error;
     }
-    APFloatVal = APFloat(APFloat::BFloat(), APInt(16, Val));
-    return lltok::APFloat;
+    APSIntVal = APInt(16, Val);
+    return lltok::FloatHexLiteral;
   }
   }
 }
@@ -1179,6 +1189,7 @@ lltok::Kind LLLexer::Lex0x() {
 ///    NInteger          -[0-9]+
 ///    FPConstant        [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
 ///    PInteger          [0-9]+
+///    HexFPLiteral      [-+]?0x[0-9A-Fa-f]+.[0-9A-Fa-f]*[pP][-+]?[0-9]+
 ///    HexFPConstant     0x[0-9A-Fa-f]+
 ///    HexFP80Constant   0xK[0-9A-Fa-f]+
 ///    HexFP128Constant  0xL[0-9A-Fa-f]+
@@ -1194,7 +1205,9 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
       return lltok::LabelStr;
     }
 
-    return lltok::Error;
+    // It might be a -inf, -nan, etc. Check if it's a float string (which will
+    // also handle error conditions there).
+    return LexFloatStr();
   }
 
   // At this point, it is either a label, int or fp constant.
@@ -1227,6 +1240,9 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
   if (CurPtr[0] != '.') {
     if (TokStart[0] == '0' && TokStart[1] == 'x')
       return Lex0x();
+    if (TokStart[0] == '-' && TokStart[1] == '0' && TokStart[2] == 'x')
+      return LexFloatStr();
+
     APSIntVal = APSInt(StringRef(TokStart, CurPtr - TokStart));
     return lltok::APSInt;
   }
@@ -1245,26 +1261,31 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
     }
   }
 
-  APFloatVal = APFloat(APFloat::IEEEdouble(),
-                       StringRef(TokStart, CurPtr - TokStart));
-  return lltok::APFloat;
+  StrVal.assign(TokStart, CurPtr - TokStart);
+  return lltok::FloatLiteral;
 }
 
 /// Lex a floating point constant starting with +.
-///    FPConstant  [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
+///    FPConstant   [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
+///    HexFPLiteral [-+]?0x[0-9A-Fa-f]+.[0-9A-Fa-f]*[pP][-+]?[0-9]+
+///    HexFPSpecial [-+](inf|qnan|s?nan\(0x[0-9A-Fa-f]+\))
 lltok::Kind LLLexer::LexPositive() {
-  // If the letter after the negative is a number, this is probably not a
-  // label.
+  // If it's not numeric, check for special floating-point values.
   if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
-    return lltok::Error;
+    return LexFloatStr();
 
   // Skip digits.
   for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
     /*empty*/;
 
+  // If the first non-digit is an x, check if it's a hex FP literal. LexFloatStr
+  // will reanalyze TokStr..CurPtr to make sure that it's 0x and not 413x.
+  if (CurPtr[0] == 'x')
+    return LexFloatStr();
+
   // At this point, we need a '.'.
   if (CurPtr[0] != '.') {
-    CurPtr = TokStart+1;
+    CurPtr = TokStart + 1;
     return lltok::Error;
   }
 
@@ -1282,7 +1303,111 @@ lltok::Kind LLLexer::LexPositive() {
     }
   }
 
-  APFloatVal = APFloat(APFloat::IEEEdouble(),
-                       StringRef(TokStart, CurPtr - TokStart));
-  return lltok::APFloat;
+  StrVal.assign(TokStart, CurPtr - TokStart);
+  return lltok::FloatLiteral;
+}
+
+/// Lex all tokens that start with a + or - that could be a float literal.
+///    HexFPLiteral      [-+]?0x[0-9A-Fa-f]+.[0-9A-Fa-f]*[pP][-+]?[0-9]+
+///    HexFPSpecial      [-+](inf|qnan|s?nan\(0x[0-9A-Fa-f]+\))
+lltok::Kind LLLexer::LexFloatStr() {
+  // At the point we enter this function, we may have seen a few characters
+  // already, but how many differs based on the entry point. Rewind to the
+  // beginning just in case.
+  CurPtr = TokStart;
+
+  // Check for optional sign.
+  if (*CurPtr == '-' || *CurPtr == '+')
+    ++CurPtr;
+
+  if (*CurPtr != '0') {
+    // Check for keywords.
+    const char *LabelStart = CurPtr;
+    while (isLabelChar(*CurPtr))
+      ++CurPtr;
+    StringRef Label(LabelStart, CurPtr - LabelStart);
+
+    // Basic special values.
+    if (Label == "inf") {
+      // Copy from the beginning, to include the sign.
+      StrVal.assign(TokStart, CurPtr - TokStart);
+      return lltok::FloatLiteral;
+    }
+
+    // APFloat::convertFromString doesn't support qnan, so translate it to a
+    // nan payload string it does support.
+    if (Label == "qnan") {
+      StrVal = *TokStart == '-' ? "-nan(0)" : "nan(0)";
+      return lltok::FloatLiteral;
+    }
+
+    // NaN with payload.
+    if ((Label == "nan" || Label == "snan") && *CurPtr == '(') {
+      const char *Payload = ++CurPtr;
+      while (*CurPtr && *CurPtr != ')')
+        ++CurPtr;
+
+      // If no close parenthesis, it's a bad token, return it as an error.
+      if (*CurPtr++ != ')') {
+        CurPtr = TokStart + 1;
+        return lltok::Error;
+      }
+
+      StringRef PayloadStr(Payload, CurPtr - Payload);
+      APInt Val;
+      if (PayloadStr.consume_front("0x") && PayloadStr.getAsInteger(16, Val)) {
+        StrVal.assign(TokStart, CurPtr - TokStart);
+        // Drop the leading + from the string, as APFloat::convertFromString
+        // doesn't support leading + sign.
+        if (StrVal[0] == '+')
+          StrVal.erase(0, 1);
+        return lltok::FloatLiteral;
+      }
+    }
+
+    // Bad token, return it as an error.
+    CurPtr = TokStart + 1;
+    return lltok::Error;
+  }
+  ++CurPtr;
+
+  if (*CurPtr++ != 'x') {
+    // Bad token, return it as an error.
+    CurPtr = TokStart + 1;
+    return lltok::Error;
+  }
+
+  if (!isxdigit(static_cast<unsigned char>(CurPtr[0]))) {
+    // Bad token, return it as an error.
+    CurPtr = TokStart + 1;
+    return lltok::Error;
+  }
+
+  while (isxdigit(static_cast<uns...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/190641


More information about the llvm-commits mailing list