Object: Add a missing return in ObjectFile::createObjectFile
authorJustin Bogner <mail@justinbogner.com>
Tue, 18 Oct 2016 05:17:23 +0000 (05:17 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 18 Oct 2016 05:17:23 +0000 (05:17 +0000)
When Error was threaded through these APIs back in r265606 the
"return" was missed here, which triggers a warning if/when I add
LLVM_NODISCARD to the Error type.

llvm-svn: 284454

llvm/lib/Object/ObjectFile.cpp

index 92f9c1f..bd50773 100644 (file)
@@ -118,8 +118,8 @@ ObjectFile::createObjectFile(StringRef ObjectPath) {
 
   Expected<std::unique_ptr<ObjectFile>> ObjOrErr =
       createObjectFile(Buffer->getMemBufferRef());
-  if (!ObjOrErr)
-    ObjOrErr.takeError();
+  if (Error Err = ObjOrErr.takeError())
+    return std::move(Err);
   std::unique_ptr<ObjectFile> Obj = std::move(ObjOrErr.get());
 
   return OwningBinary<ObjectFile>(std::move(Obj), std::move(Buffer));