xref: /freebsd/contrib/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- ClangASTMetadata.cpp ----------------------------------------------===//
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 #include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
10 #include "lldb/Utility/Stream.h"
11 
12 using namespace lldb_private;
13 
GetIsDynamicCXXType() const14 std::optional<bool> ClangASTMetadata::GetIsDynamicCXXType() const {
15   switch (m_is_dynamic_cxx) {
16   case 0:
17     return std::nullopt;
18   case 1:
19     return false;
20   case 2:
21     return true;
22   }
23   llvm_unreachable("Invalid m_is_dynamic_cxx value");
24 }
25 
SetIsDynamicCXXType(std::optional<bool> b)26 void ClangASTMetadata::SetIsDynamicCXXType(std::optional<bool> b) {
27   m_is_dynamic_cxx = b ? *b + 1 : 0;
28 }
29 
Dump(Stream * s)30 void ClangASTMetadata::Dump(Stream *s) {
31   lldb::user_id_t uid = GetUserID();
32 
33   if (uid != LLDB_INVALID_UID) {
34     s->Printf("uid=0x%" PRIx64, uid);
35   }
36 
37   uint64_t isa_ptr = GetISAPtr();
38   if (isa_ptr != 0) {
39     s->Printf("isa_ptr=0x%" PRIx64, isa_ptr);
40   }
41 
42   const char *obj_ptr_name = GetObjectPtrName();
43   if (obj_ptr_name) {
44     s->Printf("obj_ptr_name=\"%s\" ", obj_ptr_name);
45   }
46 
47   if (m_is_dynamic_cxx) {
48     s->Printf("is_dynamic_cxx=%i ", m_is_dynamic_cxx);
49   }
50   s->EOL();
51 }
52