aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WindowsResource.cpp
diff options
context:
space:
mode:
authorMircea Trofin <mtrofin@google.com>2024-05-15 10:34:47 -0700
committerGitHub <noreply@github.com>2024-05-15 10:34:47 -0700
commit217668f641e82f901645f428ae0d07a3c01e9a8a (patch)
treed2c428d07a420c27b3b7aea38d6b9be55ac9ea9e /llvm/lib/Object/WindowsResource.cpp
parentd92c67784f21063d6334a009dbf4f9e0f8217b41 (diff)
downloadllvm-217668f641e82f901645f428ae0d07a3c01e9a8a.zip
llvm-217668f641e82f901645f428ae0d07a3c01e9a8a.tar.gz
llvm-217668f641e82f901645f428ae0d07a3c01e9a8a.tar.bz2
[nfc] Allow forwarding `Error` returns from `Expected` callers (#92208)
On a few compilers (clang 11/12 for example [1]), the following does not result in a copy elision, and since `Error`'s copy dtor is elided, results in a compile error: ``` Expect<Something> foobar() { ... if (Error E = aCallReturningError()) return E; ... } ``` Moving `E` would, conversely, result in the pessimizing-move warning on more recent clangs ("moving a local object in a return statement prevents copy elision") We just need to make the `Expected` ctor taking an `Error` take it as a r-value reference. [1] https://lab.llvm.org/buildbot/#/builders/54/builds/10505
Diffstat (limited to 'llvm/lib/Object/WindowsResource.cpp')
-rw-r--r--llvm/lib/Object/WindowsResource.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index 983c8e3..306e8ec 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -80,7 +80,7 @@ Expected<ResourceEntryRef>
ResourceEntryRef::create(BinaryStreamRef BSR, const WindowsResource *Owner) {
auto Ref = ResourceEntryRef(BSR, Owner);
if (auto E = Ref.loadNext())
- return std::move(E);
+ return E;
return Ref;
}
@@ -1006,7 +1006,7 @@ writeWindowsResourceCOFF(COFF::MachineTypes MachineType,
Error E = Error::success();
WindowsResourceCOFFWriter Writer(MachineType, Parser, E);
if (E)
- return std::move(E);
+ return E;
return Writer.write(TimeDateStamp);
}