Coverage Report

Created: 2023-09-21 18:56

/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
733
  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
  /// Type name for exact match, or name of the python callback if m_match_type
43
  /// is `eFormatterMatchCallback`.
44
  ConstString m_name;
45
  RegularExpression m_type_name_regex;
46
  /// Indicates what kind of matching strategy should be used:
47
  /// - eFormatterMatchExact: match the exact type name in m_name.
48
  /// - eFormatterMatchRegex: match using the RegularExpression object
49
  ///   `m_type_name_regex` instead.
50
  /// - eFormatterMatchCallback: run the function in m_name to decide if a type
51
  ///   matches or not.
52
  lldb::FormatterMatchType m_match_type;
53
54
  // if the user tries to add formatters for, say, "struct Foo" those will not
55
  // match any type because of the way we strip qualifiers from typenames this
56
  // method looks for the case where the user is adding a
57
  // "class","struct","enum" or "union" Foo and strips the unnecessary qualifier
58
15.2M
  static ConstString StripTypeName(ConstString type) {
59
15.2M
    if (type.IsEmpty())
60
12
      return type;
61
62
15.2M
    std::string type_cstr(type.AsCString());
63
15.2M
    StringLexer type_lexer(type_cstr);
64
65
15.2M
    type_lexer.AdvanceIf("class ");
66
15.2M
    type_lexer.AdvanceIf("enum ");
67
15.2M
    type_lexer.AdvanceIf("struct ");
68
15.2M
    type_lexer.AdvanceIf("union ");
69
70
15.2M
    while (type_lexer.NextIf({' ', '\t', '\v', '\f'}).first)
71
45
      ;
72
73
15.2M
    return ConstString(type_lexer.GetUnlexed());
74
15.2M
  }
75
76
public:
77
  TypeMatcher() = delete;
78
  /// Creates a matcher that accepts any type with exactly the given type name.
79
  TypeMatcher(ConstString type_name)
80
504
      : m_name(type_name), m_match_type(lldb::eFormatterMatchExact) {}
81
  /// Creates a matcher that accepts any type matching the given regex.
82
  TypeMatcher(RegularExpression regex)
83
      : m_type_name_regex(std::move(regex)),
84
        m_match_type(lldb::eFormatterMatchRegex) {}
85
  /// Creates a matcher using the matching type and string from the given type
86
  /// name specifier.
87
  TypeMatcher(lldb::TypeNameSpecifierImplSP type_specifier)
88
206k
      : m_name(type_specifier->GetName()),
89
206k
        m_match_type(type_specifier->GetMatchType()) {
90
206k
    if (m_match_type == lldb::eFormatterMatchRegex)
91
67.7k
      m_type_name_regex = RegularExpression(type_specifier->GetName());
92
206k
  }
93
94
  /// True iff this matches the given type.
95
2.67M
  bool Matches(FormattersMatchCandidate candidate_type) const {
96
2.67M
    ConstString type_name = candidate_type.GetTypeName();
97
2.67M
    switch (m_match_type) {
98
1.81M
    case lldb::eFormatterMatchExact:
99
1.81M
      return m_name == type_name ||
100
1.81M
             
StripTypeName(m_name) == StripTypeName(type_name)1.80M
;
101
866k
    case lldb::eFormatterMatchRegex:
102
866k
      return m_type_name_regex.Execute(type_name.GetStringRef());
103
44
    case lldb::eFormatterMatchCallback:
104
      // CommandObjectType{Synth,Filter}Add tries to prevent the user from
105
      // creating both a synthetic child provider and a filter for the same type
106
      // in the same category, but we don't have a type object at that point, so
107
      // it creates a dummy candidate without type or script interpreter.
108
      // Skip callback matching in these cases.
109
44
      if (candidate_type.GetScriptInterpreter())
110
44
        return candidate_type.GetScriptInterpreter()->FormatterCallbackFunction(
111
44
            m_name.AsCString(),
112
44
            std::make_shared<TypeImpl>(candidate_type.GetType()));
113
2.67M
    }
114
0
    return false;
115
2.67M
  }
116
117
0
  lldb::FormatterMatchType GetMatchType() const { return m_match_type; }
118
119
  /// Returns the underlying match string for this TypeMatcher.
120
14.7M
  ConstString GetMatchString() const {
121
14.7M
    if (m_match_type == lldb::eFormatterMatchExact)
122
11.5M
        return StripTypeName(m_name);
123
3.19M
    if (m_match_type == lldb::eFormatterMatchRegex)
124
3.19M
        return ConstString(m_type_name_regex.GetText());
125
8
    return m_name;
126
3.19M
  }
