[all-commits] [llvm/llvm-project] f7075d: [offload] add nodiscard support to offload-tblgen ...

Jan Trusiłło via All-commits all-commits at lists.llvm.org
Mon Aug 3 07:40:35 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f7075d0da225b3de1cc83345a3a74d2f310d1057
      https://github.com/llvm/llvm-project/commit/f7075d0da225b3de1cc83345a3a74d2f310d1057
  Author: Jan Trusiłło <jan.trusillo at intel.com>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M offload/liboffload/API/APIDefs.td
    M offload/liboffload/API/Common.td
    A offload/test/tools/offload-tblgen/enums_structs_nodiscard.td
    M offload/test/tools/offload-tblgen/functions_basic.td
    M offload/tools/offload-tblgen/APIGen.cpp
    M offload/tools/offload-tblgen/RecordTypes.hpp

  Log Message:
  -----------
  [offload] add nodiscard support to offload-tblgen and mark ol_errc_t (#209727)

Offload API functions may fail with error codes that shouldn't be
ignored. Most notably, if `olInit` fails and its error return value is
ignored, it is easy to use the library in an invalid uninitialized
state, which can and has caused confusion. In those cases, it may be
useful to have the ability to mark some API function with
`[[nodiscard]]`

This PR adds an optional `nodiscard` property to offload-tblgen's
`Function`, `Enum`, and `Struct`. If set, an `OL_NODISCARD` macro is
emitted, which expands to `[[nodiscard]]` on >=C++17 and >=C23, and to
nothing otherwise.

`nodiscard` is set for `ol_errc_t`, meaning every call to a function
that returns it will emit a compiler warning if the return value is
ignored and the TU is compiled on a supported language mode.

`libsycl` and `llvm-gpu-loader` still build cleanly and are unaffected
by the change.

Worth considering: should there be an opt-out (`#define
OL_DISABLE_NODISCARD` or similar)?

Assisted-by: Claude



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list