Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Core/UniqueCStringMap.h
Line
Count
Source (jump to first uncovered line)
1
//===-- UniqueCStringMap.h --------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_CORE_UNIQUECSTRINGMAP_H
10
#define LLDB_CORE_UNIQUECSTRINGMAP_H
11
12
#include <algorithm>
13
#include <vector>
14
15
#include "lldb/Utility/ConstString.h"
16
#include "lldb/Utility/RegularExpression.h"
17
18
namespace lldb_private {
19
20
// Templatized uniqued string map.
21
//
22
// This map is useful for mapping unique C string names to values of type T.
23
// Each "const char *" name added must be unique for a given
24
// C string value. ConstString::GetCString() can provide such strings.
25
// Any other string table that has guaranteed unique values can also be used.
26
template <typename T> class UniqueCStringMap {
27
public:
28
  struct Entry {
29
195M
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<unsigned int>::Entry::Entry(lldb_private::ConstString, unsigned int const&)
Line
Count
Source
29
193M
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry::Entry(lldb_private::ConstString, lldb_private::OptionValueEnumeration::EnumeratorInfo const&)
Line
Count
Source
29
208k
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<unsigned long>::Entry::Entry(lldb_private::ConstString, unsigned long const&)
Line
Count
Source
29
843k
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<lldb::BasicType>::Entry::Entry(lldb_private::ConstString, lldb::BasicType const&)
Line
Count
Source
29
96
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<DWARFDIE>::Entry::Entry(lldb_private::ConstString, DWARFDIE const&)
Line
Count
Source
29
16
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
lldb_private::UniqueCStringMap<DIERef>::Entry::Entry(lldb_private::ConstString, DIERef const&)
Line
Count
Source
29
105k
    Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
30
31
    ConstString cstring;
32
    T value;
33
  };
34
35
  typedef std::vector<Entry> collection;
36
  typedef typename collection::iterator iterator;
37
  typedef typename collection::const_iterator const_iterator;
38
39
  // Call this function multiple times to add a bunch of entries to this map,
40
  // then later call UniqueCStringMap<T>::Sort() before doing any searches by
41
  // name.
42
174M
  void Append(ConstString unique_cstr, const T &value) {
43
174M
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
174M
  }
lldb_private::UniqueCStringMap<unsigned int>::Append(lldb_private::ConstString, unsigned int const&)
Line
Count
Source
42
172M
  void Append(ConstString unique_cstr, const T &value) {
43
172M
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
172M
  }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Append(lldb_private::ConstString, lldb_private::OptionValueEnumeration::EnumeratorInfo const&)
Line
Count
Source
42
208k
  void Append(ConstString unique_cstr, const T &value) {
43
208k
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
208k
  }
lldb_private::UniqueCStringMap<unsigned long>::Append(lldb_private::ConstString, unsigned long const&)
Line
Count
Source
42
843k
  void Append(ConstString unique_cstr, const T &value) {
43
843k
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
843k
  }
lldb_private::UniqueCStringMap<lldb::BasicType>::Append(lldb_private::ConstString, lldb::BasicType const&)
Line
Count
Source
42
96
  void Append(ConstString unique_cstr, const T &value) {
43
96
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
96
  }
lldb_private::UniqueCStringMap<DWARFDIE>::Append(lldb_private::ConstString, DWARFDIE const&)
Line
Count
Source
42
16
  void Append(ConstString unique_cstr, const T &value) {
43
16
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
16
  }
lldb_private::UniqueCStringMap<DIERef>::Append(lldb_private::ConstString, DIERef const&)
Line
Count
Source
42
105k
  void Append(ConstString unique_cstr, const T &value) {
43
105k
    m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
44
105k
  }
45
46
28.6M
  void Append(const Entry &e) { m_map.push_back(e); }
47
48
67.6k
  void Clear() { m_map.clear(); }
lldb_private::UniqueCStringMap<unsigned int>::Clear()
Line
Count
Source
48
2.29k
  void Clear() { m_map.clear(); }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Clear()
Line
Count
Source
48
65.3k
  void Clear() { m_map.clear(); }
lldb_private::UniqueCStringMap<DIERef>::Clear()
Line
Count
Source
48
44
  void Clear() { m_map.clear(); }
49
50
  // Get an entries by index in a variety of forms.
51
  //
52
  // The caller is responsible for ensuring that the collection does not change
53
  // during while using the returned values.
54
  bool GetValueAtIndex(uint32_t idx, T &value) const {
55
    if (idx < m_map.size()) {
56
      value = m_map[idx].value;
57
      return true;
58
    }
59
    return false;
60
  }
61
62
52.6k
  ConstString GetCStringAtIndexUnchecked(uint32_t idx) const {
63
52.6k
    return m_map[idx].cstring;
64
52.6k
  }
65
66
  // Use this function if you have simple types in your map that you can easily
67
  // copy when accessing values by index.
68
52.9k
  T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::GetValueAtIndexUnchecked(unsigned int) const
Line
Count
Source
68
205
  T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
lldb_private::UniqueCStringMap<DWARFDIE>::GetValueAtIndexUnchecked(unsigned int) const
Line
Count
Source
68
26
  T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
lldb_private::UniqueCStringMap<DIERef>::GetValueAtIndexUnchecked(unsigned int) const
Line
Count
Source
68
52.7k
  T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
69
70
  // Use this function if you have complex types in your map that you don't
71
  // want to copy when accessing values by index.
72
72
  const T &GetValueRefAtIndexUnchecked(uint32_t idx) const {
73
72
    return m_map[idx].value;
74
72
  }
75
76
192
  ConstString GetCStringAtIndex(uint32_t idx) const {
77
192
    return ((idx < m_map.size()) ? m_map[idx].cstring : 
ConstString()0
);
78
192
  }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::GetCStringAtIndex(unsigned int) const
Line
Count
Source
76
114
  ConstString GetCStringAtIndex(uint32_t idx) const {
77
114
    return ((idx < m_map.size()) ? m_map[idx].cstring : 
ConstString()0
);
78
114
  }
lldb_private::UniqueCStringMap<DWARFDIE>::GetCStringAtIndex(unsigned int) const
Line
Count
Source
76
6
  ConstString GetCStringAtIndex(uint32_t idx) const {
77
6
    return ((idx < m_map.size()) ? m_map[idx].cstring : 
ConstString()0
);
78
6
  }
lldb_private::UniqueCStringMap<DIERef>::GetCStringAtIndex(unsigned int) const
Line
Count
Source
76
72
  ConstString GetCStringAtIndex(uint32_t idx) const {
77
72
    return ((idx < m_map.size()) ? m_map[idx].cstring : 
ConstString()0
);
78
72
  }
79
80
  // Find the value for the unique string in the map.
81
  //
82
  // Return the value for \a unique_cstr if one is found, return \a fail_value
83
  // otherwise. This method works well for simple type
84
  // T values and only if there is a sensible failure value that can
85
  // be returned and that won't match any existing values.
86
324k
  T Find(ConstString unique_cstr, T fail_value) const {
87
324k
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
88
324k
    if (pos != m_map.end() && 
pos->cstring == unique_cstr283k
)
89
223k
      return pos->value;
90
101k
    return fail_value;
91
324k
  }
lldb_private::UniqueCStringMap<unsigned long>::Find(lldb_private::ConstString, unsigned long) const
Line
Count
Source
86
324k
  T Find(ConstString unique_cstr, T fail_value) const {
87
324k
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
88
324k
    if (pos != m_map.end() && 
pos->cstring == unique_cstr283k
)
89
222k
      return pos->value;
90
101k
    return fail_value;
91
324k
  }
lldb_private::UniqueCStringMap<lldb::BasicType>::Find(lldb_private::ConstString, lldb::BasicType) const
Line
Count
Source
86
38
  T Find(ConstString unique_cstr, T fail_value) const {
87
38
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
88
38
    if (pos != m_map.end() && pos->cstring == unique_cstr)
89
34
      return pos->value;
90
4
    return fail_value;
91
38
  }
lldb_private::UniqueCStringMap<DWARFDIE>::Find(lldb_private::ConstString, DWARFDIE) const
Line
Count
Source
86
6
  T Find(ConstString unique_cstr, T fail_value) const {
87
6
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
88
6
    if (pos != m_map.end() && pos->cstring == unique_cstr)
89
0
      return pos->value;
90
6
    return fail_value;
91
6
  }
92
93
  // Get a pointer to the first entry that matches "name". nullptr will be
94
  // returned if there is no entry that matches "name".
95
  //
96
  // The caller is responsible for ensuring that the collection does not change
97
  // during while using the returned pointer.
98
1.10M
  const Entry *FindFirstValueForName(ConstString unique_cstr) const {
99
1.10M
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
100
1.10M
    if (pos != m_map.end() && 
pos->cstring == unique_cstr188k
)
101
5.36k
      return &(*pos);
102
1.10M
    return nullptr;
103
1.10M
  }
lldb_private::UniqueCStringMap<unsigned int>::FindFirstValueForName(lldb_private::ConstString) const
Line
Count
Source
98
1.10M
  const Entry *FindFirstValueForName(ConstString unique_cstr) const {
99
1.10M
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
100
1.10M
    if (pos != m_map.end() && 
pos->cstring == unique_cstr184k
)
101
1.32k
      return &(*pos);
102
1.10M
    return nullptr;
103
1.10M
  }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::FindFirstValueForName(lldb_private::ConstString) const
Line
Count
Source
98
4.04k
  const Entry *FindFirstValueForName(ConstString unique_cstr) const {
99
4.04k
    auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
100
4.04k
    if (pos != m_map.end() && pos->cstring == unique_cstr)
101
4.04k
      return &(*pos);
102
0
    return nullptr;
103
4.04k
  }
104
105
  // Get a pointer to the next entry that matches "name" from a previously
106
  // returned Entry pointer. nullptr will be returned if there is no subsequent
107
  // entry that matches "name".
108
  //
109
  // The caller is responsible for ensuring that the collection does not change
110
  // during while using the returned pointer.
111
4.39k
  const Entry *FindNextValueForName(const Entry *entry_ptr) const {
112
4.39k
    if (!m_map.empty()) {
113
4.39k
      const Entry *first_entry = &m_map[0];
114
4.39k
      const Entry *after_last_entry = first_entry + m_map.size();
115
4.39k
      const Entry *next_entry = entry_ptr + 1;
116
4.39k
      if (first_entry <= next_entry && next_entry < after_last_entry) {
117
4.16k
        if (next_entry->cstring == entry_ptr->cstring)
118
3.26k
          return next_entry;
119
4.16k
      }
120
4.39k
    }
121
1.12k
    return nullptr;
122
4.39k
  }
123
124
5.91M
  size_t GetValues(ConstString unique_cstr, std::vector<T> &values) const {
125
5.91M
    const size_t start_size = values.size();
126
127
5.91M
    for (const Entry &entry : llvm::make_range(std::equal_range(
128
5.91M
             m_map.begin(), m_map.end(), unique_cstr, Compare())))
129
283k
      values.push_back(entry.value);
130
131
5.91M
    return values.size() - start_size;
132
5.91M
  }
133
134
  size_t GetValues(const RegularExpression &regex,
135
0
                   std::vector<T> &values) const {
136
0
    const size_t start_size = values.size();
137
138
0
    const_iterator pos, end = m_map.end();
139
0
    for (pos = m_map.begin(); pos != end; ++pos) {
140
0
      if (regex.Execute(pos->cstring.GetCString()))
141
0
        values.push_back(pos->value);
142
0
    }
143
144
0
    return values.size() - start_size;
145
0
  }
146
147
  // Get the total number of entries in this map.
148
46.4k
  size_t GetSize() const { return m_map.size(); }
lldb_private::UniqueCStringMap<unsigned int>::GetSize() const
Line
Count
Source
148
7
  size_t GetSize() const { return m_map.size(); }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::GetSize() const
Line
Count
Source
148
114
  size_t GetSize() const { return m_map.size(); }
lldb_private::UniqueCStringMap<DWARFDIE>::GetSize() const
Line
Count
Source
148
32
  size_t GetSize() const { return m_map.size(); }
lldb_private::UniqueCStringMap<DIERef>::GetSize() const
Line
Count
Source
148
46.3k
  size_t GetSize() const { return m_map.size(); }
149
150
  // Returns true if this map is empty.
151
220
  bool IsEmpty() const { return m_map.empty(); }
lldb_private::UniqueCStringMap<unsigned int>::IsEmpty() const
Line
Count
Source
151
40
  bool IsEmpty() const { return m_map.empty(); }
lldb_private::UniqueCStringMap<DWARFDIE>::IsEmpty() const
Line
Count
Source
151
12
  bool IsEmpty() const { return m_map.empty(); }
lldb_private::UniqueCStringMap<DIERef>::IsEmpty() const
Line
Count
Source
151
168
  bool IsEmpty() const { return m_map.empty(); }
152
153
  // Reserve memory for at least "n" entries in the map. This is useful to call
154
  // when you know you will be adding a lot of entries using
155
  // UniqueCStringMap::Append() (which should be followed by a call to
156
  // UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert().
157
142k
  void Reserve(size_t n) { m_map.reserve(n); }
lldb_private::UniqueCStringMap<unsigned int>::Reserve(unsigned long)
Line
Count
Source
157
142k
  void Reserve(size_t n) { m_map.reserve(n); }
lldb_private::UniqueCStringMap<DIERef>::Reserve(unsigned long)
Line
Count
Source
157
36
  void Reserve(size_t n) { m_map.reserve(n); }
158
159
  // Sort the unsorted contents in this map. A typical code flow would be:
160
  // size_t approximate_num_entries = ....
161
  // UniqueCStringMap<uint32_t> my_map;
162
  // my_map.Reserve (approximate_num_entries);
163
  // for (...)
164
  // {
165
  //      my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
166
  // }
167
  // my_map.Sort();
168
891k
  void Sort() {
169
51.6M
    Sort([](const T &, const T &) { return false; });
lldb_private::UniqueCStringMap<unsigned int>::Sort()::'lambda'(unsigned int const&, unsigned int const&)::operator()(unsigned int const&, unsigned int const&) const
Line
Count
Source
169
51.5M
    Sort([](const T &, const T &) { return false; });
Unexecuted instantiation: lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()::'lambda'(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&)::operator()(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&) const
lldb_private::UniqueCStringMap<unsigned long>::Sort()::'lambda'(unsigned long const&, unsigned long const&)::operator()(unsigned long const&, unsigned long const&) const
Line
Count
Source
169
119k
    Sort([](const T &, const T &) { return false; });
lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()::'lambda'(lldb::BasicType const&, lldb::BasicType const&)::operator()(lldb::BasicType const&, lldb::BasicType const&) const
Line
Count
Source
169
4
    Sort([](const T &, const T &) { return false; });
Unexecuted instantiation: lldb_private::UniqueCStringMap<DWARFDIE>::Sort()::'lambda'(DWARFDIE const&, DWARFDIE const&)::operator()(DWARFDIE const&, DWARFDIE const&) const
170
891k
  }
lldb_private::UniqueCStringMap<unsigned int>::Sort()
Line
Count
Source
168
587k
  void Sort() {
169
587k
    Sort([](const T &, const T &) { return false; });
170
587k
  }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()
Line
Count
Source
168
65.3k
  void Sort() {
169
65.3k
    Sort([](const T &, const T &) { return false; });
170
65.3k
  }
lldb_private::UniqueCStringMap<unsigned long>::Sort()
Line
Count
Source
168
239k
  void Sort() {
169
239k
    Sort([](const T &, const T &) { return false; });
170
239k
  }
lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()
Line
Count
Source
168
3
  void Sort() {
169
3
    Sort([](const T &, const T &) { return false; });
170
3
  }
lldb_private::UniqueCStringMap<DWARFDIE>::Sort()
Line
Count
Source
168
6
  void Sort() {
169
6
    Sort([](const T &, const T &) { return false; });
170
6
  }
171
172
  /// Sort contents of this map using the provided comparator to break ties for
173
  /// entries with the same string value.
174
935k
  template <typename TCompare> void Sort(TCompare tc) {
175
935k
    Compare c;
176
2.99G
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
2.99G
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
2.99G
      if (result == 0)
179
51.6M
        return tc(lhs.value, rhs.value);
180
2.94G
      return result < 0;
181
2.99G
    });
void lldb_private::UniqueCStringMap<unsigned int>::Sort<lldb_private::UniqueCStringMap<unsigned int>::Sort()::'lambda'(unsigned int const&, unsigned int const&)>(lldb_private::UniqueCStringMap<unsigned int>::Sort()::'lambda'(unsigned int const&, unsigned int const&))::'lambda'(lldb_private::UniqueCStringMap<unsigned int>::Entry const&, lldb_private::UniqueCStringMap<unsigned int>::Entry const&)::operator()(lldb_private::UniqueCStringMap<unsigned int>::Entry const&, lldb_private::UniqueCStringMap<unsigned int>::Entry const&) const
Line
Count
Source
176
2.98G
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
2.98G
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
2.98G
      if (result == 0)
179
51.5M
        return tc(lhs.value, rhs.value);
180
2.93G
      return result < 0;
181
2.98G
    });
void lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort<lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()::'lambda'(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&)>(lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()::'lambda'(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&))::'lambda'(lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry const&, lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry const&)::operator()(lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry const&, lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry const&) const
Line
Count
Source
176
202k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
202k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
202k
      if (result == 0)
179
0
        return tc(lhs.value, rhs.value);
180
202k
      return result < 0;
181
202k
    });
void lldb_private::UniqueCStringMap<unsigned long>::Sort<lldb_private::UniqueCStringMap<unsigned long>::Sort()::'lambda'(unsigned long const&, unsigned long const&)>(lldb_private::UniqueCStringMap<unsigned long>::Sort()::'lambda'(unsigned long const&, unsigned long const&))::'lambda'(lldb_private::UniqueCStringMap<unsigned long>::Entry const&, lldb_private::UniqueCStringMap<unsigned long>::Entry const&)::operator()(lldb_private::UniqueCStringMap<unsigned long>::Entry const&, lldb_private::UniqueCStringMap<unsigned long>::Entry const&) const
Line
Count
Source
176
9.37M
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
9.37M
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
9.37M
      if (result == 0)
179
119k
        return tc(lhs.value, rhs.value);
180
9.25M
      return result < 0;
181
9.37M
    });
void lldb_private::UniqueCStringMap<lldb::BasicType>::Sort<lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()::'lambda'(lldb::BasicType const&, lldb::BasicType const&)>(lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()::'lambda'(lldb::BasicType const&, lldb::BasicType const&))::'lambda'(lldb_private::UniqueCStringMap<lldb::BasicType>::Entry const&, lldb_private::UniqueCStringMap<lldb::BasicType>::Entry const&)::operator()(lldb_private::UniqueCStringMap<lldb::BasicType>::Entry const&, lldb_private::UniqueCStringMap<lldb::BasicType>::Entry const&) const
Line
Count
Source
176
458
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
458
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
458
      if (result == 0)
