[PATCH] D49234: [DebugInfo] Refactor DWARFDie::iterator to prevent UB

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 18:41:39 PDT 2018


efriedma added a comment.

[forward.iterators]: "Two dereferenceable iterators a and b of type X offer the multi-pass guarantee if [...] the expression `(void)++X(a), *a` is equivalent to the expression `*a`."  [reverse.iter.requirements]: "The template parameter Iterator shall meet all the requirements of a Bidirectional Iterator".  So it's UB to use std::reverse_iterator with your iterator.

There isn't any standard way to handle this situation; libcxx has an internal hack for standard library types (https://reviews.llvm.org/rL300164).


https://reviews.llvm.org/D49234





More information about the llvm-commits mailing list