Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/DataFormatters/FormattersContainer.h
Line
Count
Source (jump to first uncovered line)
1
//===-- FormattersContainer.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_DATAFORMATTERS_FORMATTERSCONTAINER_H
10
#define LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
11
12
#include <functional>
13
#include <map>
14
#include <memory>
15
#include <mutex>
16
#include <string>
17
18
#include "lldb/lldb-public.h"
19
20
#include "lldb/Core/ValueObject.h"
21
#include "lldb/DataFormatters/FormatClasses.h"
22
#include "lldb/DataFormatters/TypeFormat.h"
23
#include "lldb/DataFormatters/TypeSummary.h"
24
#include "lldb/DataFormatters/TypeSynthetic.h"
25
#include "lldb/Symbol/CompilerType.h"
26
#include "lldb/Utility/RegularExpression.h"
27
#include "lldb/Utility/StringLexer.h"
28
29
namespace lldb_private {
30
31
class IFormatChangeListener {
32
public:
33
662
  virtual ~IFormatChangeListener() = default;
34
35
  virtual void Changed() = 0;
36
37
  virtual uint32_t GetCurrentRevision() = 0;
38
};
39
40
/// Class for matching type names.
41
class TypeMatcher {
42
  RegularExpression m_type_name_regex;
43
  ConstString m_type_name;
44
  /// False if m_type_name_regex should be used for matching. False if this is
45
  /// just matching by comparing with m_type_name string.
46
  bool m_is_regex;
47
48
  // if the user tries to add formatters for, say, "struct Foo" those will not
49
  // match any type because of the way we strip qualifiers from typenames this
50
  // method looks for the case where the user is adding a
51
  // "class","struct","enum" or "union" Foo and strips the unnecessary qualifier
52
14.6M
  static ConstString StripTypeName(ConstString type) {
53
14.6M
    if (type.IsEmpty())
54
12
      return type;
55
56
14.6M
    std::string type_cstr(type.AsCString());
57
14.6M
    StringLexer type_lexer(type_cstr);
58
59
14.6M
    type_lexer.AdvanceIf("class ");
60
14.6M
    type_lexer.AdvanceIf("enum ");
61
14.6M
    type_lexer.AdvanceIf("struct ");
62
14.6M
    type_lexer.AdvanceIf("union ");
63
64
14.6M
    while (type_lexer.NextIf({' ', '\t', '\v', '\f'}).first)
65
65
      ;
66
67
14.6M
    return ConstString(type_lexer.GetUnlexed());
68
14.6M
  }
69
70
public:
71
  TypeMatcher() = delete;
72
  /// Creates a matcher that accepts any type with exactly the given type name.
73
  TypeMatcher(ConstString type_name)
74
129k
      : m_type_name(type_name), m_is_regex(false) {}
75
  /// Creates a matcher that accepts any type matching the given regex.
76
  TypeMatcher(RegularExpression regex)
77
57.1k
      : m_type_name_regex(std::move(regex)), m_is_regex(true) {}
78
79
  /// True iff this matches the given type name.
80
2.92M
  bool Matches(ConstString type_name) const {
81
2.92M
    if (m_is_regex)
82
911k
      return m_type_name_regex.Execute(type_name.GetStringRef());
83
2.01M
    return m_type_name == type_name ||
84
2.01M
           
StripTypeName(m_type_name) == StripTypeName(type_name)2.01M
;
85
2.92M
  }
86
87
  /// Returns the underlying match string for this TypeMatcher.
88
13.1M
  ConstString GetMatchString() const {
89
13.1M
    if (m_is_regex)
90
2.48M
      return ConstString(m_type_name_regex.GetText());
91
10.6M
    return StripTypeName(m_type_name);
92
13.1M
  }
93
94
  /// Returns true if this TypeMatcher and the given one were most created by
95
  /// the same match string.
96
  /// The main purpose of this function is to find existing TypeMatcher
97
  /// instances by the user input that created them. This is necessary as LLDB
98
  /// allows referencing existing TypeMatchers in commands by the user input
99
  /// that originally created them:
100
  /// (lldb) type summary add --summary-string \"A\" -x TypeName
101
  /// (lldb) type summary delete TypeName
102
6.57M
  bool CreatedBySameMatchString(TypeMatcher other) const {
103
6.57M
    return GetMatchString() == other.GetMatchString();
104
6.57M
  }
105
};
106
107
template <typename ValueType> class FormattersContainer {
108
public:
109
  typedef typename std::shared_ptr<ValueType> ValueSP;
110
  typedef std::vector<std::pair<TypeMatcher, ValueSP>> MapType;
111
  typedef std::function<bool(const TypeMatcher &, const ValueSP &)>
112
      ForEachCallback;
113
  typedef typename std::shared_ptr<FormattersContainer<ValueType>>
114
      SharedPointer;
115
116
  friend class TypeCategoryImpl;
117
118
27.0k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
118
7.25k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
118
6.59k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
118
6.59k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
118
6.59k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
119
120
184k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
121
184k
    if (listener)
122
184k
      entry->GetRevision() = listener->GetCurrentRevision();
123
0
    else
124
0
      entry->GetRevision() = 0;
125
126
184k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
127
184k
    Delete(matcher);
128
184k
    m_map.emplace_back(std::move(matcher), std::move(entry));
129
184k
    if (listener)
130
184k
      listener->Changed();
131
184k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeSummaryImpl> const&)
Line
Count
Source
120
137k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
121
137k
    if (listener)
122
137k
      entry->GetRevision() = listener->GetCurrentRevision();
123
0
    else
124
0
      entry->GetRevision() = 0;
125
126
137k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
127
137k
    Delete(matcher);
128
137k
    m_map.emplace_back(std::move(matcher), std::move(entry));
129
137k
    if (listener)
130
137k
      listener->Changed();
131
137k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFormatImpl> const&)
Line
Count
Source
120
700
  void Add(TypeMatcher matcher, const ValueSP &entry) {
121
700
    if (listener)
122
700
      entry->GetRevision() = listener->GetCurrentRevision();
123
0
    else
124
0
      entry->GetRevision() = 0;
125
126
700
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
127
700
    Delete(matcher);
128
700
    m_map.emplace_back(std::move(matcher), std::move(entry));
129
700
    if (listener)
130
700
      listener->Changed();
131
700
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFilterImpl> const&)
Line
Count
Source
120
40
  void Add(TypeMatcher matcher, const ValueSP &entry) {
121
40
    if (listener)
122
40
      entry->GetRevision() = listener->GetCurrentRevision();
123
0
    else
124
0
      entry->GetRevision() = 0;
125
126
40
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
127
40
    Delete(matcher);
128
40
    m_map.emplace_back(std::move(matcher), std::move(entry));
129
40
    if (listener)
130
40
      listener->Changed();
131
40
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::SyntheticChildren> const&)
Line
Count
Source
120
46.4k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
121
46.4k
    if (listener)
