Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Core/ThreadSafeDenseMap.h
Line
Count
Source
1
//===-- ThreadSafeDenseMap.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_CORE_THREADSAFEDENSEMAP_H
11
#define LLDB_CORE_THREADSAFEDENSEMAP_H
12
13
#include <mutex>
14
15
#include "llvm/ADT/DenseMap.h"
16
17
18
namespace lldb_private {
19
20
template <typename _KeyType, typename _ValueType,
21
          typename _MutexType = std::mutex>
22
class ThreadSafeDenseMap {
23
public:
24
  typedef llvm::DenseMap<_KeyType, _ValueType> LLVMMapType;
25
26
  ThreadSafeDenseMap(unsigned map_initial_capacity = 0)
27
3.49k
      : m_map(map_initial_capacity), m_mutex() {}
lldb_private::ThreadSafeDenseMap<clang::ASTContext*, lldb_private::TypeSystemClang*, std::__1::mutex>::ThreadSafeDenseMap(unsigned int)
Line
Count
Source
27
920
      : m_map(map_initial_capacity), m_mutex() {}
lldb_private::ThreadSafeDenseMap<void*, unsigned long long, std::__1::mutex>::ThreadSafeDenseMap(unsigned int)
Line
Count
Source
27
2.57k
      : m_map(map_initial_capacity), m_mutex() {}
28
29
24.5k
  void Insert(_KeyType k, _ValueType v) {
30
24.5k
    std::lock_guard<_MutexType> guard(m_mutex);
31
24.5k
    m_map.insert(std::make_pair(k, v));
32
24.5k
  }
lldb_private::ThreadSafeDenseMap<clang::ASTContext*, lldb_private::TypeSystemClang*, std::__1::mutex>::Insert(clang::ASTContext*, lldb_private::TypeSystemClang*)
Line
Count
Source
29
24.4k
  void Insert(_KeyType k, _ValueType v) {
30
24.4k
    std::lock_guard<_MutexType> guard(m_mutex);
31
24.4k
    m_map.insert(std::make_pair(k, v));
32
24.4k
  }
lldb_private::ThreadSafeDenseMap<void*, unsigned long long, std::__1::mutex>::Insert(void*, unsigned long long)
Line
Count
Source
29
78
  void Insert(_KeyType k, _ValueType v) {
30
78
    std::lock_guard<_MutexType> guard(m_mutex);
31
78
    m_map.insert(std::make_pair(k, v));
32
78
  }
33
34
26.6k
  void Erase(_KeyType k) {
35
26.6k
    std::lock_guard<_MutexType> guard(m_mutex);
36
26.6k
    m_map.erase(k);
37
26.6k
  }
38
39
5.91M
  _ValueType Lookup(_KeyType k) {
40
5.91M
    std::lock_guard<_MutexType> guard(m_mutex);
41
5.91M
    return m_map.lookup(k);
42
5.91M
  }
lldb_private::ThreadSafeDenseMap<clang::ASTContext*, lldb_private::TypeSystemClang*, std::__1::mutex>::Lookup(clang::ASTContext*)
Line
Count
Source
39
5.91M
  _ValueType Lookup(_KeyType k) {
40
5.91M
    std::lock_guard<_MutexType> guard(m_mutex);
41
5.91M
    return m_map.lookup(k);
42
5.91M
  }
lldb_private::ThreadSafeDenseMap<void*, unsigned long long, std::__1::mutex>::Lookup(void*)
Line
Count
Source
39
174
  _ValueType Lookup(_KeyType k) {
40
174
    std::lock_guard<_MutexType> guard(m_mutex);
41
174
    return m_map.lookup(k);
42
174
  }
43
44
  bool Lookup(_KeyType k, _ValueType &v) {
45
    std::lock_guard<_MutexType> guard(m_mutex);
46
    auto iter = m_map.find(k), end = m_map.end();
47
    if (iter == end)
48
      return false;
49
    v = iter->second;
50
    return true;
51
  }
52
53
  void Clear() {
54
    std::lock_guard<_MutexType> guard(m_mutex);
55
    m_map.clear();
56
  }
57
58
protected:
59
  LLVMMapType m_map;
60
  _MutexType m_mutex;
61
};
62
63
} // namespace lldb_private
64
65
#endif // LLDB_CORE_THREADSAFEDENSEMAP_H