Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/include/llvm/ADT/DenseSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef LLVM_ADT_DENSESET_H
#define LLVM_ADT_DENSESET_H

#include "llvm/ADT/ADL.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/MathExtras.h"
Expand Down Expand Up @@ -237,6 +238,10 @@ class DenseSetImpl {
for (; I != E; ++I)
insert(*I);
}

template <typename Range> void insert_range(Range &&R) {
insert(adl_begin(R), adl_end(R));
}
};

/// Equality comparison for DenseSet.
Expand Down
8 changes: 8 additions & 0 deletions llvm/unittests/ADT/DenseSetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/ADT/DenseSet.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <type_traits>

Expand All @@ -32,6 +33,13 @@ TEST(DenseSetTest, DoubleEntrySetTest) {
EXPECT_EQ(0u, set.count(2));
}

TEST(DenseSetTest, InsertRange) {
llvm::DenseSet<unsigned> set;
constexpr unsigned Args[] = {3, 1, 2};
set.insert_range(Args);
EXPECT_THAT(set, ::testing::UnorderedElementsAre(1, 2, 3));
}

struct TestDenseSetInfo {
static inline unsigned getEmptyKey() { return ~0; }
static inline unsigned getTombstoneKey() { return ~0U - 1; }
Expand Down