122
46.4k
      entry->GetRevision() = listener->GetCurrentRevision();
123
0
    else
124
0
      entry->GetRevision() = 0;
125
126
46.4k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
127
46.4k
    Delete(matcher);
128
46.4k
    m_map.emplace_back(std::move(matcher), std::move(entry));
129
46.4k
    if (listener)
130
46.4k
      listener->Changed();
131
46.4k
  }
132
133
185k
  bool Delete(TypeMatcher matcher) {
134
185k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135
6.74M
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter6.55M
)
136
6.56M
      if (iter->first.CreatedBySameMatchString(matcher)) {
137
2.26k
        m_map.erase(iter);
138
2.26k
        if (listener)
139
2.26k
          listener->Changed();
140
2.26k
        return true;
141
2.26k
      }
142
182k
    return false;
143
185k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
133
137k
  bool Delete(TypeMatcher matcher) {
134
137k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135
5.87M
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter5.73M
)
136
5.73M
      if (iter->first.CreatedBySameMatchString(matcher)) {
137
2.20k
        m_map.erase(iter);
138
2.20k
        if (listener)
139
2.20k
          listener->Changed();
140
2.20k
        return true;
141
2.20k
      }
142
135k
    return false;
143
137k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
133
739
  bool Delete(TypeMatcher matcher) {
134
739
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135
783
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter44
)
136
59
      if (iter->first.CreatedBySameMatchString(matcher)) {
137
15
        m_map.erase(iter);
138
15
        if (listener)
139
15
          listener->Changed();
140
15
        return true;
141
15
      }
142
724
    return false;
143
739
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
133
56
  bool Delete(TypeMatcher matcher) {
134
56
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135
77
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter21
)
136
45
      if (iter->first.CreatedBySameMatchString(matcher)) {
137
24
        m_map.erase(iter);
138
24
        if (listener)
139
24
          listener->Changed();
140
24
        return true;
141
24
      }
142
32
    return false;
