[llvm] [LLVM][Support] add nonNull function helper (PR #188718)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 06:32:20 PDT 2026
================
@@ -811,6 +811,19 @@ T cantFail(Expected<T> ValOrErr, const char *Msg = nullptr) {
}
}
+/// Calls llvm_unreachable if Pointer is null, otherwise returns the
+/// pointer as is.
+template <typename T>
+LLVM_ATTRIBUTE_RETURNS_NONNULL T *nonNull(T *Pointer,
+ const char *Msg = nullptr) {
----------------
Keenuts wrote:
I'd still need to check Msg was not set to null in the call (or assert)
https://github.com/llvm/llvm-project/pull/188718
More information about the llvm-commits
mailing list