xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Core/ValueObjectCast.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===-- ValueObjectCast.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_CORE_VALUEOBJECTCAST_H
10 #define LLDB_CORE_VALUEOBJECTCAST_H
11 
12 #include "lldb/Core/ValueObject.h"
13 #include "lldb/Symbol/CompilerType.h"
14 #include "lldb/lldb-defines.h"
15 #include "lldb/lldb-enumerations.h"
16 #include "lldb/lldb-forward.h"
17 
18 #include <cstddef>
19 #include <cstdint>
20 #include <optional>
21 
22 namespace lldb_private {
23 class ConstString;
24 
25 /// A ValueObject that represents a given value represented as a different type.
26 class ValueObjectCast : public ValueObject {
27 public:
28   ~ValueObjectCast() override;
29 
30   static lldb::ValueObjectSP Create(ValueObject &parent,
31                                     ConstString name,
32                                     const CompilerType &cast_type);
33 
34   std::optional<uint64_t> GetByteSize() override;
35 
36   llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
37 
38   lldb::ValueType GetValueType() const override;
39 
40   bool IsInScope() override;
41 
GetParent()42   ValueObject *GetParent() override {
43     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
44   }
45 
GetParent()46   const ValueObject *GetParent() const override {
47     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
48   }
49 
50 protected:
51   ValueObjectCast(ValueObject &parent, ConstString name,
52                   const CompilerType &cast_type);
53 
54   bool UpdateValue() override;
55 
56   CompilerType GetCompilerTypeImpl() override;
57 
58   CompilerType m_cast_type;
59 
60 private:
61   ValueObjectCast(const ValueObjectCast &) = delete;
62   const ValueObjectCast &operator=(const ValueObjectCast &) = delete;
63 };
64 
65 } // namespace lldb_private
66 
67 #endif // LLDB_CORE_VALUEOBJECTCAST_H
68