[llvm] [LLVM][Support] add nonNull function helper (PR #188718)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 06:00:07 PDT 2026
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/188718 at github.com>
================
@@ -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,
----------------
kuhar wrote:
It would be nice for this to start with a verb, e.g.: `assertNonNull`
https://github.com/llvm/llvm-project/pull/188718
More information about the llvm-commits
mailing list