179
4
        return tc(lhs.value, rhs.value);
180
454
      return result < 0;
181
458
    });
Unexecuted instantiation: void lldb_private::UniqueCStringMap<DWARFDIE>::Sort<lldb_private::UniqueCStringMap<DWARFDIE>::Sort()::'lambda'(DWARFDIE const&, DWARFDIE const&)>(lldb_private::UniqueCStringMap<DWARFDIE>::Sort()::'lambda'(DWARFDIE const&, DWARFDIE const&))::'lambda'(lldb_private::UniqueCStringMap<DWARFDIE>::Entry const&, lldb_private::UniqueCStringMap<DWARFDIE>::Entry const&)::operator()(lldb_private::UniqueCStringMap<DWARFDIE>::Entry const&, lldb_private::UniqueCStringMap<DWARFDIE>::Entry const&) const
void lldb_private::UniqueCStringMap<DIERef>::Sort<std::__1::less<DIERef> >(std::__1::less<DIERef>)::'lambda'(lldb_private::UniqueCStringMap<DIERef>::Entry const&, lldb_private::UniqueCStringMap<DIERef>::Entry const&)::operator()(lldb_private::UniqueCStringMap<DIERef>::Entry const&, lldb_private::UniqueCStringMap<DIERef>::Entry const&) const
Line
Count
Source
176
169k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
169k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
169k
      if (result == 0)
