mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
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 |
||
|---|---|---|
| .. | ||
| deviceinfo | ||
| kernelreplay | ||
| offload-tblgen | ||
| CMakeLists.txt | ||