[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)
Hood Chatham via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 14:57:24 PDT 2025
================
@@ -227,6 +227,53 @@ bool SemaWasm::BuiltinWasmTableCopy(CallExpr *TheCall) {
return false;
}
+bool SemaWasm::BuiltinWasmTestFunctionPointerSignature(CallExpr *TheCall) {
+ if (SemaRef.checkArgCount(TheCall, 1))
+ return true;
+
+ Expr *FuncPtrArg = TheCall->getArg(0);
+ QualType ArgType = FuncPtrArg->getType();
+
+ // Check that the argument is a function pointer
+ const PointerType *PtrTy = ArgType->getAs<PointerType>();
+ if (!PtrTy) {
+ return Diag(FuncPtrArg->getBeginLoc(),
+ diag::err_typecheck_expect_function_pointer)
+ << ArgType << FuncPtrArg->getSourceRange();
+ }
+
+ const FunctionProtoType *FuncTy =
+ PtrTy->getPointeeType()->getAs<FunctionProtoType>();
+ if (!FuncTy) {
+ return Diag(FuncPtrArg->getBeginLoc(),
+ diag::err_typecheck_expect_function_pointer)
+ << ArgType << FuncPtrArg->getSourceRange();
+ }
+
+ // Check that the function pointer doesn't use reference types
----------------
hoodmane wrote:
It's enough here but the LLVM intrinsic doesn't handle them yet. It shouldn't be too hard to support but it seemed tricky enough that I thought it would be better to leave to a follow-up.
https://github.com/llvm/llvm-project/pull/150201
More information about the cfe-commits
mailing list