143
56
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
133
46.4k
  bool Delete(TypeMatcher matcher) {
134
46.4k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135
871k
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter824k
)
136
824k
      if (iter->first.CreatedBySameMatchString(matcher)) {
137
15
        m_map.erase(iter);
138
15
        if (listener)
139
15
          listener->Changed();
140
15
        return true;
141
15
      }
142
46.4k
    return false;
143
46.4k
  }
144
145
509k
  bool Get(ConstString type, ValueSP &entry) {
146
509k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
147
2.92M
    for (auto &formatter : llvm::reverse(m_map)) {
148
2.92M
      if (formatter.first.Matches(type)) {
149
2.90k
        entry = formatter.second;
150
2.90k
        return true;
151
2.90k
      }
152
2.92M
    }
153
506k
    return false;
154
509k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Get(lldb_private::ConstString, std::__1::shared_ptr<lldb_private::TypeFormatImpl>&)
Line
Count
Source
145
126k
  bool Get(ConstString type, ValueSP &entry) {
146
126k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
147
126k
    for (auto &formatter : llvm::reverse(m_map)) {
148
14.9k
      if (formatter.first.Matches(type)) {
149
83
        entry = formatter.second;
150
83
        return true;
151
83
      }
152
14.9k
    }
153
126k
    return false;
154
126k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Get(lldb_private::ConstString, std::__1::shared_ptr<lldb_private::TypeSummaryImpl>&)
Line
Count
Source
145
116k
  bool Get(ConstString type, ValueSP &entry) {
146
116k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
147
2.05M
    for (auto &formatter : llvm::reverse(m_map)) {
148
2.05M
      if (formatter.first.Matches(type)) {
149
2.17k
        entry = formatter.second;
150
2.17k
        return true;
151
2.17k
      }
152
2.05M
    }
153
114k
    return false;
154
116k
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Get(lldb_private::ConstString, std::__1::shared_ptr<lldb_private::TypeFilterImpl>&)
Line
Count
Source
145
134k
  bool Get(ConstString type, ValueSP &entry) {
146
134k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
147
134k
    for (auto &formatter : llvm::reverse(m_map)) {
148
457
      if (formatter.first.Matches(type)) {
149
87
        entry = formatter.second;
150
87
        return true;
151
87
      }
152
457
    }
153
134k
    return false;
154
134k
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Get(lldb_private::ConstString, std::__1::shared_ptr<lldb_private::SyntheticChildren>&)
Line
Count
Source
145
131k
  bool Get(ConstString type, ValueSP &entry) {
146
131k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
147
856k
    for (auto &formatter : llvm::reverse(m_map)) {
148
856k
      if (formatter.first.Matches(type)) {
149
564
        entry = formatter.second;
150
564
        return true;
151
564
      }
152
856k
    }
153
131k
    return false;
154
131k
  }
155
156
270
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
157
270
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
158
270
    for (const auto &pos : m_map)
159
7.26k
      if (pos.first.CreatedBySameMatchString(matcher)) {
160
37
        entry = pos.second;
161
37
        return true;
162
37
      }
163
233
    return false;
164
270
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFormatImpl>&)
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeSummaryImpl>&)
Line
Count
Source
156
264
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
157
264
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
158
264
    for (const auto &pos : m_map)
159
7.26k
      if (pos.first.CreatedBySameMatchString(matcher)) {
160
36
        entry = pos.second;
161
36
        return true;
162
36
      }
163
228
    return false;
164
264
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFilterImpl>&)
Line
Count
Source
156
6
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
157
6
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
158
6
    for (const auto &pos : m_map)
159
2
      if (pos.first.CreatedBySameMatchString(matcher)) {
160
1
        entry = pos.second;
161
1
        return true;
162
1
      }
163
5
    return false;
164
6
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::SyntheticChildren>&)
165
166
0
  ValueSP GetAtIndex(size_t index) {
167
0
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
168
0
    if (index >= m_map.size())
169
0
      return ValueSP();
170
0
    return m_map[index].second;
171
0
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::GetAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetAtIndex(unsigned long)
172
173
0
  lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierAtIndex(size_t index) {
174
0
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
175
0
    if (index >= m_map.size())
176
0
      return lldb::TypeNameSpecifierImplSP();
177
0
    TypeMatcher type_matcher = m_map[index].first;
178
0
    return std::make_shared<TypeNameSpecifierImpl>(
179
0
        type_matcher.GetMatchString().GetStringRef(), true);
180
0
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::GetTypeNameSpecifierAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetTypeNameSpecifierAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetTypeNameSpecifierAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetTypeNameSpecifierAtIndex(unsigned long)
181
182
1.55k
  void Clear() {
183
1.55k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
184
1.55k
    m_map.clear();
185
1.55k
    if (listener)
186
1.55k
      listener->Changed();
187
1.55k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Clear()
Line
Count
Source
182
382
  void Clear() {
183
382
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
184
382
    m_map.clear();
185
382
    if (listener)
186
382
      listener->Changed();
187
382
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Clear()
Line
Count
Source
182
717
  void Clear() {
183
717
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
184
717
    m_map.clear();
185
717
    if (listener)
186
717
      listener->Changed();
187
717
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Clear()
Line
Count
Source
182
126
  void Clear() {
183
126
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
184
126
    m_map.clear();
185
126
    if (listener)
186
126
      listener->Changed();
187
126
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Clear()
Line
Count
Source
182
326
  void Clear() {
183
326
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
184
326
    m_map.clear();
185
326
    if (listener)
186
326
      listener->Changed();
187
326
  }
188
189
2.32k
  void ForEach(ForEachCallback callback) {
190
2.32k
    if (callback) {
191
643
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
192
7.88k
      for (const auto &pos : m_map) {
193
7.88k
        const TypeMatcher &type = pos.first;
194
7.88k
        if (!callback(type, pos.second))
195
0
          break;
196
7.88k
      }
197
643
    }
198
2.32k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::ForEach(std::__1::function<bool (lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeSummaryImpl> const&)>)
Line
Count
Source
189
583
  void ForEach(ForEachCallback callback) {
190
583
    if (callback) {
191
367
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
192
7.01k
      for (const auto &pos : m_map) {
193
7.01k
        const TypeMatcher &type = pos.first;
194
7.01k
        if (!callback(type, pos.second))
195
0
          break;
196
7.01k
      }
197
367
    }
198
583
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::ForEach(std::__1::function<bool (lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFormatImpl> const&)>)
Line
Count
Source
189
580
  void ForEach(ForEachCallback callback) {
190
580
    if (callback) {
191
86
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
192
86
      for (const auto &pos : m_map) {
193
41
        const TypeMatcher &type = pos.first;
194
41
        if (!callback(type, pos.second))
195
0
          break;
196
41
      }
197
86
    }
198
580
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::ForEach(std::__1::function<bool (lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFilterImpl> const&)>)
Line
Count
Source
189
580
  void ForEach(ForEachCallback callback) {
190
580
    if (callback) {
191
80
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
192
80
      for (const auto &pos : m_map) {
193
6
        const TypeMatcher &type = pos.first;
194
6
        if (!callback(type, pos.second))
195
0
          break;
196
6
      }
197
80
    }
198
580
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::ForEach(std::__1::function<bool (lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::SyntheticChildren> const&)>)
Line
Count
Source
189
580
  void ForEach(ForEachCallback callback) {
190
580
    if (callback) {
191
110
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
192
815
      for (const auto &pos : m_map) {
193
815
        const TypeMatcher &type = pos.first;
194
815
        if (!callback(type, pos.second))
195
0
          break;
196
815
      }
197
110
    }
198
580
  }
199
200
399
  uint32_t GetCount() {
201
399
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
202
399
    return m_map.size();
203
399
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetCount()
Line
Count
Source
200
90
  uint32_t GetCount() {
201
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
202
90
    return m_map.size();
203
90
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::GetCount()
Line
Count
Source
200
129
  uint32_t GetCount() {
201
129
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
202
129
    return m_map.size();
203
129
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetCount()
Line
Count
Source
200
90
  uint32_t GetCount() {
201
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
202
90
    return m_map.size();
203
90
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetCount()
Line
Count
Source
200
90
  uint32_t GetCount() {
201
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
202
90
    return m_map.size();
203
90
  }
204
205
80
  void AutoComplete(CompletionRequest &request) {
206
582
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
582
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
582
      return true;
209
582
    });
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::AutoComplete(lldb_private::CompletionRequest&)::'lambda'(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFormatImpl> const&)::operator()(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFormatImpl> const&) const
Line
Count
Source
206
5
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
5
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
5
      return true;
209
5
    });
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::AutoComplete(lldb_private::CompletionRequest&)::'lambda'(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeSummaryImpl> const&)::operator()(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeSummaryImpl> const&) const
Line
Count
Source
206
425
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
425
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
425
      return true;
209
425
    });
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::AutoComplete(lldb_private::CompletionRequest&)::'lambda'(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFilterImpl> const&)::operator()(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::TypeFilterImpl> const&) const
Line
Count
Source
206
3
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
3
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
3
      return true;
209
3
    });
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::AutoComplete(lldb_private::CompletionRequest&)::'lambda'(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::SyntheticChildren> const&)::operator()(lldb_private::TypeMatcher const&, std::__1::shared_ptr<lldb_private::SyntheticChildren> const&) const
Line
Count
Source
206
149
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
149
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
149
      return true;
209
149
    });
210
80
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
205
20
  void AutoComplete(CompletionRequest &request) {
206
20
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
20
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
20
      return true;
209
20
    });
210
20
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
205
20
  void AutoComplete(CompletionRequest &request) {
206
20
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
20
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
20
      return true;
209
20
    });
210
20
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
205
20
  void AutoComplete(CompletionRequest &request) {
206
20
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
20
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
20
      return true;
209
20
    });
210
20
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
205
20
  void AutoComplete(CompletionRequest &request) {
206
20
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
207
20
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
208
20
      return true;
209
20
    });
210
20
  }
