Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/OptionValueArray.h
Line
Count
Source (jump to first uncovered line)
1
//===-- OptionValueArray.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_OPTIONVALUEARRAY_H
10
#define LLDB_INTERPRETER_OPTIONVALUEARRAY_H
11
12
#include <vector>
13
14
#include "lldb/Interpreter/OptionValue.h"
15
16
namespace lldb_private {
17
18
class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
19
public:
20
  OptionValueArray(uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false)
21
23.0k
      : m_type_mask(type_mask), m_raw_value_dump(raw_value_dump) {}
22
23
30.0k
  ~OptionValueArray() override = default;
24
25
  // Virtual subclass pure virtual overrides
26
27
32.6k
  OptionValue::Type GetType() const override { return eTypeArray; }
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
17.4k
  void Clear() override {
37
17.4k
    m_values.clear();
38
17.4k
    m_value_was_set = false;
39
17.4k
  }
40
41
  lldb::OptionValueSP
42
  DeepCopy(const lldb::OptionValueSP &new_parent) const override;
43
44
0
  bool IsAggregateValue() const override { return true; }
45
46
  lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
47
                                  llvm::StringRef name, bool will_modify,
48
                                  Status &error) const override;
49
50
  // Subclass specific functions
51
52
467
  size_t GetSize() const { return m_values.size(); }
53
54
6
  lldb::OptionValueSP operator[](size_t idx) const {
55
6
    lldb::OptionValueSP value_sp;
56
6
    if (idx < m_values.size())
57
6
      value_sp = m_values[idx];
58
6
    return value_sp;
59
6
  }
60
61
73
  lldb::OptionValueSP GetValueAtIndex(size_t idx) const {
62
73
    lldb::OptionValueSP value_sp;
63
73
    if (idx < m_values.size())
64
73
      value_sp = m_values[idx];
65
73
    return value_sp;
66
73
  }
67
68
147
  bool AppendValue(const lldb::OptionValueSP &value_sp) {
69
    // Make sure the value_sp object is allowed to contain values of the type
70
    // passed in...
71
147
    if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
72
147
      m_values.push_back(value_sp);
73
147
      return true;
74
147
    }
75
0
    return false;
76
147
  }
77
78
73
  bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
79
    // Make sure the value_sp object is allowed to contain values of the type
80
    // passed in...
81
73
    if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
82
73
      if (idx < m_values.size())
83
0
        m_values.insert(m_values.begin() + idx, value_sp);
84
73
      else
85
73
        m_values.push_back(value_sp);
86
73
      return true;
87
73
    }
88
0
    return false;
89
73
  }
90
91
0
  bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
92
0
    // Make sure the value_sp object is allowed to contain values of the type
93
0
    // passed in...
94
0
    if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
95
0
      if (idx < m_values.size()) {
96
0
        m_values[idx] = value_sp;
97
0
        return true;
98
0
      }
99
0
    }
100
0
    return false;
101
0
  }
102
103
0
  bool DeleteValue(size_t idx) {
104
0
    if (idx < m_values.size()) {
105
0
      m_values.erase(m_values.begin() + idx);
106
0
      return true;
107
0
    }
108
0
    return false;
109
0
  }
110
111
  size_t GetArgs(Args &args) const;
112
113
  Status SetArgs(const Args &args, VarSetOperationType op);
114
115
protected:
116
  typedef std::vector<lldb::OptionValueSP> collection;
117
118
  uint32_t m_type_mask;
119
  collection m_values;
120
  bool m_raw_value_dump;
121
};
122
123
} // namespace lldb_private
124
125
#endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H