[STLExtras] Use return type from operator* of the wrapped iter.
authorFlorian Hahn <flo@fhahn.com>
Sun, 10 Jan 2021 14:41:13 +0000 (14:41 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sun, 10 Jan 2021 14:41:13 +0000 (14:41 +0000)
commitc701f85c45589091f0d232fc2bc0bc390a6ab684
treef059295b7a2e1f5a1db37403a4e72613817370ab
parent47991a15d1925cba4687c5077cc9c81c8fcd00bd
[STLExtras] Use return type from operator* of the wrapped iter.

Currently make_early_inc_range cannot be used with iterators with
operator* implementations that do not return a reference.

Most notably in the LLVM codebase, this means the User iterator ranges
cannot be used with make_early_inc_range, which slightly simplifies
iterating over ranges while elements are removed.

Instead of directly using BaseT::reference as return type of operator*,
this patch uses decltype to get the actual return type of the operator*
implementation in WrappedIteratorT.

This patch also updates a few places to use make use of
make_early_inc_range.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D93992
llvm/include/llvm/ADT/STLExtras.h
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
llvm/unittests/ADT/STLExtrasTest.cpp