211
212
protected:
213
  FormattersContainer(const FormattersContainer &) = delete;
214
  const FormattersContainer &operator=(const FormattersContainer &) = delete;
215
216
274k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
217
509k
    for (const FormattersMatchCandidate &candidate : candidates) {
218
509k
      if (Get(candidate.GetTypeName(), entry)) {
219
2.89k
        if (candidate.IsMatch(entry) == false) {
220
326
          entry.reset();
221
326
          continue;
222
2.57k
        } else {
223
2.57k
          return true;
224
2.57k
        }
225
2.89k
      }
226
509k
    }
227
272k
    return false;
228
274k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Get(std::__1::vector<lldb_private::FormattersMatchCandidate, std::__1::allocator<lldb_private::FormattersMatchCandidate> > const&, std::__1::shared_ptr<lldb_private::TypeFormatImpl>&)
Line
Count
Source
216
73.8k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
217
126k
    for (const FormattersMatchCandidate &candidate : candidates) {
218
126k
      if (Get(candidate.GetTypeName(), entry)) {
219
83
        if (candidate.IsMatch(entry) == false) {
220
9
          entry.reset();
221
9
          continue;
222
74
        } else {
223
74
          return true;
224
74
        }
225
83
      }
226
126k
    }
227
73.8k
    return false;