179
703
        return tc(lhs.value, rhs.value);
180
168k
      return result < 0;
181
169k
    });
182
935k
  }
void lldb_private::UniqueCStringMap<unsigned int>::Sort<lldb_private::UniqueCStringMap<unsigned int>::Sort()::'lambda'(unsigned int const&, unsigned int const&)>(lldb_private::UniqueCStringMap<unsigned int>::Sort()::'lambda'(unsigned int const&, unsigned int const&))
Line
Count
Source
174
587k
  template <typename TCompare> void Sort(TCompare tc) {
175
587k
    Compare c;
176
587k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
587k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
587k
      if (result == 0)
179
587k
        return tc(lhs.value, rhs.value);
180
587k
      return result < 0;
181
587k
    });
182
587k
  }
void lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort<lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()::'lambda'(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&)>(lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Sort()::'lambda'(lldb_private::OptionValueEnumeration::EnumeratorInfo const&, lldb_private::OptionValueEnumeration::EnumeratorInfo const&))
Line
Count
Source
174
65.3k
  template <typename TCompare> void Sort(TCompare tc) {
175
65.3k
    Compare c;
176
65.3k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
65.3k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
65.3k
      if (result == 0)
179
65.3k
        return tc(lhs.value, rhs.value);
180
65.3k
      return result < 0;
181
65.3k
    });
