ClangASTMetadata.h revision 360784
1//===-- ClangASTMetadata.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 liblldb_ClangASTMetadata_h
10#define liblldb_ClangASTMetadata_h
11
12#include "lldb/Core/dwarf.h"
13#include "lldb/lldb-defines.h"
14#include "lldb/lldb-enumerations.h"
15
16namespace lldb_private {
17
18class ClangASTMetadata {
19public:
20  ClangASTMetadata()
21      : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
22        m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {}
23
24  bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
25
26  void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; }
27
28  void SetUserID(lldb::user_id_t user_id) {
29    m_user_id = user_id;
30    m_union_is_user_id = true;
31    m_union_is_isa_ptr = false;
32  }
33
34  lldb::user_id_t GetUserID() const {
35    if (m_union_is_user_id)
36      return m_user_id;
37    else
38      return LLDB_INVALID_UID;
39  }
40
41  void SetISAPtr(uint64_t isa_ptr) {
42    m_isa_ptr = isa_ptr;
43    m_union_is_user_id = false;
44    m_union_is_isa_ptr = true;
45  }
46
47  uint64_t GetISAPtr() const {
48    if (m_union_is_isa_ptr)
49      return m_isa_ptr;
50    else
51      return 0;
52  }
53
54  void SetObjectPtrName(const char *name) {
55    m_has_object_ptr = true;
56    if (strcmp(name, "self") == 0)
57      m_is_self = true;
58    else if (strcmp(name, "this") == 0)
59      m_is_self = false;
60    else
61      m_has_object_ptr = false;
62  }
63
64  lldb::LanguageType GetObjectPtrLanguage() const {
65    if (m_has_object_ptr) {
66      if (m_is_self)
67        return lldb::eLanguageTypeObjC;
68      else
69        return lldb::eLanguageTypeC_plus_plus;
70    }
71    return lldb::eLanguageTypeUnknown;
72  }
73
74  const char *GetObjectPtrName() const {
75    if (m_has_object_ptr) {
76      if (m_is_self)
77        return "self";
78      else
79        return "this";
80    } else
81      return nullptr;
82  }
83
84  bool HasObjectPtr() const { return m_has_object_ptr; }
85
86  void Dump(Stream *s);
87
88private:
89  union {
90    lldb::user_id_t m_user_id;
91    uint64_t m_isa_ptr;
92  };
93
94  bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1,
95      m_is_self : 1, m_is_dynamic_cxx : 1;
96};
97
98} // namespace lldb_private
99
100#endif // liblldb_ClangASTMetadata_h
101