[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.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 16:18:32 PDT 2015


lhames added inline comments.

================
Comment at: include/llvm/Object/Archive.h:111
@@ -109,3 +110,3 @@
   class child_iterator {
-    Child child;
+    ErrorOr<Child> child;
 
----------------
rafael wrote:
> I don't think the iterator should include the possibility of being at error. Everywhere else we just push the error outwards.
> 
> This should still be just "Child child;" and then when appropriate we should use a ErrorOr<child_iterator>. For example, child_begin should return that.
Unfortunately we can't just wrap the iterator here: Increment itself can fail if any given Child's header is damaged, so the iterator needs to handle the possibility of failure.

As a bonus, handling failure inside the iterator allows you to use ranged-based for loops, which you can't use if the iterator is wrapped.


http://reviews.llvm.org/D13989





More information about the llvm-commits mailing list