[llvm] [Doc] Clarify the comments about how handleErrors works. (PR #65655)

Zequan Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 15:12:56 PDT 2023


https://github.com/ZequanWu updated https://github.com/llvm/llvm-project/pull/65655

>From 9e13c8e9c20d3fad867467bbf208b9ca1912378b Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Thu, 7 Sep 2023 14:47:05 -0400
Subject: [PATCH 1/2] [Doc] Clarify the comments about how handleErrors works.

---
 llvm/include/llvm/Support/Error.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index 2292770a97c4b40..ce00982bceb14f1 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 playload 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

>From 4fac4c43404b3208d59775995739d7f1f4b31c91 Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Wed, 20 Sep 2023 18:12:48 -0400
Subject: [PATCH 2/2] Fix typo.

---
 llvm/include/llvm/Support/Error.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index ce00982bceb14f1..bb4f38f7ec355ef 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -140,7 +140,7 @@ class ErrorInfoBase {
 ///         return Error(std::move(M));
 ///     });
 ///   // Note - The error passed to handleErrors will be marked as checked. If
-///   // there is no matched handler, a new error with the same playload is
+///   // 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



More information about the llvm-commits mailing list