aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/DenseMapTest.cpp
diff options
context:
space:
mode:
authorElijah Kin <elijah.m.kin@gmail.com>2025-07-10 10:46:12 -0700
committerGitHub <noreply@github.com>2025-07-10 10:46:12 -0700
commit49b87cd7793fe529c747940f483d0d57f963b6f7 (patch)
treefe0af27ff4ec3c530c23dce9364444633a51a4de /llvm/unittests/ADT/DenseMapTest.cpp
parentc92d5dad67aafded296653c2b9a369a7fe24ba13 (diff)
downloadllvm-49b87cd7793fe529c747940f483d0d57f963b6f7.zip
llvm-49b87cd7793fe529c747940f483d0d57f963b6f7.tar.gz
llvm-49b87cd7793fe529c747940f483d0d57f963b6f7.tar.bz2
DenseMapInfo: support std::optional<T> (#147851)
Diffstat (limited to 'llvm/unittests/ADT/DenseMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/DenseMapTest.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
index c95f96c..e3e8e8c 100644
--- a/llvm/unittests/ADT/DenseMapTest.cpp
+++ b/llvm/unittests/ADT/DenseMapTest.cpp
@@ -15,6 +15,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <map>
+#include <optional>
#include <set>
#include <utility>
#include <variant>
@@ -86,6 +87,14 @@ struct CtorTesterMapInfo {
CtorTester getTestKey(int i, CtorTester *) { return CtorTester(i); }
CtorTester getTestValue(int i, CtorTester *) { return CtorTester(42 + i); }
+std::optional<uint32_t> getTestKey(int i, std::optional<uint32_t> *) {
+ return i;
+}
+
+std::optional<uint32_t> getTestValue(int i, std::optional<uint32_t> *) {
+ return 42 + i;
+}
+
// Test fixture, with helper functions implemented by forwarding to global
// function overloads selected by component types of the type parameter. This
// allows all of the map implementations to be tested with shared
@@ -117,11 +126,13 @@ typedef ::testing::Types<DenseMap<uint32_t, uint32_t>,
DenseMap<uint32_t *, uint32_t *>,
DenseMap<CtorTester, CtorTester, CtorTesterMapInfo>,
DenseMap<EnumClass, uint32_t>,
+ DenseMap<std::optional<uint32_t>, uint32_t>,
SmallDenseMap<uint32_t, uint32_t>,
SmallDenseMap<uint32_t *, uint32_t *>,
SmallDenseMap<CtorTester, CtorTester, 4,
CtorTesterMapInfo>,
- SmallDenseMap<EnumClass, uint32_t>
+ SmallDenseMap<EnumClass, uint32_t>,
+ SmallDenseMap<std::optional<uint32_t>, uint32_t>
> DenseMapTestTypes;
// clang-format on