182
65.3k
  }
void lldb_private::UniqueCStringMap<unsigned long>::Sort<lldb_private::UniqueCStringMap<unsigned long>::Sort()::'lambda'(unsigned long const&, unsigned long const&)>(lldb_private::UniqueCStringMap<unsigned long>::Sort()::'lambda'(unsigned long const&, unsigned long const&))
Line
Count
Source
174
239k
  template <typename TCompare> void Sort(TCompare tc) {
175
239k
    Compare c;
176
239k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
239k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
239k
      if (result == 0)
179
239k
        return tc(lhs.value, rhs.value);
180
239k
      return result < 0;
181
239k
    });
182
239k
  }
void lldb_private::UniqueCStringMap<lldb::BasicType>::Sort<lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()::'lambda'(lldb::BasicType const&, lldb::BasicType const&)>(lldb_private::UniqueCStringMap<lldb::BasicType>::Sort()::'lambda'(lldb::BasicType const&, lldb::BasicType const&))
Line
Count
Source
174
3
  template <typename TCompare> void Sort(TCompare tc) {
175
3
    Compare c;
176
3
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
3
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
3
      if (result == 0)
179
3
        return tc(lhs.value, rhs.value);
180
3
      return result < 0;
181
3
    });
182
3
  }
void lldb_private::UniqueCStringMap<DWARFDIE>::Sort<lldb_private::UniqueCStringMap<DWARFDIE>::Sort()::'lambda'(DWARFDIE const&, DWARFDIE const&)>(lldb_private::UniqueCStringMap<DWARFDIE>::Sort()::'lambda'(DWARFDIE const&, DWARFDIE const&))
Line
Count
Source
174
6
  template <typename TCompare> void Sort(TCompare tc) {
175
6
    Compare c;
176
6
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
6
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
6
      if (result == 0)
179
6
        return tc(lhs.value, rhs.value);
180
6
      return result < 0;
181
6
    });
