LLDB  mainline
Type.cpp
Go to the documentation of this file.
1 //===-- Type.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 <cstdio>
10 #include <optional>
11 
12 #include "lldb/Core/Module.h"
15 #include "lldb/Utility/LLDBLog.h"
16 #include "lldb/Utility/Log.h"
17 #include "lldb/Utility/Scalar.h"
19 
21 #include "lldb/Symbol/ObjectFile.h"
23 #include "lldb/Symbol/SymbolFile.h"
25 #include "lldb/Symbol/Type.h"
26 #include "lldb/Symbol/TypeList.h"
27 #include "lldb/Symbol/TypeSystem.h"
28 
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Target.h"
32 
33 #include "llvm/ADT/StringRef.h"
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 
38 bool lldb_private::contextMatches(llvm::ArrayRef<CompilerContext> context_chain,
39  llvm::ArrayRef<CompilerContext> pattern) {
40  auto ctx = context_chain.begin();
41  auto ctx_end = context_chain.end();
42  for (const CompilerContext &pat : pattern) {
43  // Early exit if the pattern is too long.
44  if (ctx == ctx_end)
45  return false;
46  if (*ctx != pat) {
47  // Skip any number of module matches.
48  if (pat.kind == CompilerContextKind::AnyModule) {
49  // Greedily match 0..n modules.
50  ctx = std::find_if(ctx, ctx_end, [](const CompilerContext &ctx) {
51  return ctx.kind != CompilerContextKind::Module;
52  });
53  continue;
54  }
55  // See if there is a kind mismatch; they should have 1 bit in common.
56  if (((uint16_t)ctx->kind & (uint16_t)pat.kind) == 0)
57  return false;
58  // The name is ignored for AnyModule, but not for AnyType.
59  if (pat.kind != CompilerContextKind::AnyModule && ctx->name != pat.name)
60  return false;
61  }
62  ++ctx;
63  }
64  return true;
65 }
66 
67 void CompilerContext::Dump() const {
68  switch (kind) {
69  default:
70  printf("Invalid");
71  break;
72  case CompilerContextKind::TranslationUnit:
73  printf("TranslationUnit");
74  break;
75  case CompilerContextKind::Module:
76  printf("Module");
77  break;
78  case CompilerContextKind::Namespace:
79  printf("Namespace");
80  break;
81  case CompilerContextKind::Class:
82  printf("Class");
83  break;
84  case CompilerContextKind::Struct:
85  printf("Structure");
86  break;
87  case CompilerContextKind::Union:
88  printf("Union");
89  break;
90  case CompilerContextKind::Function:
91  printf("Function");
92  break;
93  case CompilerContextKind::Variable:
94  printf("Variable");
95  break;
96  case CompilerContextKind::Enum:
97  printf("Enumeration");
98  break;
99  case CompilerContextKind::Typedef:
100  printf("Typedef");
101  break;
102  case CompilerContextKind::AnyModule:
103  printf("AnyModule");
104  break;
105  case CompilerContextKind::AnyType:
106  printf("AnyType");
107  break;
108  }
109  printf("(\"%s\")\n", name.GetCString());
110 }
111 
113 public:
114  TypeAppendVisitor(TypeListImpl &type_list) : m_type_list(type_list) {}
115 
116  bool operator()(const lldb::TypeSP &type) {
117  m_type_list.Append(TypeImplSP(new TypeImpl(type)));
118  return true;
119  }
120 
121 private:
123 };
124 
125 void TypeListImpl::Append(const lldb_private::TypeList &type_list) {
126  TypeAppendVisitor cb(*this);
127  type_list.ForEach(cb);
128 }
129 
130 SymbolFileType::SymbolFileType(SymbolFile &symbol_file,
131  const lldb::TypeSP &type_sp)
132  : UserID(type_sp ? type_sp->GetID() : LLDB_INVALID_UID),
133  m_symbol_file(symbol_file), m_type_sp(type_sp) {}
134 
136  if (!m_type_sp) {
137  Type *resolved_type = m_symbol_file.ResolveTypeUID(GetID());
138  if (resolved_type)
139  m_type_sp = resolved_type->shared_from_this();
140  }
141  return m_type_sp.get();
142 }
143 
145  std::optional<uint64_t> byte_size, SymbolContextScope *context,
146  user_id_t encoding_uid, EncodingDataType encoding_uid_type,
147  const Declaration &decl, const CompilerType &compiler_type,
148  ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
149  : std::enable_shared_from_this<Type>(), UserID(uid), m_name(name),
150  m_symbol_file(symbol_file), m_context(context),
151  m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
152  m_decl(decl), m_compiler_type(compiler_type),
153  m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
154  : ResolveState::Unresolved),
155  m_payload(opaque_payload) {
156  if (byte_size) {
157  m_byte_size = *byte_size;
158  m_byte_size_has_value = true;
159  } else {
160  m_byte_size = 0;
161  m_byte_size_has_value = false;
162  }
163 }
164 
166  : std::enable_shared_from_this<Type>(), UserID(0), m_name("<INVALID TYPE>"),
167  m_payload(0) {
168  m_byte_size = 0;
169  m_byte_size_has_value = false;
170 }
171 
173  bool show_name, ExecutionContextScope *exe_scope) {
174  *s << "id = " << (const UserID &)*this;
175 
176  // Call the name accessor to make sure we resolve the type name
177  if (show_name) {
178  ConstString type_name = GetName();
179  if (type_name) {
180  *s << ", name = \"" << type_name << '"';
181  ConstString qualified_type_name(GetQualifiedName());
182  if (qualified_type_name != type_name) {
183  *s << ", qualified = \"" << qualified_type_name << '"';
184  }
185  }
186  }
187 
188  // Call the get byte size accessor so we resolve our byte size
189  if (GetByteSize(exe_scope))
190  s->Printf(", byte-size = %" PRIu64, m_byte_size);
191  bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
192  m_decl.Dump(s, show_fullpaths);
193 
194  if (m_compiler_type.IsValid()) {
195  *s << ", compiler_type = \"";
197  *s << '"';
198  } else if (m_encoding_uid != LLDB_INVALID_UID) {
199  s->Printf(", type_uid = 0x%8.8" PRIx64, m_encoding_uid);
200  switch (m_encoding_uid_type) {
201  case eEncodingInvalid:
202  break;
203  case eEncodingIsUID:
204  s->PutCString(" (unresolved type)");
205  break;
206  case eEncodingIsConstUID:
207  s->PutCString(" (unresolved const type)");
208  break;
210  s->PutCString(" (unresolved restrict type)");
211  break;
213  s->PutCString(" (unresolved volatile type)");
214  break;
216  s->PutCString(" (unresolved atomic type)");
217  break;
219  s->PutCString(" (unresolved typedef)");
220  break;
222  s->PutCString(" (unresolved pointer)");
223  break;
225  s->PutCString(" (unresolved L value reference)");
226  break;
228  s->PutCString(" (unresolved R value reference)");
229  break;
231  s->PutCString(" (synthetic type)");
232  break;
233  }
234  }
235 }
236 
237 void Type::Dump(Stream *s, bool show_context, lldb::DescriptionLevel level) {
238  s->Printf("%p: ", static_cast<void *>(this));
239  s->Indent();
240  *s << "Type" << static_cast<const UserID &>(*this) << ' ';
241  if (m_name)
242  *s << ", name = \"" << m_name << "\"";
243 
245  s->Printf(", size = %" PRIu64, m_byte_size);
246 
247  if (show_context && m_context != nullptr) {
248  s->PutCString(", context = ( ");
250  s->PutCString(" )");
251  }
252 
253  bool show_fullpaths = false;
254  m_decl.Dump(s, show_fullpaths);
255 
256  if (m_compiler_type.IsValid()) {
257  *s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
259  } else if (m_encoding_uid != LLDB_INVALID_UID) {
260  s->Format(", type_data = {0:x-16}", m_encoding_uid);
261  switch (m_encoding_uid_type) {
262  case eEncodingInvalid:
263  break;
264  case eEncodingIsUID:
265  s->PutCString(" (unresolved type)");
266  break;
267  case eEncodingIsConstUID:
268  s->PutCString(" (unresolved const type)");
269  break;
271  s->PutCString(" (unresolved restrict type)");
272  break;
274  s->PutCString(" (unresolved volatile type)");
275  break;
277  s->PutCString(" (unresolved atomic type)");
278  break;
280  s->PutCString(" (unresolved typedef)");
281  break;
283  s->PutCString(" (unresolved pointer)");
284  break;
286  s->PutCString(" (unresolved L value reference)");
287  break;
289  s->PutCString(" (unresolved R value reference)");
290  break;
292  s->PutCString(" (synthetic type)");
293  break;
294  }
295  }
296 
297  //
298  // if (m_access)
299  // s->Printf(", access = %u", m_access);
300  s->EOL();
301 }
302 
304  if (!m_name)
306  return m_name;
307 }
308 
310  return GetForwardCompilerType().GetTypeName(/*BaseOnly*/ true);
311 }
312 
313 void Type::DumpTypeName(Stream *s) { GetName().Dump(s, "<invalid-type-name>"); }
314 
316  const DataExtractor &data, uint32_t data_byte_offset,
317  bool show_types, bool show_summary, bool verbose,
318  lldb::Format format) {
320  if (show_types) {
321  s->PutChar('(');
322  if (verbose)
323  s->Printf("Type{0x%8.8" PRIx64 "} ", GetID());
324  DumpTypeName(s);
325  s->PutCString(") ");
326  }
327 
329  exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
330  data_byte_offset,
331  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
332  .value_or(0),
333  0, // Bitfield bit size
334  0, // Bitfield bit offset
335  show_types, show_summary, verbose, 0);
336  }
337 }
338 
340  if (m_encoding_type == nullptr && m_encoding_uid != LLDB_INVALID_UID)
342  return m_encoding_type;
343 }
344 
345 std::optional<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
347  return static_cast<uint64_t>(m_byte_size);
348 
349  switch (m_encoding_uid_type) {
350  case eEncodingInvalid:
352  break;
353  case eEncodingIsUID:
354  case eEncodingIsConstUID:
358  case eEncodingIsTypedefUID: {
359  Type *encoding_type = GetEncodingType();
360  if (encoding_type)
361  if (std::optional<uint64_t> size =
362  encoding_type->GetByteSize(exe_scope)) {
363  m_byte_size = *size;
364  m_byte_size_has_value = true;
365  return static_cast<uint64_t>(m_byte_size);
366  }
367 
368  if (std::optional<uint64_t> size =
369  GetLayoutCompilerType().GetByteSize(exe_scope)) {
370  m_byte_size = *size;
371  m_byte_size_has_value = true;
372  return static_cast<uint64_t>(m_byte_size);
373  }
374  } break;
375 
376  // If we are a pointer or reference, then this is just a pointer size;
381  m_byte_size = arch.GetAddressByteSize();
382  m_byte_size_has_value = true;
383  return static_cast<uint64_t>(m_byte_size);
384  }
385  } break;
386  }
387  return {};
388 }
389 
390 uint32_t Type::GetNumChildren(bool omit_empty_base_classes) {
391  return GetForwardCompilerType().GetNumChildren(omit_empty_base_classes, nullptr);
392 }
393 
396 }
397 
400 }
401 
402 lldb::TypeSP Type::GetTypedefType() {
403  lldb::TypeSP type_sp;
404  if (IsTypedef()) {
406  if (typedef_type)
407  type_sp = typedef_type->shared_from_this();
408  }
409  return type_sp;
410 }
411 
413 
415  // Make sure we resolve our type if it already hasn't been.
416  return GetForwardCompilerType().GetEncoding(count);
417 }
418 
420  lldb::addr_t address, AddressType address_type,
421  bool show_types, bool show_summary, bool verbose) {
422  if (address != LLDB_INVALID_ADDRESS) {
423  DataExtractor data;
424  Target *target = nullptr;
425  if (exe_ctx)
426  target = exe_ctx->GetTargetPtr();
427  if (target)
428  data.SetByteOrder(target->GetArchitecture().GetByteOrder());
429  if (ReadFromMemory(exe_ctx, address, address_type, data)) {
430  DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
431  return true;
432  }
433  }
434  return false;
435 }
436 
438  AddressType address_type, DataExtractor &data) {
439  if (address_type == eAddressTypeFile) {
440  // Can't convert a file address to anything valid without more context
441  // (which Module it came from)
442  return false;
443  }
444 
445  const uint64_t byte_size =
446  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
447  .value_or(0);
448  if (data.GetByteSize() < byte_size) {
449  lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
450  data.SetData(data_sp);
451  }
452 
453  uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
454  if (dst != nullptr) {
455  if (address_type == eAddressTypeHost) {
456  // The address is an address in this process, so just copy it
457  if (addr == 0)
458  return false;
459  memcpy(dst, reinterpret_cast<uint8_t *>(addr), byte_size);
460  return true;
461  } else {
462  if (exe_ctx) {
463  Process *process = exe_ctx->GetProcessPtr();
464  if (process) {
465  Status error;
466  return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size,
467  error) == byte_size;
468  }
469  }
470  }
471  }
472  return false;
473 }
474 
476  AddressType address_type, DataExtractor &data) {
477  return false;
478 }
479 
480 const Declaration &Type::GetDeclaration() const { return m_decl; }
481 
482 bool Type::ResolveCompilerType(ResolveState compiler_type_resolve_state) {
483  // TODO: This needs to consider the correct type system to use.
484  Type *encoding_type = nullptr;
485  if (!m_compiler_type.IsValid()) {
486  encoding_type = GetEncodingType();
487  if (encoding_type) {
488  switch (m_encoding_uid_type) {
489  case eEncodingIsUID: {
490  CompilerType encoding_compiler_type =
491  encoding_type->GetForwardCompilerType();
492  if (encoding_compiler_type.IsValid()) {
493  m_compiler_type = encoding_compiler_type;
495  encoding_type->m_compiler_type_resolve_state;
496  }
497  } break;
498 
499  case eEncodingIsConstUID:
501  encoding_type->GetForwardCompilerType().AddConstModifier();
502  break;
503 
506  encoding_type->GetForwardCompilerType().AddRestrictModifier();
507  break;
508 
511  encoding_type->GetForwardCompilerType().AddVolatileModifier();
512  break;
513 
516  encoding_type->GetForwardCompilerType().GetAtomicType();
517  break;
518 
521  m_name.AsCString("__lldb_invalid_typedef_name"),
522  GetSymbolFile()->GetDeclContextContainingUID(GetID()), m_payload);
523  m_name.Clear();
524  break;
525 
528  encoding_type->GetForwardCompilerType().GetPointerType();
529  break;
530 
534  break;
535 
539  break;
540 
541  default:
542  llvm_unreachable("Unhandled encoding_data_type.");
543  }
544  } else {
545  // We have no encoding type, return void?
546  auto type_system_or_err =
548  if (auto err = type_system_or_err.takeError()) {
549  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
550  "Unable to construct void type from TypeSystemClang");
551  } else {
552  CompilerType void_compiler_type;
553  auto ts = *type_system_or_err;
554  if (ts)
555  void_compiler_type = ts->GetBasicTypeFromAST(eBasicTypeVoid);
556  switch (m_encoding_uid_type) {
557  case eEncodingIsUID:
558  m_compiler_type = void_compiler_type;
559  break;
560 
561  case eEncodingIsConstUID:
562  m_compiler_type = void_compiler_type.AddConstModifier();
563  break;
564 
566  m_compiler_type = void_compiler_type.AddRestrictModifier();
567  break;
568 
570  m_compiler_type = void_compiler_type.AddVolatileModifier();
571  break;
572 
574  m_compiler_type = void_compiler_type.GetAtomicType();
575  break;
576 
578  m_compiler_type = void_compiler_type.CreateTypedef(
579  m_name.AsCString("__lldb_invalid_typedef_name"),
580  GetSymbolFile()->GetDeclContextContainingUID(GetID()), m_payload);
581  break;
582 
584  m_compiler_type = void_compiler_type.GetPointerType();
585  break;
586 
588  m_compiler_type = void_compiler_type.GetLValueReferenceType();
589  break;
590 
592  m_compiler_type = void_compiler_type.GetRValueReferenceType();
593  break;
594 
595  default:
596  llvm_unreachable("Unhandled encoding_data_type.");
597  }
598  }
599  }
600 
601  // When we have a EncodingUID, our "m_flags.compiler_type_resolve_state" is
602  // set to eResolveStateUnresolved so we need to update it to say that we
603  // now have a forward declaration since that is what we created above.
604  if (m_compiler_type.IsValid())
606  }
607 
608  // Check if we have a forward reference to a class/struct/union/enum?
609  if (compiler_type_resolve_state == ResolveState::Layout ||
610  compiler_type_resolve_state == ResolveState::Full) {
611  // Check if we have a forward reference to a class/struct/union/enum?
612  if (m_compiler_type.IsValid() &&
613  m_compiler_type_resolve_state < compiler_type_resolve_state) {
615  if (!m_compiler_type.IsDefined()) {
616  // We have a forward declaration, we need to resolve it to a complete
617  // definition.
619  }
620  }
621  }
622 
623  // If we have an encoding type, then we need to make sure it is resolved
624  // appropriately.
626  if (encoding_type == nullptr)
627  encoding_type = GetEncodingType();
628  if (encoding_type) {
629  ResolveState encoding_compiler_type_resolve_state =
630  compiler_type_resolve_state;
631 
632  if (compiler_type_resolve_state == ResolveState::Layout) {
633  switch (m_encoding_uid_type) {
637  encoding_compiler_type_resolve_state = ResolveState::Forward;
638  break;
639  default:
640  break;
641  }
642  }
643  encoding_type->ResolveCompilerType(encoding_compiler_type_resolve_state);
644  }
645  }
646  return m_compiler_type.IsValid();
647 }
649  uint32_t encoding_mask = 1u << m_encoding_uid_type;
650  Type *encoding_type = GetEncodingType();
651  assert(encoding_type != this);
652  if (encoding_type)
653  encoding_mask |= encoding_type->GetEncodingMask();
654  return encoding_mask;
655 }
656 
659  return m_compiler_type;
660 }
661 
664  return m_compiler_type;
665 }
666 
669  return m_compiler_type;
670 }
671 
674 }
675 
676 bool Type::GetTypeScopeAndBasename(llvm::StringRef name,
677  llvm::StringRef &scope,
678  llvm::StringRef &basename,
679  TypeClass &type_class) {
680  type_class = eTypeClassAny;
681 
682  if (name.empty())
683  return false;
684 
685  basename = name;
686  if (basename.consume_front("struct "))
687  type_class = eTypeClassStruct;
688  else if (basename.consume_front("class "))
689  type_class = eTypeClassClass;
690  else if (basename.consume_front("union "))
691  type_class = eTypeClassUnion;
692  else if (basename.consume_front("enum "))
693  type_class = eTypeClassEnumeration;
694  else if (basename.consume_front("typedef "))
695  type_class = eTypeClassTypedef;
696 
697  size_t namespace_separator = basename.find("::");
698  if (namespace_separator == llvm::StringRef::npos)
699  return false;
700 
701  size_t template_begin = basename.find('<');
702  while (namespace_separator != llvm::StringRef::npos) {
703  if (template_begin != llvm::StringRef::npos &&
704  namespace_separator > template_begin) {
705  size_t template_depth = 1;
706  llvm::StringRef template_arg =
707  basename.drop_front(template_begin + 1);
708  while (template_depth > 0 && !template_arg.empty()) {
709  if (template_arg.front() == '<')
710  template_depth++;
711  else if (template_arg.front() == '>')
712  template_depth--;
713  template_arg = template_arg.drop_front(1);
714  }
715  if (template_depth != 0)
716  return false; // We have an invalid type name. Bail out.
717  if (template_arg.empty())
718  break; // The template ends at the end of the full name.
719  basename = template_arg;
720  } else {
721  basename = basename.drop_front(namespace_separator + 2);
722  }
723  template_begin = basename.find('<');
724  namespace_separator = basename.find("::");
725  }
726  if (basename.size() < name.size()) {
727  scope = name.take_front(name.size() - basename.size());
728  return true;
729  }
730  return false;
731 }
732 
733 ModuleSP Type::GetModule() {
734  if (m_symbol_file)
736  return ModuleSP();
737 }
738 
739 ModuleSP Type::GetExeModule() {
740  if (m_compiler_type) {
741  auto ts = m_compiler_type.GetTypeSystem();
742  if (!ts)
743  return {};
744  SymbolFile *symbol_file = ts->GetSymbolFile();
745  if (symbol_file)
746  return symbol_file->GetObjectFile()->GetModule();
747  }
748  return {};
749 }
750 
751 TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) {
752  if (in_type_sp) {
753  m_compiler_type = in_type_sp->GetForwardCompilerType();
754  m_type_name = in_type_sp->GetName();
755  }
756 }
757 
758 TypeAndOrName::TypeAndOrName(const char *in_type_str)
759  : m_type_name(in_type_str) {}
760 
762  : m_type_name(in_type_const_string) {}
763 
764 bool TypeAndOrName::operator==(const TypeAndOrName &other) const {
765  if (m_compiler_type != other.m_compiler_type)
766  return false;
767  if (m_type_name != other.m_type_name)
768  return false;
769  return true;
770 }
771 
772 bool TypeAndOrName::operator!=(const TypeAndOrName &other) const {
773  return !(*this == other);
774 }
775 
777  if (m_type_name)
778  return m_type_name;
779  if (m_compiler_type)
780  return m_compiler_type.GetTypeName();
781  return ConstString("<invalid>");
782 }
783 
785  m_type_name = type_name;
786 }
787 
788 void TypeAndOrName::SetName(const char *type_name_cstr) {
789  m_type_name.SetCString(type_name_cstr);
790 }
791 
792 void TypeAndOrName::SetTypeSP(lldb::TypeSP type_sp) {
793  if (type_sp) {
794  m_compiler_type = type_sp->GetForwardCompilerType();
795  m_type_name = type_sp->GetName();
796  } else
797  Clear();
798 }
799 
801  m_compiler_type = compiler_type;
802  if (m_compiler_type)
804 }
805 
807  return !((bool)m_type_name || (bool)m_compiler_type);
808 }
809 
811  m_type_name.Clear();
813 }
814 
815 bool TypeAndOrName::HasName() const { return (bool)m_type_name; }
816 
818  return m_compiler_type.IsValid();
819 }
820 
821 TypeImpl::TypeImpl(const lldb::TypeSP &type_sp)
822  : m_module_wp(), m_static_type(), m_dynamic_type() {
823  SetType(type_sp);
824 }
825 
826 TypeImpl::TypeImpl(const CompilerType &compiler_type)
827  : m_module_wp(), m_static_type(), m_dynamic_type() {
828  SetType(compiler_type);
829 }
830 
831 TypeImpl::TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic)
832  : m_module_wp(), m_static_type(), m_dynamic_type(dynamic) {
833  SetType(type_sp, dynamic);
834 }
835 
836 TypeImpl::TypeImpl(const CompilerType &static_type,
837  const CompilerType &dynamic_type)
838  : m_module_wp(), m_static_type(), m_dynamic_type() {
839  SetType(static_type, dynamic_type);
840 }
841 
842 void TypeImpl::SetType(const lldb::TypeSP &type_sp) {
843  if (type_sp) {
844  m_static_type = type_sp->GetForwardCompilerType();
845  m_exe_module_wp = type_sp->GetExeModule();
846  m_module_wp = type_sp->GetModule();
847  } else {
849  m_module_wp = lldb::ModuleWP();
850  }
851 }
852 
853 void TypeImpl::SetType(const CompilerType &compiler_type) {
854  m_module_wp = lldb::ModuleWP();
855  m_static_type = compiler_type;
856 }
857 
858 void TypeImpl::SetType(const lldb::TypeSP &type_sp,
859  const CompilerType &dynamic) {
860  SetType(type_sp);
861  m_dynamic_type = dynamic;
862 }
863 
864 void TypeImpl::SetType(const CompilerType &compiler_type,
865  const CompilerType &dynamic) {
866  m_module_wp = lldb::ModuleWP();
867  m_static_type = compiler_type;
868  m_dynamic_type = dynamic;
869 }
870 
871 bool TypeImpl::CheckModule(lldb::ModuleSP &module_sp) const {
872  return CheckModuleCommon(m_module_wp, module_sp);
873 }
874 
875 bool TypeImpl::CheckExeModule(lldb::ModuleSP &module_sp) const {
876  return CheckModuleCommon(m_exe_module_wp, module_sp);
877 }
878 
879 bool TypeImpl::CheckModuleCommon(const lldb::ModuleWP &input_module_wp,
880  lldb::ModuleSP &module_sp) const {
881  // Check if we have a module for this type. If we do and the shared pointer
882  // is can be successfully initialized with m_module_wp, return true. Else
883  // return false if we didn't have a module, or if we had a module and it has
884  // been deleted. Any functions doing anything with a TypeSP in this TypeImpl
885  // class should call this function and only do anything with the ivars if
886  // this function returns true. If we have a module, the "module_sp" will be
887  // filled in with a strong reference to the module so that the module will at
888  // least stay around long enough for the type query to succeed.
889  module_sp = input_module_wp.lock();
890  if (!module_sp) {
891  lldb::ModuleWP empty_module_wp;
892  // If either call to "std::weak_ptr::owner_before(...) value returns true,
893  // this indicates that m_module_wp once contained (possibly still does) a
894  // reference to a valid shared pointer. This helps us know if we had a
895  // valid reference to a section which is now invalid because the module it
896  // was in was deleted
897  if (empty_module_wp.owner_before(input_module_wp) ||
898  input_module_wp.owner_before(empty_module_wp)) {
899  // input_module_wp had a valid reference to a module, but all strong
900  // references have been released and the module has been deleted
901  return false;
902  }
903  }
904  // We either successfully locked the module, or didn't have one to begin with
905  return true;
906 }
907 
908 bool TypeImpl::operator==(const TypeImpl &rhs) const {
909  return m_static_type == rhs.m_static_type &&
911 }
912 
913 bool TypeImpl::operator!=(const TypeImpl &rhs) const {
914  return !(*this == rhs);
915 }
916 
917 bool TypeImpl::IsValid() const {
918  // just a name is not valid
919  ModuleSP module_sp;
920  if (CheckModule(module_sp))
922  return false;
923 }
924 
925 TypeImpl::operator bool() const { return IsValid(); }
926 
928  m_module_wp = lldb::ModuleWP();
931 }
932 
933 ModuleSP TypeImpl::GetModule() const {
934  lldb::ModuleSP module_sp;
935  if (CheckExeModule(module_sp))
936  return module_sp;
937  return nullptr;
938 }
939 
941  ModuleSP module_sp;
942  if (CheckModule(module_sp)) {
943  if (m_dynamic_type)
944  return m_dynamic_type.GetTypeName();
945  return m_static_type.GetTypeName();
946  }
947  return ConstString();
948 }
949 
951  ModuleSP module_sp;
952  if (CheckModule(module_sp)) {
953  if (m_dynamic_type)
956  }
957  return ConstString();
958 }
959 
961  ModuleSP module_sp;
962  if (CheckModule(module_sp)) {
963  if (m_dynamic_type.IsValid()) {
966  }
968  }
969  return TypeImpl();
970 }
971 
973  ModuleSP module_sp;
974  if (CheckModule(module_sp)) {
975  if (m_dynamic_type.IsValid()) {
978  }
980  }
981  return TypeImpl();
982 }
983 
985  ModuleSP module_sp;
986  if (CheckModule(module_sp)) {
987  if (m_dynamic_type.IsValid()) {
990  }
992  }
993  return TypeImpl();
994 }
995 
997  ModuleSP module_sp;
998  if (CheckModule(module_sp)) {
999  if (m_dynamic_type.IsValid()) {
1002  }
1004  }
1005  return TypeImpl();
1006 }
1007 
1009  ModuleSP module_sp;
1010  if (CheckModule(module_sp)) {
1011  if (m_dynamic_type.IsValid()) {
1014  }
1016  }
1017  return TypeImpl();
1018 }
1019 
1021  ModuleSP module_sp;
1022  if (CheckModule(module_sp)) {
1023  if (m_dynamic_type.IsValid()) {
1026  }
1028  }
1029  return TypeImpl();
1030 }
1031 
1033  ModuleSP module_sp;
1034  if (CheckModule(module_sp)) {
1035  if (m_dynamic_type.IsValid()) {
1038  }
1040  }
1041  return TypeImpl();
1042 }
1043 
1045  ModuleSP module_sp;
1046  if (CheckModule(module_sp)) {
1047  if (prefer_dynamic) {
1048  if (m_dynamic_type.IsValid())
1049  return m_dynamic_type;
1050  }
1051  return m_static_type;
1052  }
1053  return CompilerType();
1054 }
1055 
1057  ModuleSP module_sp;
1058  if (CheckModule(module_sp)) {
1059  if (prefer_dynamic) {
1060  if (m_dynamic_type.IsValid())
1061  return m_dynamic_type.GetTypeSystem();
1062  }
1063  return m_static_type.GetTypeSystem();
1064  }
1065  return {};
1066 }
1067 
1069  lldb::DescriptionLevel description_level) {
1070  ModuleSP module_sp;
1071  if (CheckModule(module_sp)) {
1072  if (m_dynamic_type.IsValid()) {
1073  strm.Printf("Dynamic:\n");
1075  strm.Printf("\nStatic:\n");
1076  }
1078  } else {
1079  strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
1080  }
1081  return true;
1082 }
1083 
1086 }
1087 
1089 
1091  return m_decl.GetMangledName();
1092 }
1093 
1095 
1097  return m_kind;
1098 }
1099 
1101  switch (m_kind) {
1103  return false;
1105  stream.Printf("constructor for %s",
1106  m_type.GetTypeName().AsCString("<unknown>"));
1107  break;
1109  stream.Printf("destructor for %s",
1110  m_type.GetTypeName().AsCString("<unknown>"));
1111  break;
1113  stream.Printf("instance method %s of type %s", m_name.AsCString(),
1115  break;
1117  stream.Printf("static method %s of type %s", m_name.AsCString(),
1119  break;
1120  }
1121  return true;
1122 }
1123 
1125  if (m_type)
1126  return m_type.GetFunctionReturnType();
1127  return m_decl.GetFunctionReturnType();
1128 }
1129 
1131  if (m_type)
1133  else
1135 }
1136 
1138  if (m_type)
1139  return m_type.GetFunctionArgumentAtIndex(idx);
1140  else
1141  return m_decl.GetFunctionArgumentType(idx);
1142 }
1143 
1144 TypeEnumMemberImpl::TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp,
1145  ConstString name,
1146  const llvm::APSInt &value)
1147  : m_integer_type_sp(integer_type_sp), m_name(name), m_value(value),
1148  m_valid((bool)name && (bool)integer_type_sp)
1149 
1150 {}
lldb_private::CompilerType::GetNonReferenceType
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
Definition: CompilerType.cpp:459
lldb_private::TypeMemberFunctionImpl::m_kind
lldb::MemberFunctionKind m_kind
Definition: Type.h:485
lldb::eMemberFunctionKindDestructor
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
Definition: lldb-enumerations.h:1057
lldb_private::Stream::Format
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
lldb_private::TypeMemberFunctionImpl::m_type
CompilerType m_type
Definition: Type.h:482
lldb_private::ObjectFile::GetArchitecture
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:47
lldb_private::TypeAndOrName::IsEmpty
bool IsEmpty() const
Definition: Type.cpp:806
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:741
lldb_private::Type::EncodingDataType
EncodingDataType
Definition: Type.h:70
Scalar.h
lldb_private::TypeImpl::CheckModuleCommon
bool CheckModuleCommon(const lldb::ModuleWP &input_module_wp, lldb::ModuleSP &module_sp) const
Definition: Type.cpp:879
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::TypeImpl::GetCanonicalType
TypeImpl GetCanonicalType() const
Definition: Type.cpp:1032
lldb_private::Type::DumpValue
void DumpValue(ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, uint32_t data_offset, bool show_type, bool show_summary, bool verbose, lldb::Format format=lldb::eFormatDefault)
Definition: Type.cpp:315
lldb_private::Type::eEncodingIsSyntheticUID
@ eEncodingIsSyntheticUID
This type is the synthetic type whose UID is m_encoding_uid.
Definition: Type.h:95
lldb_private::TypeImpl::operator==
bool operator==(const TypeImpl &rhs) const
Definition: Type.cpp:908
lldb_private::Process::ReadMemory
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1926
lldb_private::LLDBLog::Symbols
@ Symbols
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:156
lldb_private::Type::eEncodingIsConstUID
@ eEncodingIsConstUID
This type is the type whose UID is m_encoding_uid with the const qualifier added.
Definition: Type.h:77
lldb_private::CompilerType::GetByteSize
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:560
lldb_private::CompilerType::IsDefined
bool IsDefined() const
Definition: CompilerType.cpp:232
lldb_private::CompilerDecl::GetNumFunctionArguments
size_t GetNumFunctionArguments() const
Definition: CompilerDecl.cpp:31
lldb_private::TypeAndOrName::SetName
void SetName(ConstString type_name)
Definition: Type.cpp:784
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
lldb_private::Type::GetFormat
lldb::Format GetFormat()
Definition: Type.cpp:412
lldb_private::Type::eEncodingIsTypedefUID
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
Definition: Type.h:85
lldb_private::TypeAndOrName::HasName
bool HasName() const
Definition: Type.cpp:815
lldb_private::contextMatches
bool contextMatches(llvm::ArrayRef< CompilerContext > context_chain, llvm::ArrayRef< CompilerContext > pattern)
Match context_chain against pattern, which may contain "Any" kinds.
Definition: Type.cpp:38
lldb_private::TypeAndOrName::SetCompilerType
void SetCompilerType(CompilerType compiler_type)
Definition: Type.cpp:800
lldb_private::TypeImpl::CheckModule
bool CheckModule(lldb::ModuleSP &module_sp) const
Definition: Type.cpp:871
lldb_private::UserID
Definition: UserID.h:31
lldb_private::Type::GetEncodingType
Type * GetEncodingType()
Definition: Type.cpp:339
lldb_private::AddressType
AddressType
Definition: lldb-private-enumerations.h:30
lldb_private::CompilerType::GetTypeName
ConstString GetTypeName(bool BaseOnly=false) const
Definition: CompilerType.cpp:322
lldb_private::Type::GetLayoutCompilerType
CompilerType GetLayoutCompilerType()
Definition: Type.cpp:662
lldb_private::TypeMemberFunctionImpl::m_decl
CompilerDecl m_decl
Definition: Type.h:483
lldb_private::Type::m_compiler_type_resolve_state
ResolveState m_compiler_type_resolve_state
Definition: Type.h:221
lldb_private::TypeImpl::GetModule
lldb::ModuleSP GetModule() const
Definition: Type.cpp:933
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
lldb_private::Process
Definition: Process.h:338
lldb::eMemberFunctionKindUnknown
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
Definition: lldb-enumerations.h:1055
Module.h
lldb_private::SymbolFile::GetTypeSystemForLanguage
virtual llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)=0
lldb_private::Type::m_payload
Payload m_payload
Language-specific flags.
Definition: Type.h:223
lldb_private::Type::GetModule
lldb::ModuleSP GetModule()
Since Type instances only keep a "SymbolFile *" internally, other classes like TypeImpl need make sur...
Definition: Type.cpp:733
lldb_private::eAddressTypeHost
@ eAddressTypeHost
Address is an address in the process that is running this code.
Definition: lldb-private-enumerations.h:36
lldb_private::Type::m_byte_size_has_value
uint64_t m_byte_size_has_value
Definition: Type.h:218
lldb_private::DataExtractor::PeekData
const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
Definition: DataExtractor.h:832
lldb_private::TypeMemberFunctionImpl::GetMangledName
ConstString GetMangledName() const
Definition: Type.cpp:1090
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:301
lldb_private::TypeImpl::GetDisplayTypeName
ConstString GetDisplayTypeName() const
Definition: Type.cpp:950
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:232
lldb_private::TypeMemberFunctionImpl::m_name
ConstString m_name
Definition: Type.h:484
lldb_private::CompilerType::AddVolatileModifier
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
Definition: CompilerType.cpp:510
lldb_private::Type::m_encoding_uid_type
EncodingDataType m_encoding_uid_type
Definition: Type.h:216
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:303
lldb_private::CompilerType::IsAggregateType
bool IsAggregateType() const
Definition: CompilerType.cpp:32
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::TypeAndOrName::Clear
void Clear()
Definition: Type.cpp:810
lldb_private::Target
Definition: Target.h:469
lldb_private::TypeList::ForEach
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition: TypeList.cpp:78
lldb_private::DataExtractor::SetData
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
Definition: DataExtractor.cpp:223
lldb_private::Type::Dump
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition: Type.cpp:237
lldb_private::Type::GetEncoding
lldb::Encoding GetEncoding(uint64_t &count)
Definition: Type.cpp:414
lldb_private::Type::eEncodingIsRValueReferenceUID
@ eEncodingIsRValueReferenceUID
This type is R value reference to a type whose UID is m_encoding_uid.
Definition: Type.h:91
lldb_private::CompilerType::GetFunctionArgumentAtIndex
CompilerType GetFunctionArgumentAtIndex(const size_t index) const
Definition: CompilerType.cpp:143
Process.h
lldb_private::TypeImpl::TypeImpl
TypeImpl()=default
lldb_private::Type::ResolveCompilerType
bool ResolveCompilerType(ResolveState compiler_type_resolve_state)
Definition: Type.cpp:482
lldb_private::TypeImpl::IsValid
bool IsValid() const
Definition: Type.cpp:917
lldb_private::TypeImpl::m_dynamic_type
CompilerType m_dynamic_type
Definition: Type.h:325
Target.h
lldb_private::Type::Type
Type()
Definition: Type.cpp:165
lldb_private::TypeMemberFunctionImpl::GetName
ConstString GetName() const
Definition: Type.cpp:1088
lldb_private::DataExtractor::SetByteOrder
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition: DataExtractor.h:931
lldb_private::Type::ResolveState
ResolveState
Definition: Type.h:98
lldb_private::Type::eEncodingInvalid
@ eEncodingInvalid
Invalid encoding.
Definition: Type.h:72
lldb_private::CompilerType::GetPointeeType
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
Definition: CompilerType.cpp:466
lldb_private::Declaration::Dump
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::TypeMemberFunctionImpl::GetKind
lldb::MemberFunctionKind GetKind() const
Definition: Type.cpp:1096
lldb_private::CompilerContext
CompilerContext allows an array of these items to be passed to perform detailed lookups in SymbolVend...
Definition: Type.h:29
lldb_private::Type::m_symbol_file
SymbolFile * m_symbol_file
Definition: Type.h:211
lldb_private::SymbolFileType::GetType
Type * GetType()
Definition: Type.cpp:135
lldb_private::CompilerType::GetDisplayTypeName
ConstString GetDisplayTypeName() const
Definition: CompilerType.cpp:330
lldb_private::CompilerType::GetTypeSystem
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
Definition: CompilerType.cpp:989
lldb_private::CompilerType::Clear
void Clear()
Definition: CompilerType.h:469
lldb_private::TypeAndOrName::GetName
ConstString GetName() const
Definition: Type.cpp:776
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
lldb_private::CompilerDecl::GetFunctionReturnType
CompilerType GetFunctionReturnType() const
Definition: CompilerDecl.cpp:27
lldb_private::SymbolFile::ResolveTypeUID
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
lldb_private::Type::eEncodingIsRestrictUID
@ eEncodingIsRestrictUID
This type is the type whose UID is m_encoding_uid with the restrict qualifier added.
Definition: Type.h:80
lldb_private::DataExtractor
Definition: DataExtractor.h:48
Log.h
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::CompilerType::CreateTypedef
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
Definition: CompilerType.cpp:524
lldb_private::TypeMemberFunctionImpl::GetType
CompilerType GetType() const
Definition: Type.cpp:1094
lldb_private::SymbolFileType::m_type_sp
lldb::TypeSP m_type_sp
Definition: Type.h:65
lldb_private::TypeAndOrName::HasCompilerType
bool HasCompilerType() const
Definition: Type.cpp:817
lldb_private::CompilerType::GetFormat
lldb::Format GetFormat() const
Definition: CompilerType.cpp:581
lldb_private::Type::eEncodingIsVolatileUID
@ eEncodingIsVolatileUID
This type is the type whose UID is m_encoding_uid with the volatile qualifier added.
Definition: Type.h:83
lldb_private::Type::GetTypedefType
lldb::TypeSP GetTypedefType()
Definition: Type.cpp:402
lldb_private::CompilerType::GetAtomicType
CompilerType GetAtomicType() const
Return a new CompilerType that is the atomic type of this type.
Definition: CompilerType.cpp:496
lldb_private::CompilerType::DumpValue
void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth)
Definition: CompilerType.cpp:818
StreamString.h
Type.h
SymbolContextScope.h
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::CompilerType::AddConstModifier
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
Definition: CompilerType.cpp:503
lldb_private::CompilerType::GetNumberOfFunctionArguments
size_t GetNumberOfFunctionArguments() const
Definition: CompilerType.cpp:135
lldb_private::Type::DumpTypeName
void DumpTypeName(Stream *s)
Definition: Type.cpp:313
TypeAppendVisitor
Definition: Type.cpp:112
lldb_private::Type::GetExeModule
lldb::ModuleSP GetExeModule()
GetModule may return module for compile unit's object file.
Definition: Type.cpp:739
lldb_private::CompilerDecl::GetDeclContext
CompilerDeclContext GetDeclContext() const
Definition: CompilerDecl.cpp:23
lldb_private::Type::GetDeclaration
const lldb_private::Declaration & GetDeclaration() const
Definition: Type.cpp:480
lldb_private::Type::GetSymbolFile
SymbolFile * GetSymbolFile()
Definition: Type.h:125
TypeAppendVisitor::operator()
bool operator()(const lldb::TypeSP &type)
Definition: Type.cpp:116
lldb::eBasicTypeVoid
@ eBasicTypeVoid
Definition: lldb-enumerations.h:756
lldb_private::TypeImpl::GetPointeeType
TypeImpl GetPointeeType() const
Definition: Type.cpp:972
lldb_private::TypeImpl::GetDereferencedType
TypeImpl GetDereferencedType() const
Definition: Type.cpp:1008
lldb_private::Type::WriteToMemory
bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
Definition: Type.cpp:475
lldb_private::CompilerType::GetEncoding
lldb::Encoding GetEncoding(uint64_t &count) const
Definition: CompilerType.cpp:574
lldb_private::CompilerDeclContext::GetName
ConstString GetName() const
Definition: CompilerDeclContext.cpp:25
TypeSystem.h
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::CompilerType::GetFunctionReturnType
CompilerType GetFunctionReturnType() const
Definition: CompilerType.cpp:435
lldb_private::ConstString::Dump
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
Definition: ConstString.cpp:282
CompilerType.h
lldb_private::Type::ResolveState::Full
@ Full
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:124
lldb_private::CompilerType::GetLValueReferenceType
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
Definition: CompilerType.cpp:482
lldb_private::Type::m_context
SymbolContextScope * m_context
The symbol context in which this type is defined.
Definition: Type.h:213
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
ObjectFile.h
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::CompilerType::GetNumChildren
uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
Definition: CompilerType.cpp:588
lldb_private::Type::m_encoding_type
Type * m_encoding_type
Definition: Type.h:214
lldb_private::TypeImpl::GetName
ConstString GetName() const
Definition: Type.cpp:940
lldb_private::Type::GetEncodingMask
uint32_t GetEncodingMask()
Definition: Type.cpp:648
lldb_private::Type::eEncodingIsPointerUID
@ eEncodingIsPointerUID
This type is pointer to a type whose UID is m_encoding_uid.
Definition: Type.h:87
lldb_private::Type::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
Definition: Type.cpp:172
TypeList.h
lldb_private::SymbolFile::CompleteType
virtual bool CompleteType(CompilerType &compiler_type)=0
lldb_private::ConstString::Clear
void Clear()
Clear this object's state.
Definition: ConstString.h:231
lldb_private::Type::m_encoding_uid
lldb::user_id_t m_encoding_uid
Definition: Type.h:215
TypeAppendVisitor::TypeAppendVisitor
TypeAppendVisitor(TypeListImpl &type_list)
Definition: Type.cpp:114
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:988
lldb_private::CompilerDecl::GetFunctionArgumentType
CompilerType GetFunctionArgumentType(size_t arg_idx) const
Definition: CompilerDecl.cpp:35
lldb::eMemberFunctionKindStaticMethod
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
Definition: lldb-enumerations.h:1061
lldb_private::Status
Definition: Status.h:44
lldb_private::CompilerType::GetPointerType
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
Definition: CompilerType.cpp:474
lldb_private::Type::IsAggregateType
bool IsAggregateType()
Definition: Type.cpp:394
lldb_private::TypeImpl::GetUnqualifiedType
TypeImpl GetUnqualifiedType() const
Definition: Type.cpp:1020
lldb_private::Type::GetQualifiedName
ConstString GetQualifiedName()
Definition: Type.cpp:672
lldb_private::Type::ResolveState::Layout
@ Layout
uint32_t
lldb::eMemberFunctionKindConstructor
@ eMemberFunctionKindConstructor
A function used to create instances.
Definition: lldb-enumerations.h:1056
lldb_private::Type::eEncodingIsLValueReferenceUID
@ eEncodingIsLValueReferenceUID
This type is L value reference to a type whose UID is m_encoding_uid.
Definition: Type.h:89
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:214
lldb_private::TypeMemberFunctionImpl::GetArgumentAtIndex
CompilerType GetArgumentAtIndex(size_t idx) const
Definition: Type.cpp:1137
lldb_private::TypeMemberFunctionImpl::GetReturnType
CompilerType GetReturnType() const
Definition: Type.cpp:1124
lldb_private::Type::IsTypedef
bool IsTypedef()
Definition: Type.h:143
lldb_private::TypeImpl::SetType
void SetType(const lldb::TypeSP &type_sp)
Definition: Type.cpp:842
lldb_private::TypeAndOrName::SetTypeSP
void SetTypeSP(lldb::TypeSP type_sp)
Definition: Type.cpp:792
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::TypeImpl::GetDescription
bool GetDescription(lldb_private::Stream &strm, lldb::DescriptionLevel description_level)
Definition: Type.cpp:1068
lldb_private::Type::ReadFromMemory
bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
Definition: Type.cpp:437
lldb_private::CompilerType::IsTemplateType
bool IsTemplateType() const
Definition: CompilerType.cpp:264
lldb_private::TypeImpl::m_exe_module_wp
lldb::ModuleWP m_exe_module_wp
Definition: Type.h:323
lldb_private::eAddressTypeFile
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
Definition: lldb-private-enumerations.h:32
lldb_private::Type::DumpValueInMemory
bool DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s, lldb::addr_t address, AddressType address_type, bool show_types, bool show_summary, bool verbose)
Definition: Type.cpp:419
lldb_private::CompilerType::GetCanonicalType
CompilerType GetCanonicalType() const
Definition: CompilerType.cpp:398
lldb_private::Type
Definition: Type.h:68
lldb_private::TypeAndOrName::operator!=
bool operator!=(const TypeAndOrName &other) const
Definition: Type.cpp:772
lldb_private::TypeImpl::GetCompilerType
CompilerType GetCompilerType(bool prefer_dynamic)
Definition: Type.cpp:1044
lldb_private::TypeImpl::GetTypeSystem
CompilerType::TypeSystemSPWrapper GetTypeSystem(bool prefer_dynamic)
Definition: Type.cpp:1056
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:667
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::CompilerType::AddRestrictModifier
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
Definition: CompilerType.cpp:517
lldb_private::TypeAndOrName::operator==
bool operator==(const TypeAndOrName &other) const
Definition: Type.cpp:764
lldb_private::CompilerDecl::GetMangledName
ConstString GetMangledName() const
Definition: CompilerDecl.cpp:19
uint16_t
lldb_private::TypeImpl::Clear
void Clear()
Definition: Type.cpp:927
lldb::Encoding
Encoding
Register encoding definitions.
Definition: lldb-enumerations.h:147
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::CompilerType::GetBasicTypeFromAST
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
Definition: CompilerType.cpp:543
lldb_private::CompilerType::GetTypedefedType
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
Definition: CompilerType.cpp:533
DataExtractor.h
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::TypeMemberFunctionImpl::GetNumArguments
size_t GetNumArguments() const
Definition: Type.cpp:1130
lldb_private::Type::m_decl
Declaration m_decl
Definition: Type.h:219
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:446
TypeAppendVisitor::m_type_list
TypeListImpl & m_type_list
Definition: Type.cpp:122
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Type::ResolveState::Forward
@ Forward
lldb::eDescriptionLevelVerbose
@ eDescriptionLevelVerbose
Definition: lldb-enumerations.h:211
lldb_private::TypeImpl
Definition: Type.h:257
lldb_private::CompilerContext::kind
CompilerContextKind kind
Definition: Type.h:39
lldb_private::TypeImpl::GetPointerType
TypeImpl GetPointerType() const
Definition: Type.cpp:960
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::TypeImpl::GetTypedefedType
TypeImpl GetTypedefedType() const
Definition: Type.cpp:996
lldb_private::SymbolContextScope::DumpSymbolContext
virtual void DumpSymbolContext(Stream *s)=0
Dump the object's symbol context to the stream s.
lldb_private::TypeAndOrName::TypeAndOrName
TypeAndOrName()=default
lldb::MemberFunctionKind
MemberFunctionKind
Kind of member function.
Definition: lldb-enumerations.h:1054
lldb_private::Type::GetByteSize
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
Definition: Type.cpp:345
lldb_private::TypeImpl::GetReferenceType
TypeImpl GetReferenceType() const
Definition: Type.cpp:984
lldb_private::Type::IsTemplateType
bool IsTemplateType()
Definition: Type.cpp:398
lldb_private::SymbolFileType::m_symbol_file
SymbolFile & m_symbol_file
Definition: Type.h:64
lldb_private::TypeImpl::m_module_wp
lldb::ModuleWP m_module_wp
Definition: Type.h:322
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::Type::m_name
ConstString m_name
Definition: Type.h:210
lldb_private::TypeMemberFunctionImpl::IsValid
bool IsValid()
Definition: Type.cpp:1084
lldb_private::Type::eEncodingIsAtomicUID
@ eEncodingIsAtomicUID
This type is the type whose UID is m_encoding_uid as an atomic type.
Definition: Type.h:93
lldb_private::TypeAndOrName
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition: Type.h:410
lldb_private::TypeImpl::CheckExeModule
bool CheckExeModule(lldb::ModuleSP &module_sp) const
Definition: Type.cpp:875
lldb::eMemberFunctionKindInstanceMethod
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
Definition: lldb-enumerations.h:1059
SymbolVendor.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::SymbolFile::GetObjectFile
virtual ObjectFile * GetObjectFile()=0
lldb_private::TypeAndOrName::m_type_name
ConstString m_type_name
Definition: Type.h:448
lldb_private::TypeMemberFunctionImpl::GetDescription
bool GetDescription(Stream &stream)
Definition: Type.cpp:1100
lldb_private::Declaration
Definition: Declaration.h:24
lldb_private::CompilerType::TypeSystemSPWrapper
This is a minimal wrapper of a TypeSystem shared pointer as returned by CompilerType which conventien...
Definition: CompilerType.h:52
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::Type::m_byte_size
uint64_t m_byte_size
Definition: Type.h:217
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
lldb_private::TypeImpl::operator!=
bool operator!=(const TypeImpl &rhs) const
Definition: Type.cpp:913
lldb
Definition: SBAddress.h:15
lldb_private::Type::m_compiler_type
CompilerType m_compiler_type
Definition: Type.h:220
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:360
lldb_private::Type::GetFullCompilerType
CompilerType GetFullCompilerType()
Definition: Type.cpp:657
LLDBLog.h
SymbolFile.h
lldb_private::TypeEnumMemberImpl::TypeEnumMemberImpl
TypeEnumMemberImpl()
Definition: Type.h:490
lldb::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:157
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
ExecutionContext.h
lldb_private::CompilerType::GetRValueReferenceType
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
Definition: CompilerType.cpp:489
lldb_private::Type::GetBaseName
ConstString GetBaseName()
Definition: Type.cpp:309
DataBufferHeap.h
lldb_private::CompilerType::GetFullyUnqualifiedType
CompilerType GetFullyUnqualifiedType() const
Definition: CompilerType.cpp:405
lldb_private::CompilerType::DumpTypeDescription
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
Definition: CompilerType.cpp:856
lldb_private::Type::eEncodingIsUID
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
Definition: Type.h:74
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:208
lldb_private::TypeAndOrName::m_compiler_type
CompilerType m_compiler_type
Definition: Type.h:447
lldb_private::TypeListImpl
Definition: Type.h:328
lldb_private::TypeImpl::m_static_type
CompilerType m_static_type
Definition: Type.h:324
lldb_private::Type::GetNumChildren
uint32_t GetNumChildren(bool omit_empty_base_classes)
Definition: Type.cpp:390
lldb_private::Type::GetTypeScopeAndBasename
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)
Definition: Type.cpp:676