summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
blob: 59a5166c505b35a59476131ede9f275748b7533f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <string>
#include <unordered_map>
#include <unordered_set>

int g_the_foo = 0;

int thefoo_rw(int arg = 1) {
  if (arg < 0)
    arg = 0;
  if (!arg)
    arg = 1;
  g_the_foo += arg;
  return g_the_foo;
}

int main() {

  char buffer[sizeof(std::unordered_map<int, std::string>)] = {0};
  std::unordered_map<int, std::string> &corrupt_map = *(std::unordered_map<int, std::string> *)buffer;

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_map<int, std::string> UnorderedMap;
  UnorderedMap map; // Set break point at this line.
  map.emplace(1, "hello");
  map.emplace(2, "world");
  map.emplace(3, "this");
  map.emplace(4, "is");
  map.emplace(5, "me");
  thefoo_rw(); // Set break point at this line.

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_multimap<int, std::string> UnorderedMultiMap;
  UnorderedMultiMap mmap;
  mmap.emplace(1, "hello");
  mmap.emplace(2, "hello");
  mmap.emplace(2, "world");
  mmap.emplace(3, "this");
  mmap.emplace(3, "this");
  mmap.emplace(3, "this");
  thefoo_rw(); // Set break point at this line.

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_set<int> IntsUnorderedSet;
  IntsUnorderedSet iset;
  iset.emplace(1);
  iset.emplace(2);
  iset.emplace(3);
  iset.emplace(4);
  iset.emplace(5);
  thefoo_rw(); // Set break point at this line.

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_set<std::string> StringsUnorderedSet;
  StringsUnorderedSet sset;
  sset.emplace("hello");
  sset.emplace("world");
  sset.emplace("this");
  sset.emplace("is");
  sset.emplace("me");
  thefoo_rw(); // Set break point at this line.

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_multiset<int> IntsUnorderedMultiSet;
  IntsUnorderedMultiSet imset;
  imset.emplace(1);
  imset.emplace(2);
  imset.emplace(2);
  imset.emplace(3);
  imset.emplace(3);
  imset.emplace(3);
  thefoo_rw(); // Set break point at this line.

  // Make a typedef to ensure functionality when typedefs are used.
  typedef std::unordered_multiset<std::string> StringsUnorderedMultiSet;
  StringsUnorderedMultiSet smset;
  smset.emplace("hello");
  smset.emplace("world");
  smset.emplace("world");
  smset.emplace("is");
  smset.emplace("is");
  thefoo_rw(); // Set break point at this line.

  return 0;
}