228
73.8k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Get(std::__1::vector<lldb_private::FormattersMatchCandidate, std::__1::allocator<lldb_private::FormattersMatchCandidate> > const&, std::__1::shared_ptr<lldb_private::TypeSummaryImpl>&)
Line
Count
Source
216
62.3k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
217
116k
    for (const FormattersMatchCandidate &candidate : candidates) {
218
116k
      if (Get(candidate.GetTypeName(), entry)) {
219
2.17k
        if (candidate.IsMatch(entry) == false) {
220
314
          entry.reset();
221
314
          continue;
222
1.85k
        } else {
223
1.85k
          return true;
224
1.85k
        }
225
2.17k
      }
226
116k
    }
227
60.4k
    return false;
228
62.3k
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Get(std::__1::vector<lldb_private::FormattersMatchCandidate, std::__1::allocator<lldb_private::FormattersMatchCandidate> > const&, std::__1::shared_ptr<lldb_private::TypeFilterImpl>&)
Line
Count
Source
216
69.3k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
217
134k
    for (const FormattersMatchCandidate &candidate : candidates) {
218
134k
      if (Get(candidate.GetTypeName(), entry)) {
219
84
        if (candidate.IsMatch(entry) == false) {
220
3
          entry.reset();
221
3
          continue;
222
81
        } else {
223
81
          return true;
224
81
        }
225
84
      }
226
134k
    }
227
69.2k
    return false;
228
69.3k
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Get(std::__1::vector<lldb_private::FormattersMatchCandidate, std::__1::allocator<lldb_private::FormattersMatchCandidate> > const&, std::__1::shared_ptr<lldb_private::SyntheticChildren>&)
Line
Count
Source
216
69.0k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
217
131k
    for (const FormattersMatchCandidate &candidate : candidates) {
218
131k
      if (Get(candidate.GetTypeName(), entry)) {
219
561
        if (candidate.IsMatch(entry) == false) {
220
0
          entry.reset();
221
0
          continue;
222
561
        } else {
223
561
          return true;
224
561
        }
225
561
      }
226
131k
    }
227
68.5k
    return false;
228
69.0k
  }
229
230
  MapType m_map;
231
  std::recursive_mutex m_map_mutex;
232
  IFormatChangeListener *listener;
233
};
234
235
} // namespace lldb_private
236
237
#endif // LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H