182
6
  }
void lldb_private::UniqueCStringMap<DIERef>::Sort<std::__1::less<DIERef> >(std::__1::less<DIERef>)
Line
Count
Source
174
44.0k
  template <typename TCompare> void Sort(TCompare tc) {
175
44.0k
    Compare c;
176
44.0k
    llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool {
177
44.0k
      int result = c.ThreeWay(lhs.cstring, rhs.cstring);
178
44.0k
      if (result == 0)
179
44.0k
        return tc(lhs.value, rhs.value);
180
44.0k
      return result < 0;
181
44.0k
    });
182
44.0k
  }
183
184
  // Since we are using a vector to contain our items it will always double its
185
  // memory consumption as things are added to the vector, so if you intend to
186
  // keep a UniqueCStringMap around and have a lot of entries in the map, you
187
  // will want to call this function to create a new vector and copy _only_ the
188
  // exact size needed as part of the finalization of the string map.
189
614k
  void SizeToFit() {
190
614k
    if (m_map.size() < m_map.capacity()) {
191
200k
      collection temp(m_map.begin(), m_map.end());
192
200k
      m_map.swap(temp);
193
200k
    }
194
614k
  }
lldb_private::UniqueCStringMap<unsigned int>::SizeToFit()
Line
Count
Source
189
570k
  void SizeToFit() {
190
570k
    if (m_map.size() < m_map.capacity()) {
191
197k
      collection temp(m_map.begin(), m_map.end());
192
197k
      m_map.swap(temp);
193
197k
    }
194
570k
  }
lldb_private::UniqueCStringMap<DIERef>::SizeToFit()
Line
Count
Source
189
44.0k
  void SizeToFit() {
190
44.0k
    if (m_map.size() < m_map.capacity()) {
191
3.27k
      collection temp(m_map.begin(), m_map.end());
192
3.27k
      m_map.swap(temp);
193
3.27k
    }
194
44.0k
  }
195
196
  iterator begin() { return m_map.begin(); }
197
  iterator end() { return m_map.end(); }
198
51
  const_iterator begin() const { return m_map.begin(); }
lldb_private::UniqueCStringMap<unsigned int>::begin() const
Line
Count
Source
198
7
  const_iterator begin() const { return m_map.begin(); }
lldb_private::UniqueCStringMap<DIERef>::begin() const
Line
Count
Source
198
44
  const_iterator begin() const { return m_map.begin(); }
