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

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 18:10:49 PDT 2018


dblaikie added a subscriber: rsmith.
dblaikie added a comment.

@rsmith - Richard, I'd be curious for your opinion here. I've been casting through the runes of the standard for C++ iterator semantics/guarantees, and I can't find where the iterator requirements are that makes std::reverse_iterator's behavior valid (basically relying on the underlying sequence having indefinitely persistent storage - that a pointer/reference to an element is valid even after the iterator that pointer/reference was obtained from goes out of scope). And whether there's some other solution - a common/predefined type trait for saying "hey this isn't valid" or "this is the reverse iterator type for this sequence" (so llvm::reverse(Range) could use that trait to decide how to get reverse iterators from the forward ones) or if we should create such a trait (though I guess it'd still be problematic for any other iterator adapters having to somehow forward through/expose such details... :/)?


https://reviews.llvm.org/D49234





More information about the llvm-commits mailing list