[clang] Lex: add support for `i128` and `ui128` suffixes (PR #130993)

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 13 09:14:12 PDT 2025


================
@@ -3924,10 +3924,18 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
     // to get the integer value from an overly-wide APInt is *extremely*
     // expensive, so the naive approach of assuming
     // llvm::IntegerType::MAX_INT_BITS is a big performance hit.
-    unsigned BitsNeeded =
-        Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
-                               Literal.getLiteralDigits(), Literal.getRadix())
-                         : Context.getTargetInfo().getIntMaxTWidth();
+    unsigned BitsNeeded = Context.getTargetInfo().getIntMaxTWidth();
+    if (Literal.isBitInt)
+      BitsNeeded = llvm::APInt::getSufficientBitsNeeded(
+          Literal.getLiteralDigits(), Literal.getRadix());
+    if (Literal.MicrosoftInteger) {
+      if (Literal.MicrosoftInteger == 128 &&
----------------
compnerd wrote:

Yes, it needs a double check. The first check is to check if we have a Microsoft extended numeric literal. The second check is a bitwidth check to ensure that we have a type capable of representing it. It is specifically to emit the diagnostic. Either way, we set the number of required bits to properly process the numeric literal.

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


More information about the cfe-commits mailing list