diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h index 6ee9375b175b7..0692071adb391 100644 --- a/llvm/include/llvm/ADT/SetVector.h +++ b/llvm/include/llvm/ADT/SetVector.h @@ -386,6 +386,10 @@ class SmallSetVector : public SetVector, DenseSet, N> { SmallSetVector(It Start, It End) { this->insert(Start, End); } + + template + SmallSetVector(llvm::from_range_t, Range &&R) + : SmallSetVector(adl_begin(R), adl_end(R)) {} }; } // end namespace llvm diff --git a/llvm/unittests/ADT/SetVectorTest.cpp b/llvm/unittests/ADT/SetVectorTest.cpp index 6ce4360cab90e..ff3c876deb458 100644 --- a/llvm/unittests/ADT/SetVectorTest.cpp +++ b/llvm/unittests/ADT/SetVectorTest.cpp @@ -100,3 +100,9 @@ TEST(SetVector, InsertRange) { Set.insert_range(Args); EXPECT_THAT(Set, ::testing::ElementsAre(3, 1, 2)); } + +TEST(SmallSetVector, CtorRange) { + constexpr unsigned Args[] = {3, 1, 2}; + SmallSetVector Set(llvm::from_range, Args); + EXPECT_THAT(Set, ::testing::ElementsAre(3, 1, 2)); +}