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

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 10:56:26 PST 2025


================
@@ -1017,11 +1018,13 @@ 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;
+    bool IsFloatConst = TokStart[0] == 'f';
+    int len = CurPtr - TokStart - 3;
----------------
mshockwave wrote:

I know it's from the old code but since we're changing it anyway could you make it `Len`? Also, why `int` rather than `unsigned` or `size_t`

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


More information about the llvm-commits mailing list