Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmMessenger.h
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <iosfwd>
8
#include <memory>
9
#include <string>
10
#include <vector>
11
12
#include <cm/optional>
13
14
#include "cmDiagnosticContext.h"
15
#include "cmDiagnostics.h"
16
#include "cmListFileCache.h"
17
#include "cmMessageType.h" // IWYU pragma: keep
18
19
class cmStateSnapshot;
20
21
#ifdef CMake_ENABLE_DEBUGGER
22
namespace cmDebugger {
23
class cmDebuggerAdapter;
24
}
25
#endif
26
27
class cmMessenger
28
{
29
public:
30
  enum class SuppressionHint
31
  {
32
    Show,
33
    Hide,
34
  };
35
36
  void IssueMessage(
37
    MessageType type, std::string const& text,
38
    cmListFileBacktrace const& backtrace = cmListFileBacktrace());
39
40
  void IssueDiagnostic(cmDiagnosticCategory category, std::string const& text,
41
                       cmStateSnapshot const& fallbackContext,
42
                       cmDiagnosticContext const& context = {});
43
44
  void DisplayMessage(MessageType type, cmDiagnosticCategory category,
45
                      std::string const& text,
46
                      cmListFileBacktrace const& backtrace);
47
48
  void SetTopSource(cm::optional<std::string> topSource);
49
50
  // Whether author diagnostics end with a note on how to suppress them.
51
  void SetSuppressionHint(SuppressionHint hint)
52
0
  {
53
0
    this->SuppressionHintMode = hint;
54
0
  }
55
56
  // Print the top of a backtrace.
57
  void PrintBacktraceTitle(std::ostream& out,
58
                           cmListFileBacktrace const& bt) const;
59
#ifdef CMake_ENABLE_DEBUGGER
60
  void SetDebuggerAdapter(
61
    std::shared_ptr<cmDebugger::cmDebuggerAdapter> const& debuggerAdapter)
62
0
  {
63
0
    DebuggerAdapter = debuggerAdapter;
64
0
  }
65
#endif
66
67
  struct Message
68
  {
69
    MessageType Type;
70
    cmDiagnosticCategory Category;
71
    cmListFileBacktrace Backtrace;
72
    std::string Text;
73
  };
74
75
  std::vector<Message> const& GetDisplayedMessages() const
76
0
  {
77
0
    return this->DisplayedMessages;
78
0
  }
79
80
private:
81
  cm::optional<std::string> TopSource;
82
  SuppressionHint SuppressionHintMode = SuppressionHint::Show;
83
84
  std::vector<Message> DisplayedMessages;
85
86
#ifdef CMake_ENABLE_DEBUGGER
87
  std::shared_ptr<cmDebugger::cmDebuggerAdapter> DebuggerAdapter;
88
#endif
89
};