diff options
author | Nikita Popov <npopov@redhat.com> | 2024-06-14 11:35:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 11:35:27 +0200 |
commit | 44df1167f88cabbb4cfde816f279337379ea30b3 (patch) | |
tree | ac5d601943f3c63519f6812e276da4aaff7de901 /llvm/tools | |
parent | 4bccd25467ce591869dad41c8b7c550093c20f1b (diff) | |
download | llvm-44df1167f88cabbb4cfde816f279337379ea30b3.zip llvm-44df1167f88cabbb4cfde816f279337379ea30b3.tar.gz llvm-44df1167f88cabbb4cfde816f279337379ea30b3.tar.bz2 |
[Error] Add non-consuming toString (#95375)
There are some places that want to convert an Error to string, but still
retain the original Error object, for example to emit a non-fatal
warning.
This currently isn't possible, because the entire Error infra is
move-based. And what people end up doing in this case is to move the
Error... twice.
This patch introduces a toStringWithoutConsuming() function to
accommodate this use case. This also requires some infrastructure that
allows visiting Errors without consuming them.
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/dsymutil/DwarfLinkerForBinary.cpp | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index 8347370..f6a3570 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -147,7 +147,7 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj, if (!ObjectEntry) { auto Err = ObjectEntry.takeError(); reportWarning(Twine(Obj.getObjectFilename()) + ": " + - toString(std::move(Err)), + toStringWithoutConsuming(Err), Obj.getObjectFilename()); return errorToErrorCode(std::move(Err)); } @@ -156,7 +156,7 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj, if (!Object) { auto Err = Object.takeError(); reportWarning(Twine(Obj.getObjectFilename()) + ": " + - toString(std::move(Err)), + toStringWithoutConsuming(Err), Obj.getObjectFilename()); return errorToErrorCode(std::move(Err)); } diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index 1cecbfc..b2362ec 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -1494,13 +1494,13 @@ Error DumpOutputStyle::dumpModuleSymsForPdb() { if (auto EC = Visitor.visitSymbolStreamFiltered(ModS.getSymbolArray(), Filter)) { P.formatLine("Error while processing symbol records. {0}", - toString(std::move(EC))); + toStringWithoutConsuming(EC)); return EC; } } else if (auto EC = Visitor.visitSymbolStream(ModS.getSymbolArray(), SS.Offset)) { P.formatLine("Error while processing symbol records. {0}", - toString(std::move(EC))); + toStringWithoutConsuming(EC)); return EC; } return Error::success(); |