127
128
  /// Returns true if this TypeMatcher and the given one were most created by
129
  /// the same match string.
130
  /// The main purpose of this function is to find existing TypeMatcher
131
  /// instances by the user input that created them. This is necessary as LLDB
132
  /// allows referencing existing TypeMatchers in commands by the user input
133
  /// that originally created them:
134
  /// (lldb) type summary add --summary-string \"A\" -x TypeName
135
  /// (lldb) type summary delete TypeName
136
7.39M
  bool CreatedBySameMatchString(TypeMatcher other) const {
137
7.39M
    return GetMatchString() == other.GetMatchString();
138
7.39M
  }
139
};
140
141
template <typename ValueType> class FormattersContainer {
142
public:
143
  typedef typename std::shared_ptr<ValueType> ValueSP;
144
  typedef std::vector<std::pair<TypeMatcher, ValueSP>> MapType;
145
  typedef std::function<bool(const TypeMatcher &, const ValueSP &)>
146
      ForEachCallback;
147
  typedef typename std::shared_ptr<FormattersContainer<ValueType>>
148
      SharedPointer;
149
150
  friend class TypeCategoryImpl;
151
152
44.0k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
152
11.5k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
152
10.8k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
152
10.8k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::FormattersContainer(lldb_private::IFormatChangeListener*)
Line
Count
Source
152
10.8k
  FormattersContainer(IFormatChangeListener *lst) : listener(lst) {}
153
154
206k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
155
206k
    if (listener)
156
206k
      entry->GetRevision() = listener->GetCurrentRevision();
157
0
    else
158
0
      entry->GetRevision() = 0;
159
160
206k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
161
206k
    Delete(matcher);
162
206k
    m_map.emplace_back(std::move(matcher), std::move(entry));
163
206k
    if (listener)
164
206k
      listener->Changed();
165
206k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFormatImpl> const&)
Line
Count
Source
154
760
  void Add(TypeMatcher matcher, const ValueSP &entry) {
155
760
    if (listener)
156
760
      entry->GetRevision() = listener->GetCurrentRevision();
157
0
    else
158
0
      entry->GetRevision() = 0;
159
160
760
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
161
760
    Delete(matcher);
162
760
    m_map.emplace_back(std::move(matcher), std::move(entry));
163
760
    if (listener)
164
760
      listener->Changed();
165
760
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeSummaryImpl> const&)
Line
Count
Source
154
151k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
155
151k
    if (listener)
156
151k
      entry->GetRevision() = listener->GetCurrentRevision();
157
0
    else
158
0
      entry->GetRevision() = 0;
159
160
151k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
161
151k
    Delete(matcher);
162
151k
    m_map.emplace_back(std::move(matcher), std::move(entry));
163
151k
    if (listener)
164
151k
      listener->Changed();
