114 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H10#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H11 12#include "lldb/Core/dwarf.h"13#include "lldb/lldb-defines.h"14#include "lldb/lldb-enumerations.h"15#include "lldb/lldb-private-enumerations.h"16 17namespace lldb_private {18 19class ClangASTMetadata {20public:21 ClangASTMetadata()22 : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),23 m_has_object_ptr(false), m_is_self(false),24 m_is_forcefully_completed(false) {25 SetIsDynamicCXXType(std::nullopt);26 }27 28 std::optional<bool> GetIsDynamicCXXType() const;29 30 void SetIsDynamicCXXType(std::optional<bool> b);31 32 void SetUserID(lldb::user_id_t user_id) {33 m_user_id = user_id;34 m_union_is_user_id = true;35 m_union_is_isa_ptr = false;36 }37 38 lldb::user_id_t GetUserID() const {39 if (m_union_is_user_id)40 return m_user_id;41 else42 return LLDB_INVALID_UID;43 }44 45 void SetISAPtr(uint64_t isa_ptr) {46 m_isa_ptr = isa_ptr;47 m_union_is_user_id = false;48 m_union_is_isa_ptr = true;49 }50 51 uint64_t GetISAPtr() const {52 if (m_union_is_isa_ptr)53 return m_isa_ptr;54 else55 return 0;56 }57 58 void SetObjectPtrName(const char *name) {59 m_has_object_ptr = true;60 if (strcmp(name, "self") == 0)61 m_is_self = true;62 else if (strcmp(name, "this") == 0)63 m_is_self = false;64 else65 m_has_object_ptr = false;66 }67 68 lldb::LanguageType GetObjectPtrLanguage() const {69 if (m_has_object_ptr) {70 if (m_is_self)71 return lldb::eLanguageTypeObjC;72 else73 return lldb::eLanguageTypeC_plus_plus;74 }75 return lldb::eLanguageTypeUnknown;76 }77 78 const char *GetObjectPtrName() const {79 if (m_has_object_ptr) {80 if (m_is_self)81 return "self";82 else83 return "this";84 } else85 return nullptr;86 }87 88 bool HasObjectPtr() const { return m_has_object_ptr; }89 90 /// A type is "forcefully completed" if it was declared complete to satisfy an91 /// AST invariant (e.g. base classes must be complete types), but in fact we92 /// were not able to find a actual definition for it.93 bool IsForcefullyCompleted() const { return m_is_forcefully_completed; }94 95 void SetIsForcefullyCompleted(bool value = true) {96 m_is_forcefully_completed = true;97 }98 99 void Dump(Stream *s);100 101private:102 union {103 lldb::user_id_t m_user_id;104 uint64_t m_isa_ptr;105 };106 107 unsigned m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1,108 m_is_self : 1, m_is_dynamic_cxx : 2, m_is_forcefully_completed : 1;109};110 111} // namespace lldb_private112 113#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H114