aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-02 12:42:48 -0400
committerNico Weber <thakis@chromium.org>2021-09-02 14:45:56 -0400
commit5881dcff7e76a68323edc8bb3c6e14420ad9cf7c (patch)
tree93dbf53c03b9e9cdfa42d5e4ffd975126b16a44b /llvm/unittests/ADT/StringMapTest.cpp
parenta270de359f46ee47f568af9b0e9c3849e7eefce8 (diff)
downloadllvm-5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.zip
llvm-5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.tar.gz
llvm-5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.tar.bz2
Try to unbreak Win build differently after 973519826edb76
Looks like the MS STL wants StringMapKeyIterator::operator*() to be const. Return the result by copy instead of reference to do that. Assigning to a hash map key iterator doesn't make sense anyways. Also reverts 123f811fe5b0b which is now hopefully no longer needed. Differential Revision: https://reviews.llvm.org/D109167
Diffstat (limited to 'llvm/unittests/ADT/StringMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringMapTest.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 6a3cca5..f38a604 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
EXPECT_EQ(0, try1.first->second.copy);
}
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+ StringMap<int> Map;
+ Map["A"] = 1;
+ Map["B"] = 2;
+ Map["C"] = 3;
+ Map["D"] = 3;
+
+ std::vector<StringRef> Keys{Map.keys().begin(), Map.keys().end()};
+ llvm::sort(Keys);
+
+ std::vector<StringRef> Expected{{"A", "B", "C", "D"}};
+ EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
StringMap<int> Map;
Map["A"] = 1;
Map["B"] = 2;