199
51
  const_iterator end() const { return m_map.end(); }
lldb_private::UniqueCStringMap<unsigned int>::end() const
Line
Count
Source
199
7
  const_iterator end() const { return m_map.end(); }
lldb_private::UniqueCStringMap<DIERef>::end() const
Line
Count
Source
199
44
  const_iterator end() const { return m_map.end(); }
200
201
  // Range-based for loop for all entries of the specified ConstString name.
202
  llvm::iterator_range<const_iterator>
203
314k
  equal_range(ConstString unique_cstr) const {
204
314k
    return llvm::make_range(
205
314k
        std::equal_range(m_map.begin(), m_map.end(), unique_cstr, Compare()));
206
314k
  };
207
208
protected:
209
  struct Compare {
210
    bool operator()(const Entry &lhs, const Entry &rhs) {
211
      return operator()(lhs.cstring, rhs.cstring);
212
    }
213
214
52.5M
    bool operator()(const Entry &lhs, ConstString rhs) {
215
52.5M
      return operator()(lhs.cstring, rhs);
216
52.5M
    }
lldb_private::UniqueCStringMap<unsigned int>::Compare::operator()(lldb_private::UniqueCStringMap<unsigned int>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
51.2M
    bool operator()(const Entry &lhs, ConstString rhs) {
215
51.2M
      return operator()(lhs.cstring, rhs);
216
51.2M
    }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Compare::operator()(lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
8.09k
    bool operator()(const Entry &lhs, ConstString rhs) {
215
8.09k
      return operator()(lhs.cstring, rhs);
216
8.09k
    }
lldb_private::UniqueCStringMap<unsigned long>::Compare::operator()(lldb_private::UniqueCStringMap<unsigned long>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
1.17M
    bool operator()(const Entry &lhs, ConstString rhs) {
215
1.17M
      return operator()(lhs.cstring, rhs);
216
1.17M
    }
lldb_private::UniqueCStringMap<lldb::BasicType>::Compare::operator()(lldb_private::UniqueCStringMap<lldb::BasicType>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
193
    bool operator()(const Entry &lhs, ConstString rhs) {
215
193
      return operator()(lhs.cstring, rhs);
216
193
    }
lldb_private::UniqueCStringMap<DWARFDIE>::Compare::operator()(lldb_private::UniqueCStringMap<DWARFDIE>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
6
    bool operator()(const Entry &lhs, ConstString rhs) {
215
6
      return operator()(lhs.cstring, rhs);
216
6
    }
lldb_private::UniqueCStringMap<DIERef>::Compare::operator()(lldb_private::UniqueCStringMap<DIERef>::Entry const&, lldb_private::ConstString)
Line
Count
Source
214
191k
    bool operator()(const Entry &lhs, ConstString rhs) {
215
191k
      return operator()(lhs.cstring, rhs);
216
191k
    }
217
218
26.1M
    bool operator()(ConstString lhs, const Entry &rhs) {
219
26.1M
      return operator()(lhs, rhs.cstring);
220
26.1M
    }
lldb_private::UniqueCStringMap<unsigned int>::Compare::operator()(lldb_private::ConstString, lldb_private::UniqueCStringMap<unsigned int>::Entry const&)
Line
Count
Source
218
26.0M
    bool operator()(ConstString lhs, const Entry &rhs) {
219
26.0M
      return operator()(lhs, rhs.cstring);
220
26.0M
    }
lldb_private::UniqueCStringMap<DIERef>::Compare::operator()(lldb_private::ConstString, lldb_private::UniqueCStringMap<DIERef>::Entry const&)
Line
Count
Source
218
98.6k
    bool operator()(ConstString lhs, const Entry &rhs) {
219
98.6k
      return operator()(lhs, rhs.cstring);
220
98.6k
    }
221
222
78.7M
    bool operator()(ConstString lhs, ConstString rhs) {
223
78.7M
      return ThreeWay(lhs, rhs) < 0;
224
78.7M
    }
lldb_private::UniqueCStringMap<unsigned int>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
77.2M
    bool operator()(ConstString lhs, ConstString rhs) {
223
77.2M
      return ThreeWay(lhs, rhs) < 0;
224
77.2M
    }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
8.09k
    bool operator()(ConstString lhs, ConstString rhs) {
223
8.09k
      return ThreeWay(lhs, rhs) < 0;
224
8.09k
    }
lldb_private::UniqueCStringMap<unsigned long>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
1.17M
    bool operator()(ConstString lhs, ConstString rhs) {
223
1.17M
      return ThreeWay(lhs, rhs) < 0;
224
1.17M
    }
lldb_private::UniqueCStringMap<lldb::BasicType>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
193
    bool operator()(ConstString lhs, ConstString rhs) {
223
193
      return ThreeWay(lhs, rhs) < 0;
224
193
    }
lldb_private::UniqueCStringMap<DWARFDIE>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
6
    bool operator()(ConstString lhs, ConstString rhs) {
223
6
      return ThreeWay(lhs, rhs) < 0;
224
6
    }
lldb_private::UniqueCStringMap<DIERef>::Compare::operator()(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
222
290k
    bool operator()(ConstString lhs, ConstString rhs) {
223
290k
      return ThreeWay(lhs, rhs) < 0;
224
290k
    }
225
226
    // This is only for uniqueness, not lexicographical ordering, so we can
227
    // just compare pointers. *However*, comparing pointers from different
228
    // allocations is UB, so we need compare their integral values instead.
229
3.07G
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
3.07G
      auto lhsint = uintptr_t(lhs.GetCString());
231
3.07G
      auto rhsint = uintptr_t(rhs.GetCString());
232
3.07G
      if (lhsint < rhsint)
233
1.91G
        return -1;
234
1.15G
      if (lhsint > rhsint)
235
1.10G
        return 1;
236
52.4M
      return 0;
237
1.15G
    }
lldb_private::UniqueCStringMap<unsigned int>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
3.06G
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
3.06G
      auto lhsint = uintptr_t(lhs.GetCString());
231
3.06G
      auto rhsint = uintptr_t(rhs.GetCString());
232
3.06G
      if (lhsint < rhsint)
233
1.91G
        return -1;
234
1.15G
      if (lhsint > rhsint)
235
1.10G
        return 1;
236
52.0M
      return 0;
237
1.15G
    }
lldb_private::UniqueCStringMap<lldb_private::OptionValueEnumeration::EnumeratorInfo>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
210k
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
210k
      auto lhsint = uintptr_t(lhs.GetCString());
231
210k
      auto rhsint = uintptr_t(rhs.GetCString());
232
210k
      if (lhsint < rhsint)
233
98.9k
        return -1;
234
111k
      if (lhsint > rhsint)
235
107k
        return 1;
236
4.04k
      return 0;
237
111k
    }
lldb_private::UniqueCStringMap<unsigned long>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
10.5M
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
10.5M
      auto lhsint = uintptr_t(lhs.GetCString());
231
10.5M
      auto rhsint = uintptr_t(rhs.GetCString());
232
10.5M
      if (lhsint < rhsint)
233
5.10M
        return -1;
234
5.45M
      if (lhsint > rhsint)
235
5.11M
        return 1;
236
342k
      return 0;
237
5.45M
    }
lldb_private::UniqueCStringMap<lldb::BasicType>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
651
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
651
      auto lhsint = uintptr_t(lhs.GetCString());
231
651
      auto rhsint = uintptr_t(rhs.GetCString());
232
651
      if (lhsint < rhsint)
233
397
        return -1;
234
254
      if (lhsint > rhsint)
235
216
        return 1;
236
38
      return 0;
237
254
    }
lldb_private::UniqueCStringMap<DWARFDIE>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
6
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
6
      auto lhsint = uintptr_t(lhs.GetCString());
231
6
      auto rhsint = uintptr_t(rhs.GetCString());
232
6
      if (lhsint < rhsint)
233
0
        return -1;
234
6
      if (lhsint > rhsint)
235
6
        return 1;
236
0
      return 0;
237
6
    }
lldb_private::UniqueCStringMap<DIERef>::Compare::ThreeWay(lldb_private::ConstString, lldb_private::ConstString)
Line
Count
Source
229
459k
    int ThreeWay(ConstString lhs, ConstString rhs) {
230
459k
      auto lhsint = uintptr_t(lhs.GetCString());
231
459k
      auto rhsint = uintptr_t(rhs.GetCString());
232
459k
      if (lhsint < rhsint)
233
332k
        return -1;
234
127k
      if (lhsint > rhsint)
235
126k
        return 1;
236
861
      return 0;
237
127k
    }
238
  };
239
240
  collection m_map;
241
};
242
243
} // namespace lldb_private
244
245
#endif // LLDB_CORE_UNIQUECSTRINGMAP_H