[llvm] c414e58 - [Doc] Clarify the comments about how handleErrors works. (#65655)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 15:14:08 PDT 2023
Author: Zequan Wu
Date: 2023-09-20T18:14:03-04:00
New Revision: c414e5856a8e7a4fdea643101b8373f6fe39db06
URL: https://github.com/llvm/llvm-project/commit/c414e5856a8e7a4fdea643101b8373f6fe39db06
DIFF: https://github.com/llvm/llvm-project/commit/c414e5856a8e7a4fdea643101b8373f6fe39db06.diff
LOG: [Doc] Clarify the comments about how handleErrors works. (#65655)
Added:
Modified:
llvm/include/llvm/Support/Error.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index 2292770a97c4b40..bb4f38f7ec355ef 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -127,7 +127,7 @@ class ErrorInfoBase {
///
/// auto E = foo(<...>); // <- foo returns failure with MyErrorInfo.
/// auto NewE =
-/// handleErrors(E,
+/// handleErrors(std::move(E),
/// [](const MyErrorInfo &M) {
/// // Deal with the error.
/// },
@@ -138,9 +138,15 @@ class ErrorInfoBase {
/// }
/// // Couldn't handle this error instance. Pass it up the stack.
/// return Error(std::move(M));
-/// );
-/// // Note - we must check or return NewE in case any of the handlers
-/// // returned a new error.
+/// });
+/// // Note - The error passed to handleErrors will be marked as checked. If
+/// // there is no matched handler, a new error with the same payload is
+/// // created and returned.
+/// // The handlers take the error checked by handleErrors as an argument,
+/// // which can be used to retrieve more information. If a new error is
+/// // created by a handler, it will be passed back to the caller of
+/// // handleErrors and needs to be checked or return up to the stack.
+/// // Otherwise, the passed-in error is considered consumed.
/// @endcode
///
/// The handleAllErrors function is identical to handleErrors, except
More information about the llvm-commits
mailing list