Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/OptionValueSInt64.h
Line
Count
Source (jump to first uncovered line)
1
//===-- OptionValueSInt64.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_INTERPRETER_OPTIONVALUESINT64_H
11
#define LLDB_INTERPRETER_OPTIONVALUESINT64_H
12
13
#include "lldb/Interpreter/OptionValue.h"
14
15
namespace lldb_private {
16
17
class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
18
public:
19
0
  OptionValueSInt64() = default;
20
21
  OptionValueSInt64(int64_t value)
22
17.8k
      : m_current_value(value), m_default_value(value) {}
23
24
  OptionValueSInt64(int64_t current_value, int64_t default_value)
25
0
      : m_current_value(current_value), m_default_value(default_value) {}
26
27
26.8k
  OptionValueSInt64(const OptionValueSInt64 &rhs) = default;
28
29
32.4k
  ~OptionValueSInt64() override = default;
30
31
  // Virtual subclass pure virtual overrides
32
33
19.5k
  OptionValue::Type GetType() const override { return eTypeSInt64; }
34
35
  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
36
                 uint32_t dump_mask) override;
37
38
4
  llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
39
4
    return m_current_value;
40
4
  }
41
42
  Status
43
  SetValueFromString(llvm::StringRef value,
44
                     VarSetOperationType op = eVarSetOperationAssign) override;
45
46
12.6k
  void Clear() override {
47
12.6k
    m_current_value = m_default_value;
48
12.6k
    m_value_was_set = false;
49
12.6k
  }
50
51
  // Subclass specific functions
52
53
0
  const int64_t &operator=(int64_t value) {
54
0
    m_current_value = value;
55
0
    return m_current_value;
56
0
  }
57
58
9.73k
  int64_t GetCurrentValue() const { return m_current_value; }
59
60
0
  int64_t GetDefaultValue() const { return m_default_value; }
61
62
0
  bool SetCurrentValue(int64_t value) {
63
0
    if (value >= m_min_value && value <= m_max_value) {
64
0
      m_current_value = value;
65
0
      return true;
66
0
    }
67
0
    return false;
68
0
  }
69
70
0
  bool SetDefaultValue(int64_t value) {
71
0
    if (value >= m_min_value && value <= m_max_value) {
72
0
      m_default_value = value;
73
0
      return true;
74
0
    }
75
0
    return false;
76
0
  }
77
78
6.09k
  void SetMinimumValue(int64_t v) { m_min_value = v; }
79
80
0
  int64_t GetMinimumValue() const { return m_min_value; }
81
82
6.09k
  void SetMaximumValue(int64_t v) { m_max_value = v; }
83
84
0
  int64_t GetMaximumValue() const { return m_max_value; }
85
86
protected:
87
  int64_t m_current_value = 0;
88
  int64_t m_default_value = 0;
89
  int64_t m_min_value = INT64_MIN;
90
  int64_t m_max_value = INT64_MAX;
91
};
92
93
} // namespace lldb_private
94
95
#endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H