[llvm] [LLVM][Support] add nonNull function helper (PR #188718)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 08:50: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:
fair. Moved in the default value, just added an assert for Msg then.
https://github.com/llvm/llvm-project/pull/188718
More information about the llvm-commits
mailing list