[Clang][Sema] Fix __builtin_infer_alloc_token() return type (#168773)

Using the builtin failed on 32-bit architectures:
```
clang/lib/AST/ExprConstant.cpp:14299: [..]: Assertion `I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) && "Invalid evaluation result."' failed.
```

The return type is meant to be size_t. Fix it.
This commit is contained in:
Marco Elver 2025-11-19 22:25:35 +01:00 committed by GitHub
parent 2b16ae0d42
commit 609c88a1fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -1512,7 +1512,7 @@ static bool checkBuiltinInferAllocToken(Sema &S, CallExpr *TheCall) {
return S.Diag(Arg->getBeginLoc(), diag::err_param_with_void_type);
}
TheCall->setType(S.Context.UnsignedLongLongTy);
TheCall->setType(S.Context.getSizeType());
return false;
}

View File

@ -3,6 +3,8 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -falloc-token-mode=typehash -DMODE_TYPEHASH
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2
// RUN: %clang_cc1 -triple arm-linux-androideabi -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2
// RUN: %clang_cc1 -triple arm-linux-androideabi -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2 -fexperimental-new-constant-interpreter
#if !__has_builtin(__builtin_infer_alloc_token)
#error "missing __builtin_infer_alloc_token"