Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/DataFormatters/FormatCache.h
Line
Count
Source (jump to first uncovered line)
1
//===-- FormatCache.h ---------------------------------------------*- C++
2
//-*-===//
3
//
4
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5
// See https://llvm.org/LICENSE.txt for license information.
6
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLDB_DATAFORMATTERS_FORMATCACHE_H
11
#define LLDB_DATAFORMATTERS_FORMATCACHE_H
12
13
#include <map>
14
#include <mutex>
15
16
#include "lldb/Utility/ConstString.h"
17
#include "lldb/lldb-public.h"
18
19
namespace lldb_private {
20
class FormatCache {
21
private:
22
  struct Entry {
23
  private:
24
    bool m_format_cached : 1;
25
    bool m_summary_cached : 1;
26
    bool m_synthetic_cached : 1;
27
28
    lldb::TypeFormatImplSP m_format_sp;
29
    lldb::TypeSummaryImplSP m_summary_sp;
30
    lldb::SyntheticChildrenSP m_synthetic_sp;
31
32
  public:
33
    Entry();
34
35
    template<typename ImplSP> bool IsCached();
36
    bool IsFormatCached();
37
    bool IsSummaryCached();
38
    bool IsSyntheticCached();
39
40
    void Get(lldb::TypeFormatImplSP &);
41
    void Get(lldb::TypeSummaryImplSP &);
42
    void Get(lldb::SyntheticChildrenSP &);
43
44
    void Set(lldb::TypeFormatImplSP);
45
    void Set(lldb::TypeSummaryImplSP);
46
    void Set(lldb::SyntheticChildrenSP);
47
  };
48
  typedef std::map<ConstString, Entry> CacheMap;
49
  CacheMap m_map;
50
  std::recursive_mutex m_mutex;
51
52
  uint64_t m_cache_hits = 0;
53
  uint64_t m_cache_misses = 0;
54
55
  Entry &GetEntry(ConstString type);
56
57
public:
58
1.93k
  FormatCache() = default;
59
60
  template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
61
  void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
62
  void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
63
  void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp);
64
65
  void Clear();
66
67
0
  uint64_t GetCacheHits() { return m_cache_hits; }
68
69
0
  uint64_t GetCacheMisses() { return m_cache_misses; }
70
};
71
72
} // namespace lldb_private
73
74
#endif // LLDB_DATAFORMATTERS_FORMATCACHE_H