[all-commits] [llvm/llvm-project] 217668: [nfc] Allow forwarding `Error` returns from `Expec...
Mircea Trofin via All-commits
all-commits at lists.llvm.org
Wed May 15 10:35:08 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 217668f641e82f901645f428ae0d07a3c01e9a8a
https://github.com/llvm/llvm-project/commit/217668f641e82f901645f428ae0d07a3c01e9a8a
Author: Mircea Trofin <mtrofin at google.com>
Date: 2024-05-15 (Wed, 15 May 2024)
Changed paths:
M llvm/include/llvm/Support/Error.h
M llvm/lib/Bitstream/Reader/BitstreamReader.cpp
M llvm/lib/Object/COFFObjectFile.cpp
M llvm/lib/Object/WindowsResource.cpp
Log Message:
-----------
[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
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list