Coverage Report

Created: 2023-09-12 09:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Utility/Baton.h
Line
Count
Source (jump to first uncovered line)
1
//===-- Baton.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_UTILITY_BATON_H
10
#define LLDB_UTILITY_BATON_H
11
12
#include "lldb/lldb-enumerations.h"
13
#include "lldb/lldb-public.h"
14
15
#include "llvm/Support/raw_ostream.h"
16
17
#include <memory>
18
19
namespace lldb_private {
20
class Stream;
21
}
22
23
namespace lldb_private {
24
25
/// \class Baton Baton.h "lldb/Core/Baton.h"
26
/// A class designed to wrap callback batons so they can cleanup
27
///        any acquired resources
28
///
29
/// This class is designed to be used by any objects that have a callback
30
/// function that takes a baton where the baton might need to
31
/// free/delete/close itself.
32
///
33
/// The default behavior is to not free anything. Subclasses can free any
34
/// needed resources in their destructors.
35
class Baton {
36
public:
37
4.88k
  Baton() = default;
38
4.83k
  virtual ~Baton() = default;
39
40
  virtual void *data() = 0;
41
42
  virtual void GetDescription(llvm::raw_ostream &s,
43
                              lldb::DescriptionLevel level,
44
                              unsigned indentation) const = 0;
45
};
46
47
class UntypedBaton : public Baton {
48
public:
49
4.82k
  UntypedBaton(void *Data) : m_data(Data) {}
50
4.77k
  ~UntypedBaton() override {
51
    // The default destructor for an untyped baton does NOT attempt to clean up
52
    // anything in m_data.
53
4.77k
  }
54
55
1.98k
  void *data() override { return m_data; }
56
  void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level,
57
                      unsigned indentation) const override;
58
59
  void *m_data; // Leave baton public for easy access
60
};
61
62
template <typename T> class TypedBaton : public Baton {
63
public:
64
60
  explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
lldb_private::TypedBaton<lldb_private::BreakpointOptions::CommandData>::TypedBaton(std::__1::unique_ptr<lldb_private::BreakpointOptions::CommandData, std::__1::default_delete<lldb_private::BreakpointOptions::CommandData> >)
Line
Count
Source
64
52
  explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
lldb_private::TypedBaton<lldb_private::Watchpoint::WatchpointVariableContext>::TypedBaton(std::__1::unique_ptr<lldb_private::Watchpoint::WatchpointVariableContext, std::__1::default_delete<lldb_private::Watchpoint::WatchpointVariableContext> >)
Line
Count
Source
64
2
  explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
lldb_private::TypedBaton<lldb_private::WatchpointOptions::CommandData>::TypedBaton(std::__1::unique_ptr<lldb_private::WatchpointOptions::CommandData, std::__1::default_delete<lldb_private::WatchpointOptions::CommandData> >)
Line
Count
Source
64
4
  explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
lldb_private::TypedBaton<lldb::CallbackData>::TypedBaton(std::__1::unique_ptr<lldb::CallbackData, std::__1::default_delete<lldb::CallbackData> >)
Line
Count
Source
64
2
  explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
65
66
18
  T *getItem() { return Item.get(); }
lldb_private::TypedBaton<lldb_private::BreakpointOptions::CommandData>::getItem()
Line
Count
Source
66
14
  T *getItem() { return Item.get(); }
lldb_private::TypedBaton<lldb::CallbackData>::getItem()
Line
Count
Source
66
4
  T *getItem() { return Item.get(); }
67
35
  const T *getItem() const { return Item.get(); }
lldb_private::TypedBaton<lldb_private::BreakpointOptions::CommandData>::getItem() const
Line
Count
Source
67
25
  const T *getItem() const { return Item.get(); }
lldb_private::TypedBaton<lldb_private::WatchpointOptions::CommandData>::getItem() const
Line
Count
Source
67
10
  const T *getItem() const { return Item.get(); }
68
69
50
  void *data() override { return Item.get(); }
lldb_private::TypedBaton<lldb_private::BreakpointOptions::CommandData>::data()
Line
Count
Source
69
34
  void *data() override { return Item.get(); }
lldb_private::TypedBaton<lldb_private::Watchpoint::WatchpointVariableContext>::data()
Line
Count
Source
69
1
  void *data() override { return Item.get(); }
lldb_private::TypedBaton<lldb_private::WatchpointOptions::CommandData>::data()
Line
Count
Source
69
13
  void *data() override { return Item.get(); }
lldb_private::TypedBaton<lldb::CallbackData>::data()
Line
Count
Source
69
2
  void *data() override { return Item.get(); }
70
  void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level,
71
0
                      unsigned indentation) const override {}
Unexecuted instantiation: lldb_private::TypedBaton<lldb_private::BreakpointOptions::CommandData>::GetDescription(llvm::raw_ostream&, lldb::DescriptionLevel, unsigned int) const
Unexecuted instantiation: lldb_private::TypedBaton<lldb_private::Watchpoint::WatchpointVariableContext>::GetDescription(llvm::raw_ostream&, lldb::DescriptionLevel, unsigned int) const
Unexecuted instantiation: lldb_private::TypedBaton<lldb_private::WatchpointOptions::CommandData>::GetDescription(llvm::raw_ostream&, lldb::DescriptionLevel, unsigned int) const
Unexecuted instantiation: lldb_private::TypedBaton<lldb::CallbackData>::GetDescription(llvm::raw_ostream&, lldb::DescriptionLevel, unsigned int) const
72
73
protected:
74
  std::unique_ptr<T> Item;
75
};
76
77
} // namespace lldb_private
78
79
#endif // LLDB_UTILITY_BATON_H