summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Archive.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-07-22 16:11:25 +0000
committerLang Hames <lhames@gmail.com>2016-07-22 16:11:25 +0000
commit5e51a2e31abac0d03f5a3056d368b7cd289beff1 (patch)
tree3cfa6d2a2ff799451243715a1d8eae75289e5dfe /llvm/lib/Object/Archive.cpp
parent047149f7452ac3eeeff226683d7fb1d354fc36cf (diff)
downloadbcm5719-llvm-5e51a2e31abac0d03f5a3056d368b7cd289beff1.tar.gz
bcm5719-llvm-5e51a2e31abac0d03f5a3056d368b7cd289beff1.zip
[Support] Make ErrorAsOutParameter take an Error* rather than an Error&.
This allows ErrorAsOutParameter to work better with "optional" errors. For example, consider a function where for certain input values it is known that the function can't fail. This can now be written as: Result foo(Arg X, Error *Err) { ErrorAsOutParameter EAO(Err); if (<Error Condition>) { if (Err) *Err = <report error>; else llvm_unreachable("Unexpected failure!"); } } Rather than having to construct an ErrorAsOutParameter under every conditional where Err is known to be non-null. llvm-svn: 276430
Diffstat (limited to 'llvm/lib/Object/Archive.cpp')
-rw-r--r--llvm/lib/Object/Archive.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 6d0330d52ec..84ef358344d 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -108,16 +108,15 @@ Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
: Parent(Parent) {
if (!Start)
return;
+ ErrorAsOutParameter ErrAsOutParam(Err);
uint64_t Size = sizeof(ArchiveMemberHeader);
Data = StringRef(Start, Size);
if (!isThinMember()) {
Expected<uint64_t> MemberSize = getRawSize();
if (!MemberSize) {
- if (Err) {
- ErrorAsOutParameter ErrAsOutParam(*Err);
+ if (Err)
*Err = MemberSize.takeError();
- }
return;
}
Size += MemberSize.get();
@@ -299,7 +298,7 @@ void Archive::setFirstRegular(const Child &C) {
Archive::Archive(MemoryBufferRef Source, Error &Err)
: Binary(Binary::ID_Archive, Source) {
- ErrorAsOutParameter ErrAsOutParam(Err);
+ ErrorAsOutParameter ErrAsOutParam(&Err);
StringRef Buffer = Data.getBuffer();
// Check for sufficient magic.
if (Buffer.startswith(ThinMagic)) {
OpenPOWER on IntegriCloud