165
151k
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFilterImpl> const&)
Line
Count
Source
154
33
  void Add(TypeMatcher matcher, const ValueSP &entry) {
155
33
    if (listener)
156
33
      entry->GetRevision() = listener->GetCurrentRevision();
157
0
    else
158
0
      entry->GetRevision() = 0;
159
160
33
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
161
33
    Delete(matcher);
162
33
    m_map.emplace_back(std::move(matcher), std::move(entry));
163
33
    if (listener)
164
33
      listener->Changed();
165
33
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Add(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::SyntheticChildren> const&)
Line
Count
Source
154
53.9k
  void Add(TypeMatcher matcher, const ValueSP &entry) {
155
53.9k
    if (listener)
156
53.9k
      entry->GetRevision() = listener->GetCurrentRevision();
157
0
    else
158
0
      entry->GetRevision() = 0;
159
160
53.9k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
161
53.9k
    Delete(matcher);
162
53.9k
    m_map.emplace_back(std::move(matcher), std::move(entry));
163
53.9k
    if (listener)
164
53.9k
      listener->Changed();
165
53.9k
  }
166
167
206k
  bool Delete(TypeMatcher matcher) {
168
206k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
169
7.59M
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter7.38M
)
170
7.38M
      if (iter->first.CreatedBySameMatchString(matcher)) {
171
2.36k
        m_map.erase(iter);
172
2.36k
        if (listener)
173
2.36k
          listener->Changed();
174
2.36k
        return true;
175
2.36k
      }
176
204k
    return false;
177
206k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
167
799
  bool Delete(TypeMatcher matcher) {
168
799
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
169
829
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter30
)
170
41
      if (iter->first.CreatedBySameMatchString(matcher)) {
171
11
        m_map.erase(iter);
172
11
        if (listener)
173
11
          listener->Changed();
174
11
        return true;
175
11
      }
176
788
    return false;
177
799
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
167
151k
  bool Delete(TypeMatcher matcher) {
168
151k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
169
6.50M
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter6.34M
)
170
6.35M
      if (iter->first.CreatedBySameMatchString(matcher)) {
171
2.32k
        m_map.erase(iter);
172
2.32k
        if (listener)
173
2.32k
          listener->Changed();
174
2.32k
        return true;
175
2.32k
      }
176
149k
    return false;
177
151k
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
167
48
  bool Delete(TypeMatcher matcher) {
168
48
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
169
65
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter17
)
170
34
      if (iter->first.CreatedBySameMatchString(matcher)) {
171
17
        m_map.erase(iter);
172
17
        if (listener)
173
17
          listener->Changed();
174
17
        return true;
175
17
      }
176
31
    return false;
177
48
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Delete(lldb_private::TypeMatcher)
Line
Count
Source
167
54.0k
  bool Delete(TypeMatcher matcher) {
168
54.0k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
169
1.08M
    for (auto iter = m_map.begin(); iter != m_map.end(); 
++iter1.03M
)
170
1.03M
      if (iter->first.CreatedBySameMatchString(matcher)) {
171
14
        m_map.erase(iter);
172
14
        if (listener)
173
14
          listener->Changed();
174
14
        return true;
175
14
      }
176
54.0k
    return false;
177
54.0k
  }
178
179
  // Finds the first formatter in the container that matches `candidate`.
180
679k
  bool Get(FormattersMatchCandidate candidate, ValueSP &entry) {
181
679k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
182
2.67M
    for (auto &formatter : llvm::reverse(m_map)) {
183
2.67M
      if (formatter.first.Matches(candidate)) {
184
2.32k
        entry = formatter.second;
185
2.32k
        return true;
186
2.32k
      }
187
2.67M
    }
188
677k
    return false;
189
679k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Get(lldb_private::FormattersMatchCandidate, std::__1::shared_ptr<lldb_private::TypeFormatImpl>&)
Line
Count
Source
180
169k
  bool Get(FormattersMatchCandidate candidate, ValueSP &entry) {
181
169k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
182
169k
    for (auto &formatter : llvm::reverse(m_map)) {
183
12.9k
      if (formatter.first.Matches(candidate)) {
184
57
        entry = formatter.second;
185
57
        return true;
186
57
      }
187
12.9k
    }
188
169k
    return false;
189
169k
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Get(lldb_private::FormattersMatchCandidate, std::__1::shared_ptr<lldb_private::TypeSummaryImpl>&)
Line
Count
Source
180
156k
  bool Get(FormattersMatchCandidate candidate, ValueSP &entry) {
181
156k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
182
1.86M
    for (auto &formatter : llvm::reverse(m_map)) {
183
1.86M
      if (formatter.first.Matches(candidate)) {
184
1.72k
        entry = formatter.second;
185
1.72k
        return true;
186
1.72k
      }
187
1.86M
    }
188
154k
    return false;
189
156k
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Get(lldb_private::FormattersMatchCandidate, std::__1::shared_ptr<lldb_private::TypeFilterImpl>&)
Line
Count
Source
180
178k
  bool Get(FormattersMatchCandidate candidate, ValueSP &entry) {
181
178k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
182
178k
    for (auto &formatter : llvm::reverse(m_map)) {
183
324
      if (formatter.first.Matches(candidate)) {
184
62
        entry = formatter.second;
185
62
        return true;
186
62
      }
187
324
    }
188
178k
    return false;
189
178k
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Get(lldb_private::FormattersMatchCandidate, std::__1::shared_ptr<lldb_private::SyntheticChildren>&)
Line
Count
Source
180
175k
  bool Get(FormattersMatchCandidate candidate, ValueSP &entry) {
181
175k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
182
801k
    for (auto &formatter : llvm::reverse(m_map)) {
183
801k
      if (formatter.first.Matches(candidate)) {
184
482
        entry = formatter.second;
185
482
        return true;
186
482
      }
187
801k
    }
188
174k
    return false;
189
175k
  }
190
191
  // Finds the first match between candidate types in `candidates` and
192
  // formatters in this container.
193
353k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
194
679k
    for (const FormattersMatchCandidate &candidate : candidates) {
195
679k
      if (Get(candidate, entry)) {
196
2.32k
        if (candidate.IsMatch(entry) == false) {
197
278
          entry.reset();
198
278
          continue;
199
2.04k
        } else {
200
2.04k
          return true;
201
2.04k
        }
202
2.32k
      }
203
679k
    }
204
351k
    return false;
205
353k
  }
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
193
96.4k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
194
169k
    for (const FormattersMatchCandidate &candidate : candidates) {
195
169k
      if (Get(candidate, entry)) {
196
57
        if (candidate.IsMatch(entry) == false) {
197
6
          entry.reset();
198
6
          continue;
199
51
        } else {
200
51
          return true;
201
51
        }
202
57
      }
203
169k
    }
204
96.4k
    return false;
205
96.4k
  }
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
193
80.3k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
194
156k
    for (const FormattersMatchCandidate &candidate : candidates) {
195
156k
      if (Get(candidate, entry)) {
196
1.72k
        if (candidate.IsMatch(entry) == false) {
197
270
          entry.reset();
198
270
          continue;
199
1.45k
        } else {
200
1.45k
          return true;
201
1.45k
        }
202
1.72k
      }
203
156k
    }
204
78.8k
    return false;
205
80.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
193
88.8k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
194
178k
    for (const FormattersMatchCandidate &candidate : candidates) {
195
178k
      if (Get(candidate, entry)) {
196
62
        if (candidate.IsMatch(entry) == false) {
197
2
          entry.reset();
198
2
          continue;
199
60
        } else {
200
60
          return true;
201
60
        }
202
62
      }
203
178k
    }
204
88.8k
    return false;
205
88.8k
  }
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
193
88.2k
  bool Get(const FormattersMatchVector &candidates, ValueSP &entry) {
194
175k
    for (const FormattersMatchCandidate &candidate : candidates) {
195
175k
      if (Get(candidate, entry)) {
196
482
        if (candidate.IsMatch(entry) == false) {
197
0
          entry.reset();
198
0
          continue;
199
482
        } else {
200
482
          return true;
201
482
        }
202
482
      }
203
175k
    }
204
87.7k
    return false;
205
88.2k
  }
206
207
182
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
208
182
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
209
182
    for (const auto &pos : m_map)
210
4.84k
      if (pos.first.CreatedBySameMatchString(matcher)) {
211
25
        entry = pos.second;
212
25
        return true;
213
25
      }
214
157
    return false;
215
182
  }
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
207
176
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
208
176
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
209
176
    for (const auto &pos : m_map)
210
4.84k
      if (pos.first.CreatedBySameMatchString(matcher)) {
211
24
        entry = pos.second;
212
24
        return true;
213
24
      }
214
152
    return false;
215
176
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::TypeFilterImpl>&)
Line
Count
Source
207
6
  bool GetExact(TypeMatcher matcher, ValueSP &entry) {
208
6
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
209
6
    for (const auto &pos : m_map)
210
2
      if (pos.first.CreatedBySameMatchString(matcher)) {
211
1
        entry = pos.second;
212
1
        return true;
213
1
      }
214
5
    return false;
215
6
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetExact(lldb_private::TypeMatcher, std::__1::shared_ptr<lldb_private::SyntheticChildren>&)
216
217
0
  ValueSP GetAtIndex(size_t index) {
218
0
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
219
0
    if (index >= m_map.size())
220
0
      return ValueSP();
221
0
    return m_map[index].second;
222
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)
223
224
0
  lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierAtIndex(size_t index) {
225
0
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
226
0
    if (index >= m_map.size())
227
0
      return lldb::TypeNameSpecifierImplSP();
228
0
    TypeMatcher type_matcher = m_map[index].first;
229
0
    return std::make_shared<TypeNameSpecifierImpl>(
230
0
        type_matcher.GetMatchString().GetStringRef(),
231
0
        type_matcher.GetMatchType());
232
0
  }
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetTypeNameSpecifierAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::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)
233
234
1.50k
  void Clear() {
235
1.50k
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
236
1.50k
    m_map.clear();
237
1.50k
    if (listener)
238
1.50k
      listener->Changed();
239
1.50k
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::Clear()
Line
Count
Source
234
390
  void Clear() {
235
390
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
236
390
    m_map.clear();
237
390
    if (listener)
238
390
      listener->Changed();
239
390
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::Clear()
Line
Count
Source
234
648
  void Clear() {
235
648
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
236
648
    m_map.clear();
237
648
    if (listener)
238
648
      listener->Changed();
239
648
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::Clear()
Line
Count
Source
234
129
  void Clear() {
235
129
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
236
129
    m_map.clear();
237
129
    if (listener)
238
129
      listener->Changed();
239
129
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::Clear()
Line
Count
Source
234
333
  void Clear() {
235
333
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
236
333
    m_map.clear();
237
333
    if (listener)
238
333
      listener->Changed();
239
333
  }
240
241
692
  void ForEach(ForEachCallback callback) {
242
692
    if (callback) {
243
692
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
244
5.57k
      for (const auto &pos : m_map) {
245
5.57k
        const TypeMatcher &type = pos.first;
246
5.57k
        if (!callback(type, pos.second))
247
0
          break;
248
5.57k
      }
249
692
    }
250
692
  }
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
241
96
  void ForEach(ForEachCallback callback) {
242
96
    if (callback) {
243
96
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
244
96
      for (const auto &pos : m_map) {
245
29
        const TypeMatcher &type = pos.first;
246
29
        if (!callback(type, pos.second))
247
0
          break;
248
29
      }
249
96
    }
250
96
  }
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
241
386
  void ForEach(ForEachCallback callback) {
242
386
    if (callback) {
243
386
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
244
4.90k
      for (const auto &pos : m_map) {
245
4.90k
        const TypeMatcher &type = pos.first;
246
4.90k
        if (!callback(type, pos.second))
247
0
          break;
248
4.90k
      }
249
386
    }
250
386
  }
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
241
90
  void ForEach(ForEachCallback callback) {
242
90
    if (callback) {
243
90
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
244
90
      for (const auto &pos : m_map) {
245
5
        const TypeMatcher &type = pos.first;
246
5
        if (!callback(type, pos.second))
247
0
          break;
248
5
      }
249
90
    }
250
90
  }
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
241
120
  void ForEach(ForEachCallback callback) {
242
120
    if (callback) {
243
120
      std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
244
633
      for (const auto &pos : m_map) {
245
633
        const TypeMatcher &type = pos.first;
246
633
        if (!callback(type, pos.second))
247
0
          break;
248
633
      }
249
120
    }
250
120
  }
251
252
388
  uint32_t GetCount() {
253
388
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
254
388
    return m_map.size();
255
388
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::GetCount()
Line
Count
Source
252
90
  uint32_t GetCount() {
253
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
254
90
    return m_map.size();
255
90
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::GetCount()
Line
Count
Source
252
118
  uint32_t GetCount() {
253
118
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
254
118
    return m_map.size();
255
118
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::GetCount()
Line
Count
Source
252
90
  uint32_t GetCount() {
253
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
254
90
    return m_map.size();
255
90
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::GetCount()
Line
Count
Source
252
90
  uint32_t GetCount() {
253
90
    std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
254
90
    return m_map.size();
255
90
  }
256
257
120
  void AutoComplete(CompletionRequest &request) {
258
598
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
598
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
598
      return true;
261
598
    });
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
258
5
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
5
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
5
      return true;
261
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
258
431
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
431
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
431
      return true;
261
431
    });
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
258
3
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
3
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
3
      return true;
261
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
258
159
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
159
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
159
      return true;
261
159
    });
262
120
  }
lldb_private::FormattersContainer<lldb_private::TypeFormatImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
257
30
  void AutoComplete(CompletionRequest &request) {
258
30
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
30
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
30
      return true;
261
30
    });
262
30
  }
lldb_private::FormattersContainer<lldb_private::TypeSummaryImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
257
30
  void AutoComplete(CompletionRequest &request) {
258
30
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
30
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
30
      return true;
261
30
    });
262
30
  }
lldb_private::FormattersContainer<lldb_private::TypeFilterImpl>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
257
30
  void AutoComplete(CompletionRequest &request) {
258
30
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
30
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
30
      return true;
261
30
    });
262
30
  }
lldb_private::FormattersContainer<lldb_private::SyntheticChildren>::AutoComplete(lldb_private::CompletionRequest&)
Line
Count
Source
257
30
  void AutoComplete(CompletionRequest &request) {
258
30
    ForEach([&request](const TypeMatcher &matcher, const ValueSP &value) {
259
30
      request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
260
30
      return true;
261
30
    });
262
30
  }
263
264
protected:
265
  FormattersContainer(const FormattersContainer &) = delete;
266
  const FormattersContainer &operator=(const FormattersContainer &) = delete;
267
268
  MapType m_map;
269
  std::recursive_mutex m_map_mutex;
270
  IFormatChangeListener *listener;
271
};
272
273
} // namespace lldb_private
274
275
#endif // LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H