xref: /freebsd/contrib/llvm-project/lldb/include/lldb/ValueObject/ValueObjectCast.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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_VALUEOBJECT_VALUEOBJECTCAST_H
10 #define LLDB_VALUEOBJECT_VALUEOBJECTCAST_H
11 
12 #include "lldb/Symbol/CompilerType.h"
13 #include "lldb/ValueObject/ValueObject.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, ConstString name,
31                                     const CompilerType &cast_type);
32 
33   llvm::Expected<uint64_t> GetByteSize() override;
34 
35   llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
36 
37   lldb::ValueType GetValueType() const override;
38 
39   bool IsInScope() override;
40 
GetParent()41   ValueObject *GetParent() override {
42     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
43   }
44 
GetParent()45   const ValueObject *GetParent() const override {
46     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
47   }
48 
49 protected:
50   ValueObjectCast(ValueObject &parent, ConstString name,
51                   const CompilerType &cast_type);
52 
53   bool UpdateValue() override;
54 
55   CompilerType GetCompilerTypeImpl() override;
56 
57   CompilerType m_cast_type;
58 
59 private:
60   ValueObjectCast(const ValueObjectCast &) = delete;
61   const ValueObjectCast &operator=(const ValueObjectCast &) = delete;
62 };
63 
64 } // namespace lldb_private
65 
66 #endif // LLDB_VALUEOBJECT_VALUEOBJECTCAST_H
67