[PATCH] D13989: This removes the eating of the error in Archive::Child::getSize() when the charactersin the size field in the archive header for the member is not a number.

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 24 06:10:31 PDT 2015


rafael added inline comments.

================
Comment at: lib/Object/Archive.cpp:95
@@ +94,3 @@
+    ErrorOr<uint64_t> MemberSize = getRawSize();
+    if (MemberSize.getError()) {
+      assert (EC && "Error must be caught");
----------------
You can write this as

if ((EC = MemberSize.getError())
  return;


================
Comment at: lib/Object/Archive.cpp:188
@@ -158,2 +187,3 @@
 
-  return Child(Parent, NextLoc);
+  auto ChildOrErr = Child::create(Parent, NextLoc);
+  if (std::error_code EC = ChildOrErr.getError())
----------------
This introduces a memory allocation. Please don't do that. In fact, please don't add Child::create at all. We don't want to allocate a Child, they are passed by value. This should be

std::error_code EC;
Child Ret(Parent, NextLoc, EC);
if (EC)
  return EC;
return Ret;


http://reviews.llvm.org/D13989





More information about the llvm-commits mailing list