[clang] [llvm] [WebAssembly] Add support for nonnull_extern_ref type (PR #148935)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 12:33:01 PDT 2025


badumbatish wrote:

one of the blockers is i'm actually not sure how to add the checks to ensure that the nonnull extern refs always stay non-null.

--- 

The check on IsNullExtern should always return fail for non_null_extern
```

bool SemaWasm::BuiltinWasmRefIsNullExtern(CallExpr *TheCall) {
  if (SemaRef.checkArgCount(TheCall, 1)) {
    return true;
  }

  Expr *ArgExpr = TheCall->getArg(0);
  if (!ArgExpr->getType().isWebAssemblyExternrefType()) {
    SemaRef.Diag(ArgExpr->getBeginLoc(),
                 diag::err_wasm_builtin_arg_must_be_externref_type)
        << 1 << ArgExpr->getSourceRange();
    return true;
  }

  return false;
}
```

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


More information about the llvm-commits mailing list