Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/OptionValueBoolean.h
Line
Count
Source
1
//===-- OptionValueBoolean.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_INTERPRETER_OPTIONVALUEBOOLEAN_H
10
#define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
11
12
#include "lldb/Interpreter/OptionValue.h"
13
14
namespace lldb_private {
15
16
class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
17
public:
18
  OptionValueBoolean(bool value)
19
332k
      : m_current_value(value), m_default_value(value) {}
20
  OptionValueBoolean(bool current_value, bool default_value)
21
84.2k
      : m_current_value(current_value), m_default_value(default_value) {}
22
23
493k
  ~OptionValueBoolean() override = default;
24
25
  // Virtual subclass pure virtual overrides
26
27
5.64M
  OptionValue::Type GetType() const override { return eTypeBoolean; }
28
29
  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
30
                 uint32_t dump_mask) override;
31
32
  Status
33
  SetValueFromString(llvm::StringRef value,
34
                     VarSetOperationType op = eVarSetOperationAssign) override;
35
36
263k
  void Clear() override {
37
263k
    m_current_value = m_default_value;
38
263k
    m_value_was_set = false;
39
263k
  }
40
41
  void AutoComplete(CommandInterpreter &interpreter,
42
                    CompletionRequest &request) override;
43
44
  // Subclass specific functions
45
46
  /// Convert to bool operator.
47
  ///
48
  /// This allows code to check a OptionValueBoolean in conditions.
49
  ///
50
  /// \code
51
  /// OptionValueBoolean bool_value(...);
52
  /// if (bool_value)
53
  /// { ...
54
  /// \endcode
55
  ///
56
  /// \return
57
  ///     /b True this object contains a valid namespace decl, \b
58
  ///     false otherwise.
59
7.25k
  explicit operator bool() const { return m_current_value; }
60
61
3
  const bool &operator=(bool b) {
62
3
    m_current_value = b;
63
3
    return m_current_value;
64
3
  }
65
66
5.64M
  bool GetCurrentValue() const { return m_current_value; }
67
68
45
  bool GetDefaultValue() const { return m_default_value; }
69
70
6.53k
  void SetCurrentValue(bool value) { m_current_value = value; }
71
72
2
  void SetDefaultValue(bool value) { m_default_value = value; }
73
74
protected:
75
  bool m_current_value;
76
  bool m_default_value;
77
};
78
79
} // namespace lldb_private
80
81
#endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H