LLDB  mainline
DWARFASTParserClang.cpp
Go to the documentation of this file.
1 //===-- DWARFASTParserClang.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 <cstdlib>
10 
11 #include "DWARFASTParser.h"
12 #include "DWARFASTParserClang.h"
13 #include "DWARFDebugInfo.h"
14 #include "DWARFDeclContext.h"
15 #include "DWARFDefines.h"
16 #include "SymbolFileDWARF.h"
18 #include "SymbolFileDWARFDwo.h"
19 #include "UniqueDWARFASTType.h"
20 
25 #include "lldb/Core/Module.h"
26 #include "lldb/Core/Value.h"
27 #include "lldb/Host/Host.h"
29 #include "lldb/Symbol/Function.h"
30 #include "lldb/Symbol/ObjectFile.h"
31 #include "lldb/Symbol/SymbolFile.h"
32 #include "lldb/Symbol/TypeList.h"
33 #include "lldb/Symbol/TypeMap.h"
34 #include "lldb/Target/Language.h"
36 #include "lldb/Utility/Log.h"
38 
39 #include "llvm/Demangle/Demangle.h"
40 
41 #include "clang/AST/CXXInheritance.h"
42 #include "clang/AST/DeclCXX.h"
43 #include "clang/AST/DeclObjC.h"
44 #include "clang/AST/DeclTemplate.h"
45 
46 #include <map>
47 #include <memory>
48 #include <vector>
49 
50 //#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
51 
52 #ifdef ENABLE_DEBUG_PRINTF
53 #include <cstdio>
54 #define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
55 #else
56 #define DEBUG_PRINTF(fmt, ...)
57 #endif
58 
59 using namespace lldb;
60 using namespace lldb_private;
61 using namespace lldb_private::dwarf;
63  : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
64 
66 
67 static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind) {
68  switch (decl_kind) {
69  case clang::Decl::CXXRecord:
70  case clang::Decl::ClassTemplateSpecialization:
71  return true;
72  default:
73  break;
74  }
75  return false;
76 }
77 
78 
81  m_clang_ast_importer_up = std::make_unique<ClangASTImporter>();
82  }
84 }
85 
86 /// Detect a forward declaration that is nested in a DW_TAG_module.
87 static bool IsClangModuleFwdDecl(const DWARFDIE &Die) {
88  if (!Die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
89  return false;
90  auto Parent = Die.GetParent();
91  while (Parent.IsValid()) {
92  if (Parent.Tag() == DW_TAG_module)
93  return true;
94  Parent = Parent.GetParent();
95  }
96  return false;
97 }
98 
100  if (die.IsValid()) {
101  DWARFDIE top_module_die;
102  // Now make sure this DIE is scoped in a DW_TAG_module tag and return true
103  // if so
104  for (DWARFDIE parent = die.GetParent(); parent.IsValid();
105  parent = parent.GetParent()) {
106  const dw_tag_t tag = parent.Tag();
107  if (tag == DW_TAG_module)
108  top_module_die = parent;
109  else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
110  break;
111  }
112 
113  return top_module_die;
114  }
115  return DWARFDIE();
116 }
117 
118 static lldb::ModuleSP GetContainingClangModule(const DWARFDIE &die) {
119  if (die.IsValid()) {
120  DWARFDIE clang_module_die = GetContainingClangModuleDIE(die);
121 
122  if (clang_module_die) {
123  const char *module_name = clang_module_die.GetName();
124  if (module_name)
125  return die.GetDWARF()->GetExternalModule(
126  lldb_private::ConstString(module_name));
127  }
128  }
129  return lldb::ModuleSP();
130 }
131 
133  const DWARFDIE &die,
134  Log *log) {
135  ModuleSP clang_module_sp = GetContainingClangModule(die);
136  if (!clang_module_sp)
137  return TypeSP();
138 
139  // If this type comes from a Clang module, recursively look in the
140  // DWARF section of the .pcm file in the module cache. Clang
141  // generates DWO skeleton units as breadcrumbs to find them.
142  llvm::SmallVector<CompilerContext, 4> decl_context;
143  die.GetDeclContext(decl_context);
144  TypeMap pcm_types;
145 
146  // The type in the Clang module must have the same language as the current CU.
147  LanguageSet languages;
149  llvm::DenseSet<SymbolFile *> searched_symbol_files;
150  clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
151  searched_symbol_files, pcm_types);
152  if (pcm_types.Empty()) {
153  // Since this type is defined in one of the Clang modules imported
154  // by this symbol file, search all of them. Instead of calling
155  // sym_file->FindTypes(), which would return this again, go straight
156  // to the imported modules.
157  auto &sym_file = die.GetCU()->GetSymbolFileDWARF();
158 
159  // Well-formed clang modules never form cycles; guard against corrupted
160  // ones by inserting the current file.
161  searched_symbol_files.insert(&sym_file);
162  sym_file.ForEachExternalModule(
163  *sc.comp_unit, searched_symbol_files, [&](Module &module) {
164  module.GetSymbolFile()->FindTypes(decl_context, languages,
165  searched_symbol_files, pcm_types);
166  return pcm_types.GetSize();
167  });
168  }
169 
170  if (!pcm_types.GetSize())
171  return TypeSP();
172 
173  // We found a real definition for this type in the Clang module, so lets use
174  // it and cache the fact that we found a complete type for this die.
175  TypeSP pcm_type_sp = pcm_types.GetTypeAtIndex(0);
176  if (!pcm_type_sp)
177  return TypeSP();
178 
179  lldb_private::CompilerType pcm_type = pcm_type_sp->GetForwardCompilerType();
181  GetClangASTImporter().CopyType(m_ast, pcm_type);
182 
183  if (!type)
184  return TypeSP();
185 
186  // Under normal operation pcm_type is a shallow forward declaration
187  // that gets completed later. This is necessary to support cyclic
188  // data structures. If, however, pcm_type is already complete (for
189  // example, because it was loaded for a different target before),
190  // the definition needs to be imported right away, too.
191  // Type::ResolveClangType() effectively ignores the ResolveState
192  // inside type_sp and only looks at IsDefined(), so it never calls
193  // ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(),
194  // which does extra work for Objective-C classes. This would result
195  // in only the forward declaration to be visible.
196  if (pcm_type.IsDefined())
197  GetClangASTImporter().RequireCompleteType(ClangUtil::GetQualType(type));
198 
199  SymbolFileDWARF *dwarf = die.GetDWARF();
200  TypeSP type_sp(new Type(die.GetID(), dwarf, pcm_type_sp->GetName(),
201  pcm_type_sp->GetByteSize(nullptr), nullptr,
203  &pcm_type_sp->GetDeclaration(), type,
204  Type::ResolveState::Forward,
206 
207  dwarf->GetTypeList().Insert(type_sp);
208  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
209  clang::TagDecl *tag_decl = TypeSystemClang::GetAsTagDecl(type);
210  if (tag_decl) {
211  LinkDeclContextToDIE(tag_decl, die);
212  } else {
213  clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(die);
214  if (defn_decl_ctx)
215  LinkDeclContextToDIE(defn_decl_ctx, die);
216  }
217 
218  return type_sp;
219 }
220 
222  bool started = TypeSystemClang::StartTagDeclarationDefinition(type);
223  lldbassert(started && "Unable to start a class type definition.");
224  TypeSystemClang::CompleteTagDeclarationDefinition(type);
225  const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type);
226  auto &ts = llvm::cast<TypeSystemClang>(*type.GetTypeSystem());
227  ts.GetMetadata(td)->SetIsForcefullyCompleted();
228 }
229 
230 /// Complete a type from debug info, or mark it as forcefully completed if
231 /// there is no definition of the type in the current Module. Call this function
232 /// in contexts where the usual C++ rules require a type to be complete (base
233 /// class, member, etc.).
235  // Technically, enums can be incomplete too, but we don't handle those as they
236  // are emitted even under -flimit-debug-info.
237  if (!TypeSystemClang::IsCXXClassType(type))
238  return;
239 
240  if (type.GetCompleteType())
241  return;
242 
243  // No complete definition in this module. Mark the class as complete to
244  // satisfy local ast invariants, but make a note of the fact that
245  // it is not _really_ complete so we can later search for a definition in a
246  // different module.
247  // Since we provide layout assistance, layouts of types containing this class
248  // will be correct even if we are not able to find the definition elsewhere.
250 }
251 
252 /// This function serves a similar purpose as RequireCompleteType above, but it
253 /// avoids completing the type if it is not immediately necessary. It only
254 /// ensures we _can_ complete the type later.
256  ClangASTImporter &ast_importer,
257  clang::DeclContext *decl_ctx,
258  DWARFDIE die,
259  const char *type_name_cstr) {
260  auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
261  if (!tag_decl_ctx)
262  return; // Non-tag context are always ready.
263 
264  // We have already completed the type, or we have found its definition and are
265  // ready to complete it later (cf. ParseStructureLikeDIE).
266  if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
267  return;
268 
269  // We reach this point of the tag was present in the debug info as a
270  // declaration only. If it was imported from another AST context (in the
271  // gmodules case), we can complete the type by doing a full import.
272 
273  // If this type was not imported from an external AST, there's nothing to do.
274  CompilerType type = ast.GetTypeForDecl(tag_decl_ctx);
275  if (type && ast_importer.CanImport(type)) {
276  auto qual_type = ClangUtil::GetQualType(type);
277  if (ast_importer.RequireCompleteType(qual_type))
278  return;
279  die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
280  "Unable to complete the Decl context for DIE '%s' at offset "
281  "0x%8.8x.\nPlease file a bug report.",
282  type_name_cstr ? type_name_cstr : "", die.GetOffset());
283  }
284 
285  // We don't have a type definition and/or the import failed. We must
286  // forcefully complete the type to avoid crashes.
288 }
289 
291  DWARFAttributes attributes;
292  size_t num_attributes = die.GetAttributes(attributes);
293  for (size_t i = 0; i < num_attributes; ++i) {
294  dw_attr_t attr = attributes.AttributeAtIndex(i);
295  DWARFFormValue form_value;
296  if (!attributes.ExtractFormValueAtIndex(i, form_value))
297  continue;
298  switch (attr) {
299  case DW_AT_abstract_origin:
300  abstract_origin = form_value;
301  break;
302 
303  case DW_AT_accessibility:
305  break;
306 
307  case DW_AT_artificial:
308  is_artificial = form_value.Boolean();
309  break;
310 
311  case DW_AT_bit_stride:
312  bit_stride = form_value.Unsigned();
313  break;
314 
315  case DW_AT_byte_size:
316  byte_size = form_value.Unsigned();
317  break;
318 
319  case DW_AT_byte_stride:
320  byte_stride = form_value.Unsigned();
321  break;
322 
323  case DW_AT_calling_convention:
324  calling_convention = form_value.Unsigned();
325  break;
326 
327  case DW_AT_containing_type:
328  containing_type = form_value;
329  break;
330 
331  case DW_AT_decl_file:
332  // die.GetCU() can differ if DW_AT_specification uses DW_FORM_ref_addr.
333  decl.SetFile(
334  attributes.CompileUnitAtIndex(i)->GetFile(form_value.Unsigned()));
335  break;
336  case DW_AT_decl_line:
337  decl.SetLine(form_value.Unsigned());
338  break;
339  case DW_AT_decl_column:
340  decl.SetColumn(form_value.Unsigned());
341  break;
342 
343  case DW_AT_declaration:
344  is_forward_declaration = form_value.Boolean();
345  break;
346 
347  case DW_AT_encoding:
348  encoding = form_value.Unsigned();
349  break;
350 
351  case DW_AT_enum_class:
352  is_scoped_enum = form_value.Boolean();
353  break;
354 
355  case DW_AT_explicit:
356  is_explicit = form_value.Boolean();
357  break;
358 
359  case DW_AT_external:
360  if (form_value.Unsigned())
361  storage = clang::SC_Extern;
362  break;
363 
364  case DW_AT_inline:
365  is_inline = form_value.Boolean();
366  break;
367 
368  case DW_AT_linkage_name:
369  case DW_AT_MIPS_linkage_name:
370  mangled_name = form_value.AsCString();
371  break;
372 
373  case DW_AT_name:
374  name.SetCString(form_value.AsCString());
375  break;
376 
377  case DW_AT_object_pointer:
378  object_pointer = form_value.Reference();
379  break;
380 
381  case DW_AT_signature:
382  signature = form_value;
383  break;
384 
385  case DW_AT_specification:
386  specification = form_value;
387  break;
388 
389  case DW_AT_type:
390  type = form_value;
391  break;
392 
393  case DW_AT_virtuality:
394  is_virtual = form_value.Boolean();
395  break;
396 
397  case DW_AT_APPLE_objc_complete_type:
398  is_complete_objc_class = form_value.Signed();
399  break;
400 
401  case DW_AT_APPLE_objc_direct:
402  is_objc_direct_call = true;
403  break;
404 
405  case DW_AT_APPLE_runtime_class:
406  class_language = (LanguageType)form_value.Signed();
407  break;
408 
409  case DW_AT_GNU_vector:
410  is_vector = form_value.Boolean();
411  break;
412  case DW_AT_export_symbols:
413  exports_symbols = form_value.Boolean();
414  break;
415  }
416  }
417 }
418 
419 static std::string GetUnitName(const DWARFDIE &die) {
420  if (DWARFUnit *unit = die.GetCU())
421  return unit->GetAbsolutePath().GetPath();
422  return "<missing DWARF unit path>";
423 }
424 
426  const DWARFDIE &die,
427  bool *type_is_new_ptr) {
428  if (type_is_new_ptr)
429  *type_is_new_ptr = false;
430 
431  if (!die)
432  return nullptr;
433 
434  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
435 
436  SymbolFileDWARF *dwarf = die.GetDWARF();
437  if (log) {
438  DWARFDIE context_die;
439  clang::DeclContext *context =
440  GetClangDeclContextContainingDIE(die, &context_die);
441 
442  dwarf->GetObjectFile()->GetModule()->LogMessage(
443  log,
444  "DWARFASTParserClang::ParseTypeFromDWARF "
445  "(die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')",
446  die.GetOffset(), static_cast<void *>(context), context_die.GetOffset(),
447  die.GetTagAsCString(), die.GetName());
448  }
449 
450  Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
451  if (type_ptr == DIE_IS_BEING_PARSED)
452  return nullptr;
453  if (type_ptr)
454  return type_ptr->shared_from_this();
455  // Set a bit that lets us know that we are currently parsing this
456  dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
457 
458  ParsedDWARFTypeAttributes attrs(die);
459 
460  if (DWARFDIE signature_die = attrs.signature.Reference()) {
461  if (TypeSP type_sp =
462  ParseTypeFromDWARF(sc, signature_die, type_is_new_ptr)) {
463  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
464  if (clang::DeclContext *decl_ctx =
465  GetCachedClangDeclContextForDIE(signature_die))
466  LinkDeclContextToDIE(decl_ctx, die);
467  return type_sp;
468  }
469  return nullptr;
470  }
471 
472  if (type_is_new_ptr)
473  *type_is_new_ptr = true;
474 
475  const dw_tag_t tag = die.Tag();
476 
477  TypeSP type_sp;
478 
479  switch (tag) {
480  case DW_TAG_typedef:
481  case DW_TAG_base_type:
482  case DW_TAG_pointer_type:
483  case DW_TAG_reference_type:
484  case DW_TAG_rvalue_reference_type:
485  case DW_TAG_const_type:
486  case DW_TAG_restrict_type:
487  case DW_TAG_volatile_type:
488  case DW_TAG_atomic_type:
489  case DW_TAG_unspecified_type: {
490  type_sp = ParseTypeModifier(sc, die, attrs);
491  break;
492  }
493 
494  case DW_TAG_structure_type:
495  case DW_TAG_union_type:
496  case DW_TAG_class_type: {
497  type_sp = ParseStructureLikeDIE(sc, die, attrs);
498  break;
499  }
500 
501  case DW_TAG_enumeration_type: {
502  type_sp = ParseEnum(sc, die, attrs);
503  break;
504  }
505 
506  case DW_TAG_inlined_subroutine:
507  case DW_TAG_subprogram:
508  case DW_TAG_subroutine_type: {
509  type_sp = ParseSubroutine(die, attrs);
510  break;
511  }
512  case DW_TAG_array_type: {
513  type_sp = ParseArrayType(die, attrs);
514  break;
515  }
516  case DW_TAG_ptr_to_member_type: {
517  type_sp = ParsePointerToMemberType(die, attrs);
518  break;
519  }
520  default:
521  dwarf->GetObjectFile()->GetModule()->ReportError(
522  "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
523  "attach the file at the start of this error message",
524  die.GetOffset(), tag, DW_TAG_value_to_name(tag));
525  break;
526  }
527 
528  // TODO: We should consider making the switch above exhaustive to simplify
529  // control flow in ParseTypeFromDWARF. Then, we could simply replace this
530  // return statement with a call to llvm_unreachable.
531  return UpdateSymbolContextScopeForType(sc, die, type_sp);
532 }
533 
534 lldb::TypeSP
536  const DWARFDIE &die,
537  ParsedDWARFTypeAttributes &attrs) {
538  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
539  SymbolFileDWARF *dwarf = die.GetDWARF();
540  const dw_tag_t tag = die.Tag();
541  LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
542  Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
543  Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
544  TypeSP type_sp;
545  CompilerType clang_type;
546 
547  if (tag == DW_TAG_typedef) {
548  // DeclContext will be populated when the clang type is materialized in
549  // Type::ResolveCompilerType.
552  GetClangDeclContextContainingDIE(die, nullptr), die,
553  attrs.name.GetCString());
554 
555  if (attrs.type.IsValid()) {
556  // Try to parse a typedef from the (DWARF embedded in the) Clang
557  // module file first as modules can contain typedef'ed
558  // structures that have no names like:
559  //
560  // typedef struct { int a; } Foo;
561  //
562  // In this case we will have a structure with no name and a
563  // typedef named "Foo" that points to this unnamed
564  // structure. The name in the typedef is the only identifier for
565  // the struct, so always try to get typedefs from Clang modules
566  // if possible.
567  //
568  // The type_sp returned will be empty if the typedef doesn't
569  // exist in a module file, so it is cheap to call this function
570  // just to check.
571  //
572  // If we don't do this we end up creating a TypeSP that says
573  // this is a typedef to type 0x123 (the DW_AT_type value would
574  // be 0x123 in the DW_TAG_typedef), and this is the unnamed
575  // structure type. We will have a hard time tracking down an
576  // unnammed structure type in the module debug info, so we make
577  // sure we don't get into this situation by always resolving
578  // typedefs from the module.
579  const DWARFDIE encoding_die = attrs.type.Reference();
580 
581  // First make sure that the die that this is typedef'ed to _is_
582  // just a declaration (DW_AT_declaration == 1), not a full
583  // definition since template types can't be represented in
584  // modules since only concrete instances of templates are ever
585  // emitted and modules won't contain those
586  if (encoding_die &&
587  encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
588  type_sp = ParseTypeFromClangModule(sc, die, log);
589  if (type_sp)
590  return type_sp;
591  }
592  }
593  }
594 
595  DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(),
596  DW_TAG_value_to_name(tag), type_name_cstr,
597  encoding_uid.Reference());
598 
599  switch (tag) {
600  default:
601  break;
602 
603  case DW_TAG_unspecified_type:
604  if (attrs.name == "nullptr_t" || attrs.name == "decltype(nullptr)") {
605  resolve_state = Type::ResolveState::Full;
606  clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
607  break;
608  }
609  // Fall through to base type below in case we can handle the type
610  // there...
611  [[fallthrough]];
612 
613  case DW_TAG_base_type:
614  resolve_state = Type::ResolveState::Full;
616  attrs.name.GetStringRef(), attrs.encoding,
617  attrs.byte_size.value_or(0) * 8);
618  break;
619 
620  case DW_TAG_pointer_type:
621  encoding_data_type = Type::eEncodingIsPointerUID;
622  break;
623  case DW_TAG_reference_type:
624  encoding_data_type = Type::eEncodingIsLValueReferenceUID;
625  break;
626  case DW_TAG_rvalue_reference_type:
627  encoding_data_type = Type::eEncodingIsRValueReferenceUID;
628  break;
629  case DW_TAG_typedef:
630  encoding_data_type = Type::eEncodingIsTypedefUID;
631  break;
632  case DW_TAG_const_type:
633  encoding_data_type = Type::eEncodingIsConstUID;
634  break;
635  case DW_TAG_restrict_type:
636  encoding_data_type = Type::eEncodingIsRestrictUID;
637  break;
638  case DW_TAG_volatile_type:
639  encoding_data_type = Type::eEncodingIsVolatileUID;
640  break;
641  case DW_TAG_atomic_type:
642  encoding_data_type = Type::eEncodingIsAtomicUID;
643  break;
644  }
645 
646  if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID ||
647  encoding_data_type == Type::eEncodingIsTypedefUID)) {
648  if (tag == DW_TAG_pointer_type) {
649  DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type);
650 
651  if (target_die.GetAttributeValueAsUnsigned(DW_AT_APPLE_block, 0)) {
652  // Blocks have a __FuncPtr inside them which is a pointer to a
653  // function of the proper type.
654 
655  for (DWARFDIE child_die : target_die.children()) {
656  if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name, ""),
657  "__FuncPtr")) {
658  DWARFDIE function_pointer_type =
659  child_die.GetReferencedDIE(DW_AT_type);
660 
661  if (function_pointer_type) {
662  DWARFDIE function_type =
663  function_pointer_type.GetReferencedDIE(DW_AT_type);
664 
665  bool function_type_is_new_pointer;
666  TypeSP lldb_function_type_sp = ParseTypeFromDWARF(
667  sc, function_type, &function_type_is_new_pointer);
668 
669  if (lldb_function_type_sp) {
670  clang_type = m_ast.CreateBlockPointerType(
671  lldb_function_type_sp->GetForwardCompilerType());
672  encoding_data_type = Type::eEncodingIsUID;
673  attrs.type.Clear();
674  resolve_state = Type::ResolveState::Full;
675  }
676  }
677 
678  break;
679  }
680  }
681  }
682  }
683 
684  if (cu_language == eLanguageTypeObjC ||
685  cu_language == eLanguageTypeObjC_plus_plus) {
686  if (attrs.name) {
687  if (attrs.name == "id") {
688  if (log)
689  dwarf->GetObjectFile()->GetModule()->LogMessage(
690  log,
691  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
692  "is Objective-C 'id' built-in type.",
693  die.GetOffset(), die.GetTagAsCString(), die.GetName());
694  clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
695  encoding_data_type = Type::eEncodingIsUID;
696  attrs.type.Clear();
697  resolve_state = Type::ResolveState::Full;
698  } else if (attrs.name == "Class") {
699  if (log)
700  dwarf->GetObjectFile()->GetModule()->LogMessage(
701  log,
702  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
703  "is Objective-C 'Class' built-in type.",
704  die.GetOffset(), die.GetTagAsCString(), die.GetName());
705  clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
706  encoding_data_type = Type::eEncodingIsUID;
707  attrs.type.Clear();
708  resolve_state = Type::ResolveState::Full;
709  } else if (attrs.name == "SEL") {
710  if (log)
711  dwarf->GetObjectFile()->GetModule()->LogMessage(
712  log,
713  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
714  "is Objective-C 'selector' built-in type.",
715  die.GetOffset(), die.GetTagAsCString(), die.GetName());
716  clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
717  encoding_data_type = Type::eEncodingIsUID;
718  attrs.type.Clear();
719  resolve_state = Type::ResolveState::Full;
720  }
721  } else if (encoding_data_type == Type::eEncodingIsPointerUID &&
722  attrs.type.IsValid()) {
723  // Clang sometimes erroneously emits id as objc_object*. In that
724  // case we fix up the type to "id".
725 
726  const DWARFDIE encoding_die = attrs.type.Reference();
727 
728  if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) {
729  llvm::StringRef struct_name = encoding_die.GetName();
730  if (struct_name == "objc_object") {
731  if (log)
732  dwarf->GetObjectFile()->GetModule()->LogMessage(
733  log,
734  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
735  "'%s' is 'objc_object*', which we overrode to "
736  "'id'.",
737  die.GetOffset(), die.GetTagAsCString(), die.GetName());
738  clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
739  encoding_data_type = Type::eEncodingIsUID;
740  attrs.type.Clear();
741  resolve_state = Type::ResolveState::Full;
742  }
743  }
744  }
745  }
746  }
747 
748  type_sp = std::make_shared<Type>(
749  die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
750  dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
751  clang_type, resolve_state, TypePayloadClang(GetOwningClangModule(die)));
752 
753  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
754  return type_sp;
755 }
756 
758  const DWARFDIE &die,
759  ParsedDWARFTypeAttributes &attrs) {
760  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
761  SymbolFileDWARF *dwarf = die.GetDWARF();
762  const dw_tag_t tag = die.Tag();
763  TypeSP type_sp;
764 
765  if (attrs.is_forward_declaration) {
766  type_sp = ParseTypeFromClangModule(sc, die, log);
767  if (type_sp)
768  return type_sp;
769 
771 
772  type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
773 
774  if (!type_sp) {
775  SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
776  if (debug_map_symfile) {
777  // We weren't able to find a full declaration in this DWARF,
778  // see if we have a declaration anywhere else...
779  type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
780  die_decl_ctx);
781  }
782  }
783 
784  if (type_sp) {
785  if (log) {
786  dwarf->GetObjectFile()->GetModule()->LogMessage(
787  log,
788  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
789  "forward declaration, complete type is 0x%8.8" PRIx64,
790  static_cast<void *>(this), die.GetOffset(),
791  DW_TAG_value_to_name(tag), attrs.name.GetCString(),
792  type_sp->GetID());
793  }
794 
795  // We found a real definition for this type elsewhere so lets use
796  // it and cache the fact that we found a complete type for this
797  // die
798  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
799  clang::DeclContext *defn_decl_ctx =
800  GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID()));
801  if (defn_decl_ctx)
802  LinkDeclContextToDIE(defn_decl_ctx, die);
803  return type_sp;
804  }
805  }
806  DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
807  DW_TAG_value_to_name(tag), type_name_cstr);
808 
809  CompilerType enumerator_clang_type;
810  CompilerType clang_type;
811  clang_type.SetCompilerType(
812  &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
813  if (!clang_type) {
814  if (attrs.type.IsValid()) {
815  Type *enumerator_type =
816  dwarf->ResolveTypeUID(attrs.type.Reference(), true);
817  if (enumerator_type)
818  enumerator_clang_type = enumerator_type->GetFullCompilerType();
819  }
820 
821  if (!enumerator_clang_type) {
822  if (attrs.byte_size) {
823  enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
824  "", DW_ATE_signed, *attrs.byte_size * 8);
825  } else {
826  enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
827  }
828  }
829 
830  clang_type = m_ast.CreateEnumerationType(
831  attrs.name.GetStringRef(),
832  GetClangDeclContextContainingDIE(die, nullptr),
833  GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
834  attrs.is_scoped_enum);
835  } else {
836  enumerator_clang_type = m_ast.GetEnumerationIntegerType(clang_type);
837  }
838 
839  LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);
840 
841  type_sp = std::make_shared<Type>(
842  die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
843  dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID, &attrs.decl,
844  clang_type, Type::ResolveState::Forward,
846 
847  if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
848  if (die.HasChildren()) {
849  bool is_signed = false;
850  enumerator_clang_type.IsIntegerType(is_signed);
851  ParseChildEnumerators(clang_type, is_signed,
852  type_sp->GetByteSize(nullptr).value_or(0), die);
853  }
854  TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
855  } else {
856  dwarf->GetObjectFile()->GetModule()->ReportError(
857  "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
858  "definition.\nPlease file a bug and attach the file at the "
859  "start of this error message",
860  die.GetOffset(), attrs.name.GetCString());
861  }
862  return type_sp;
863 }
864 
865 static clang::CallingConv
867  switch (attrs.calling_convention) {
868  case llvm::dwarf::DW_CC_normal:
869  return clang::CC_C;
870  case llvm::dwarf::DW_CC_BORLAND_stdcall:
871  return clang::CC_X86StdCall;
872  case llvm::dwarf::DW_CC_BORLAND_msfastcall:
873  return clang::CC_X86FastCall;
874  case llvm::dwarf::DW_CC_LLVM_vectorcall:
875  return clang::CC_X86VectorCall;
876  case llvm::dwarf::DW_CC_BORLAND_pascal:
877  return clang::CC_X86Pascal;
878  case llvm::dwarf::DW_CC_LLVM_Win64:
879  return clang::CC_Win64;
880  case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
881  return clang::CC_X86_64SysV;
882  case llvm::dwarf::DW_CC_LLVM_X86RegCall:
883  return clang::CC_X86RegCall;
884  default:
885  break;
886  }
887 
888  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
889  LLDB_LOG(log, "Unsupported DW_AT_calling_convention value: {0}",
890  attrs.calling_convention);
891  // Use the default calling convention as a fallback.
892  return clang::CC_C;
893 }
894 
896  ParsedDWARFTypeAttributes &attrs) {
897  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
898 
899  SymbolFileDWARF *dwarf = die.GetDWARF();
900  const dw_tag_t tag = die.Tag();
901 
902  bool is_variadic = false;
903  bool is_static = false;
904  bool has_template_params = false;
905 
906  unsigned type_quals = 0;
907 
908  std::string object_pointer_name;
909  if (attrs.object_pointer) {
910  const char *object_pointer_name_cstr = attrs.object_pointer.GetName();
911  if (object_pointer_name_cstr)
912  object_pointer_name = object_pointer_name_cstr;
913  }
914 
915  DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
916  DW_TAG_value_to_name(tag), type_name_cstr);
917 
918  CompilerType return_clang_type;
919  Type *func_type = nullptr;
920 
921  if (attrs.type.IsValid())
922  func_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
923 
924  if (func_type)
925  return_clang_type = func_type->GetForwardCompilerType();
926  else
927  return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
928 
929  std::vector<CompilerType> function_param_types;
930  std::vector<clang::ParmVarDecl *> function_param_decls;
931 
932  // Parse the function children for the parameters
933 
934  DWARFDIE decl_ctx_die;
935  clang::DeclContext *containing_decl_ctx =
936  GetClangDeclContextContainingDIE(die, &decl_ctx_die);
937  const clang::Decl::Kind containing_decl_kind =
938  containing_decl_ctx->getDeclKind();
939 
940  bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind);
941  // Start off static. This will be set to false in
942  // ParseChildParameters(...) if we find a "this" parameters as the
943  // first parameter
944  if (is_cxx_method) {
945  is_static = true;
946  }
947 
948  if (die.HasChildren()) {
949  bool skip_artificial = true;
950  ParseChildParameters(containing_decl_ctx, die, skip_artificial, is_static,
951  is_variadic, has_template_params,
952  function_param_types, function_param_decls,
953  type_quals);
954  }
955 
956  bool ignore_containing_context = false;
957  // Check for templatized class member functions. If we had any
958  // DW_TAG_template_type_parameter or DW_TAG_template_value_parameter
959  // the DW_TAG_subprogram DIE, then we can't let this become a method in
960  // a class. Why? Because templatized functions are only emitted if one
961  // of the templatized methods is used in the current compile unit and
962  // we will end up with classes that may or may not include these member
963  // functions and this means one class won't match another class
964  // definition and it affects our ability to use a class in the clang
965  // expression parser. So for the greater good, we currently must not
966  // allow any template member functions in a class definition.
967  if (is_cxx_method && has_template_params) {
968  ignore_containing_context = true;
969  is_cxx_method = false;
970  }
971 
972  clang::CallingConv calling_convention =
974 
975  // clang_type will get the function prototype clang type after this
976  // call
978  return_clang_type, function_param_types.data(),
979  function_param_types.size(), is_variadic, type_quals, calling_convention);
980 
981  if (attrs.name) {
982  bool type_handled = false;
983  if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
984  ObjCLanguage::MethodName objc_method(attrs.name.GetStringRef(), true);
985  if (objc_method.IsValid(true)) {
986  CompilerType class_opaque_type;
987  ConstString class_name(objc_method.GetClassName());
988  if (class_name) {
989  TypeSP complete_objc_class_type_sp(
990  dwarf->FindCompleteObjCDefinitionTypeForDIE(DWARFDIE(),
991  class_name, false));
992 
993  if (complete_objc_class_type_sp) {
994  CompilerType type_clang_forward_type =
995  complete_objc_class_type_sp->GetForwardCompilerType();
996  if (TypeSystemClang::IsObjCObjectOrInterfaceType(
997  type_clang_forward_type))
998  class_opaque_type = type_clang_forward_type;
999  }
1000  }
1001 
1002  if (class_opaque_type) {
1003  // If accessibility isn't set to anything valid, assume public
1004  // for now...
1005  if (attrs.accessibility == eAccessNone)
1006  attrs.accessibility = eAccessPublic;
1007 
1008  clang::ObjCMethodDecl *objc_method_decl =
1010  class_opaque_type, attrs.name.GetCString(), clang_type,
1011  attrs.accessibility, attrs.is_artificial, is_variadic,
1012  attrs.is_objc_direct_call);
1013  type_handled = objc_method_decl != nullptr;
1014  if (type_handled) {
1015  LinkDeclContextToDIE(objc_method_decl, die);
1016  m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
1017  } else {
1018  dwarf->GetObjectFile()->GetModule()->ReportError(
1019  "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
1020  "please file a bug and attach the file at the start of "
1021  "this error message",
1022  die.GetOffset(), tag, DW_TAG_value_to_name(tag));
1023  }
1024  }
1025  } else if (is_cxx_method) {
1026  // Look at the parent of this DIE and see if is is a class or
1027  // struct and see if this is actually a C++ method
1028  Type *class_type = dwarf->ResolveType(decl_ctx_die);
1029  if (class_type) {
1030  if (class_type->GetID() != decl_ctx_die.GetID() ||
1031  IsClangModuleFwdDecl(decl_ctx_die)) {
1032 
1033  // We uniqued the parent class of this function to another
1034  // class so we now need to associate all dies under
1035  // "decl_ctx_die" to DIEs in the DIE for "class_type"...
1036  DWARFDIE class_type_die = dwarf->GetDIE(class_type->GetID());
1037 
1038  if (class_type_die) {
1039  std::vector<DWARFDIE> failures;
1040 
1041  CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
1042  class_type, failures);
1043 
1044  // FIXME do something with these failures that's
1045  // smarter than just dropping them on the ground.
1046  // Unfortunately classes don't like having stuff added
1047  // to them after their definitions are complete...
1048 
1049  Type *type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
1050  if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
1051  return type_ptr->shared_from_this();
1052  }
1053  }
1054  }
1055 
1056  if (attrs.specification.IsValid()) {
1057  // We have a specification which we are going to base our
1058  // function prototype off of, so we need this type to be
1059  // completed so that the m_die_to_decl_ctx for the method in
1060  // the specification has a valid clang decl context.
1061  class_type->GetForwardCompilerType();
1062  // If we have a specification, then the function type should
1063  // have been made with the specification and not with this
1064  // die.
1065  DWARFDIE spec_die = attrs.specification.Reference();
1066  clang::DeclContext *spec_clang_decl_ctx =
1067  GetClangDeclContextForDIE(spec_die);
1068  if (spec_clang_decl_ctx) {
1069  LinkDeclContextToDIE(spec_clang_decl_ctx, die);
1070  } else {
1071  dwarf->GetObjectFile()->GetModule()->ReportWarning(
1072  "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x"
1073  ") has no decl\n",
1074  die.GetID(), spec_die.GetOffset());
1075  }
1076  type_handled = true;
1077  } else if (attrs.abstract_origin.IsValid()) {
1078  // We have a specification which we are going to base our
1079  // function prototype off of, so we need this type to be
1080  // completed so that the m_die_to_decl_ctx for the method in
1081  // the abstract origin has a valid clang decl context.
1082  class_type->GetForwardCompilerType();
1083 
1084  DWARFDIE abs_die = attrs.abstract_origin.Reference();
1085  clang::DeclContext *abs_clang_decl_ctx =
1086  GetClangDeclContextForDIE(abs_die);
1087  if (abs_clang_decl_ctx) {
1088  LinkDeclContextToDIE(abs_clang_decl_ctx, die);
1089  } else {
1090  dwarf->GetObjectFile()->GetModule()->ReportWarning(
1091  "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x"
1092  ") has no decl\n",
1093  die.GetID(), abs_die.GetOffset());
1094  }
1095  type_handled = true;
1096  } else {
1097  CompilerType class_opaque_type =
1098  class_type->GetForwardCompilerType();
1099  if (TypeSystemClang::IsCXXClassType(class_opaque_type)) {
1100  if (class_opaque_type.IsBeingDefined()) {
1101  if (!is_static && !die.HasChildren()) {
1102  // We have a C++ member function with no children (this
1103  // pointer!) and clang will get mad if we try and make
1104  // a function that isn't well formed in the DWARF, so
1105  // we will just skip it...
1106  type_handled = true;
1107  } else {
1108  llvm::PrettyStackTraceFormat stack_trace(
1109  "SymbolFileDWARF::ParseType() is adding a method "
1110  "%s to class %s in DIE 0x%8.8" PRIx64 " from %s",
1111  attrs.name.GetCString(),
1112  class_type->GetName().GetCString(), die.GetID(),
1113  dwarf->GetObjectFile()->GetFileSpec().GetPath().c_str());
1114 
1115  const bool is_attr_used = false;
1116  // Neither GCC 4.2 nor clang++ currently set a valid
1117  // accessibility in the DWARF for C++ methods...
1118  // Default to public for now...
1119  if (attrs.accessibility == eAccessNone)
1120  attrs.accessibility = eAccessPublic;
1121 
1122  clang::CXXMethodDecl *cxx_method_decl =
1124  class_opaque_type.GetOpaqueQualType(),
1125  attrs.name.GetCString(), attrs.mangled_name,
1126  clang_type, attrs.accessibility, attrs.is_virtual,
1127  is_static, attrs.is_inline, attrs.is_explicit,
1128  is_attr_used, attrs.is_artificial);
1129 
1130  type_handled = cxx_method_decl != nullptr;
1131  // Artificial methods are always handled even when we
1132  // don't create a new declaration for them.
1133  type_handled |= attrs.is_artificial;
1134 
1135  if (cxx_method_decl) {
1136  LinkDeclContextToDIE(cxx_method_decl, die);
1137 
1138  ClangASTMetadata metadata;
1139  metadata.SetUserID(die.GetID());
1140 
1141  if (!object_pointer_name.empty()) {
1142  metadata.SetObjectPtrName(object_pointer_name.c_str());
1143  LLDB_LOGF(log,
1144  "Setting object pointer name: %s on method "
1145  "object %p.\n",
1146  object_pointer_name.c_str(),
1147  static_cast<void *>(cxx_method_decl));
1148  }
1149  m_ast.SetMetadata(cxx_method_decl, metadata);
1150  } else {
1151  ignore_containing_context = true;
1152  }
1153  }
1154  } else {
1155  // We were asked to parse the type for a method in a
1156  // class, yet the class hasn't been asked to complete
1157  // itself through the clang::ExternalASTSource protocol,
1158  // so we need to just have the class complete itself and
1159  // do things the right way, then our
1160  // DIE should then have an entry in the
1161  // dwarf->GetDIEToType() map. First
1162  // we need to modify the dwarf->GetDIEToType() so it
1163  // doesn't think we are trying to parse this DIE
1164  // anymore...
1165  dwarf->GetDIEToType()[die.GetDIE()] = NULL;
1166 
1167  // Now we get the full type to force our class type to
1168  // complete itself using the clang::ExternalASTSource
1169  // protocol which will parse all base classes and all
1170  // methods (including the method for this DIE).
1171  class_type->GetFullCompilerType();
1172 
1173  // The type for this DIE should have been filled in the
1174  // function call above
1175  Type *type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
1176  if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
1177  return type_ptr->shared_from_this();
1178  }
1179 
1180  // FIXME This is fixing some even uglier behavior but we
1181  // really need to
1182  // uniq the methods of each class as well as the class
1183  // itself. <rdar://problem/11240464>
1184  type_handled = true;
1185  }
1186  }
1187  }
1188  }
1189  }
1190  }
1191 
1192  if (!type_handled) {
1193  clang::FunctionDecl *function_decl = nullptr;
1194  clang::FunctionDecl *template_function_decl = nullptr;
1195 
1196  if (attrs.abstract_origin.IsValid()) {
1197  DWARFDIE abs_die = attrs.abstract_origin.Reference();
1198 
1199  if (dwarf->ResolveType(abs_die)) {
1200  function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1202 
1203  if (function_decl) {
1204  LinkDeclContextToDIE(function_decl, die);
1205  }
1206  }
1207  }
1208 
1209  if (!function_decl) {
1210  char *name_buf = nullptr;
1211  llvm::StringRef name = attrs.name.GetStringRef();
1212 
1213  // We currently generate function templates with template parameters in
1214  // their name. In order to get closer to the AST that clang generates
1215  // we want to strip these from the name when creating the AST.
1216  if (attrs.mangled_name) {
1217  llvm::ItaniumPartialDemangler D;
1218  if (!D.partialDemangle(attrs.mangled_name)) {
1219  name_buf = D.getFunctionBaseName(nullptr, nullptr);
1220  name = name_buf;
1221  }
1222  }
1223 
1224  // We just have a function that isn't part of a class
1225  function_decl = m_ast.CreateFunctionDeclaration(
1226  ignore_containing_context ? m_ast.GetTranslationUnitDecl()
1227  : containing_decl_ctx,
1228  GetOwningClangModule(die), name, clang_type, attrs.storage,
1229  attrs.is_inline);
1230  std::free(name_buf);
1231 
1232  if (has_template_params) {
1233  TypeSystemClang::TemplateParameterInfos template_param_infos;
1234  ParseTemplateParameterInfos(die, template_param_infos);
1235  template_function_decl = m_ast.CreateFunctionDeclaration(
1236  ignore_containing_context ? m_ast.GetTranslationUnitDecl()
1237  : containing_decl_ctx,
1238  GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type,
1239  attrs.storage, attrs.is_inline);
1240  clang::FunctionTemplateDecl *func_template_decl =
1242  containing_decl_ctx, GetOwningClangModule(die),
1243  template_function_decl, template_param_infos);
1245  template_function_decl, func_template_decl, template_param_infos);
1246  }
1247 
1248  lldbassert(function_decl);
1249 
1250  if (function_decl) {
1251  // Attach an asm(<mangled_name>) label to the FunctionDecl.
1252  // This ensures that clang::CodeGen emits function calls
1253  // using symbols that are mangled according to the DW_AT_linkage_name.
1254  // If we didn't do this, the external symbols wouldn't exactly
1255  // match the mangled name LLDB knows about and the IRExecutionUnit
1256  // would have to fall back to searching object files for
1257  // approximately matching function names. The motivating
1258  // example is generating calls to ABI-tagged template functions.
1259  // This is done separately for member functions in
1260  // AddMethodToCXXRecordType.
1261  if (attrs.mangled_name)
1262  function_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
1263  m_ast.getASTContext(), attrs.mangled_name, /*literal=*/false));
1264 
1265  LinkDeclContextToDIE(function_decl, die);
1266 
1267  if (!function_param_decls.empty()) {
1268  m_ast.SetFunctionParameters(function_decl, function_param_decls);
1269  if (template_function_decl)
1270  m_ast.SetFunctionParameters(template_function_decl,
1271  function_param_decls);
1272  }
1273 
1274  ClangASTMetadata metadata;
1275  metadata.SetUserID(die.GetID());
1276 
1277  if (!object_pointer_name.empty()) {
1278  metadata.SetObjectPtrName(object_pointer_name.c_str());
1279  LLDB_LOGF(log,
1280  "Setting object pointer name: %s on function "
1281  "object %p.",
1282  object_pointer_name.c_str(),
1283  static_cast<void *>(function_decl));
1284  }
1285  m_ast.SetMetadata(function_decl, metadata);
1286  }
1287  }
1288  }
1289  }
1290  return std::make_shared<Type>(
1291  die.GetID(), dwarf, attrs.name, llvm::None, nullptr, LLDB_INVALID_UID,
1292  Type::eEncodingIsUID, &attrs.decl, clang_type, Type::ResolveState::Full);
1293 }
1294 
1295 TypeSP
1297  const ParsedDWARFTypeAttributes &attrs) {
1298  SymbolFileDWARF *dwarf = die.GetDWARF();
1299 
1300  DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
1301  DW_TAG_value_to_name(tag), type_name_cstr);
1302 
1303  DWARFDIE type_die = attrs.type.Reference();
1304  Type *element_type = dwarf->ResolveTypeUID(type_die, true);
1305 
1306  if (!element_type)
1307  return nullptr;
1308 
1309  llvm::Optional<SymbolFile::ArrayInfo> array_info = ParseChildArrayInfo(die);
1310  uint32_t byte_stride = attrs.byte_stride;
1311  uint32_t bit_stride = attrs.bit_stride;
1312  if (array_info) {
1313  byte_stride = array_info->byte_stride;
1314  bit_stride = array_info->bit_stride;
1315  }
1316  if (byte_stride == 0 && bit_stride == 0)
1317  byte_stride = element_type->GetByteSize(nullptr).value_or(0);
1318  CompilerType array_element_type = element_type->GetForwardCompilerType();
1319  RequireCompleteType(array_element_type);
1320 
1321  uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1322  CompilerType clang_type;
1323  if (array_info && array_info->element_orders.size() > 0) {
1324  uint64_t num_elements = 0;
1325  auto end = array_info->element_orders.rend();
1326  for (auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1327  num_elements = *pos;
1328  clang_type = m_ast.CreateArrayType(array_element_type, num_elements,
1329  attrs.is_vector);
1330  array_element_type = clang_type;
1331  array_element_bit_stride = num_elements
1332  ? array_element_bit_stride * num_elements
1333  : array_element_bit_stride;
1334  }
1335  } else {
1336  clang_type =
1337  m_ast.CreateArrayType(array_element_type, 0, attrs.is_vector);
1338  }
1339  ConstString empty_name;
1340  TypeSP type_sp = std::make_shared<Type>(
1341  die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, nullptr,
1342  dwarf->GetUID(type_die), Type::eEncodingIsUID, &attrs.decl, clang_type,
1343  Type::ResolveState::Full);
1344  type_sp->SetEncodingType(element_type);
1345  const clang::Type *type = ClangUtil::GetQualType(clang_type).getTypePtr();
1346  m_ast.SetMetadataAsUserID(type, die.GetID());
1347  return type_sp;
1348 }
1349 
1351  const DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs) {
1352  SymbolFileDWARF *dwarf = die.GetDWARF();
1353  Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
1354  Type *class_type =
1355  dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true);
1356 
1357  CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType();
1358  CompilerType class_clang_type = class_type->GetForwardCompilerType();
1359 
1360  CompilerType clang_type = TypeSystemClang::CreateMemberPointerType(
1361  class_clang_type, pointee_clang_type);
1362 
1363  if (llvm::Optional<uint64_t> clang_type_size =
1364  clang_type.GetByteSize(nullptr)) {
1365  return std::make_shared<Type>(die.GetID(), dwarf, attrs.name,
1366  *clang_type_size, nullptr, LLDB_INVALID_UID,
1367  Type::eEncodingIsUID, nullptr, clang_type,
1368  Type::ResolveState::Forward);
1369  }
1370  return nullptr;
1371 }
1372 
1374  const DWARFDIE &die, const DWARFDIE &parent_die,
1375  const CompilerType class_clang_type, const AccessType default_accessibility,
1376  const lldb::ModuleSP &module_sp,
1377  std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1378  ClangASTImporter::LayoutInfo &layout_info) {
1379 
1380  TypeSystemClang *ast =
1381  llvm::dyn_cast_or_null<TypeSystemClang>(class_clang_type.GetTypeSystem());
1382  if (ast == nullptr)
1383  return;
1384 
1385  // TODO: implement DW_TAG_inheritance type parsing.
1386  DWARFAttributes attributes;
1387  const size_t num_attributes = die.GetAttributes(attributes);
1388  if (num_attributes == 0)
1389  return;
1390 
1391  DWARFFormValue encoding_form;
1392  AccessType accessibility = default_accessibility;
1393  bool is_virtual = false;
1394  bool is_base_of_class = true;
1395  off_t member_byte_offset = 0;
1396 
1397  for (uint32_t i = 0; i < num_attributes; ++i) {
1398  const dw_attr_t attr = attributes.AttributeAtIndex(i);
1399  DWARFFormValue form_value;
1400  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
1401  switch (attr) {
1402  case DW_AT_type:
1403  encoding_form = form_value;
1404  break;
1405  case DW_AT_data_member_location:
1406  if (form_value.BlockData()) {
1407  Value initialValue(0);
1408  Value memberOffset(0);
1409  const DWARFDataExtractor &debug_info_data = die.GetData();
1410  uint32_t block_length = form_value.Unsigned();
1411  uint32_t block_offset =
1412  form_value.BlockData() - debug_info_data.GetDataStart();
1413  if (DWARFExpression::Evaluate(
1414  nullptr, nullptr, module_sp,
1415  DataExtractor(debug_info_data, block_offset, block_length),
1416  die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
1417  memberOffset, nullptr)) {
1418  member_byte_offset = memberOffset.ResolveValue(nullptr).UInt();
1419  }
1420  } else {
1421  // With DWARF 3 and later, if the value is an integer constant,
1422  // this form value is the offset in bytes from the beginning of
1423  // the containing entity.
1424  member_byte_offset = form_value.Unsigned();
1425  }
1426  break;
1427 
1428  case DW_AT_accessibility:
1429  accessibility = DWARFASTParser::GetAccessTypeFromDWARF(form_value.Unsigned());
1430  break;
1431 
1432  case DW_AT_virtuality:
1433  is_virtual = form_value.Boolean();
1434  break;
1435 
1436  default:
1437  break;
1438  }
1439  }
1440  }
1441 
1442  Type *base_class_type = die.ResolveTypeUID(encoding_form.Reference());
1443  if (base_class_type == nullptr) {
1444  module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to "
1445  "resolve the base class at 0x%8.8x"
1446  " from enclosing type 0x%8.8x. \nPlease file "
1447  "a bug and attach the file at the start of "
1448  "this error message",
1449  die.GetOffset(),
1450  encoding_form.Reference().GetOffset(),
1451  parent_die.GetOffset());
1452  return;
1453  }
1454 
1455  CompilerType base_class_clang_type = base_class_type->GetFullCompilerType();
1456  assert(base_class_clang_type);
1457  if (TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type)) {
1458  ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1459  return;
1460  }
1461  std::unique_ptr<clang::CXXBaseSpecifier> result =
1462  ast->CreateBaseClassSpecifier(base_class_clang_type.GetOpaqueQualType(),
1463  accessibility, is_virtual,
1464  is_base_of_class);
1465  if (!result)
1466  return;
1467 
1468  base_classes.push_back(std::move(result));
1469 
1470  if (is_virtual) {
1471  // Do not specify any offset for virtual inheritance. The DWARF
1472  // produced by clang doesn't give us a constant offset, but gives
1473  // us a DWARF expressions that requires an actual object in memory.
1474  // the DW_AT_data_member_location for a virtual base class looks
1475  // like:
1476  // DW_AT_data_member_location( DW_OP_dup, DW_OP_deref,
1477  // DW_OP_constu(0x00000018), DW_OP_minus, DW_OP_deref,
1478  // DW_OP_plus )
1479  // Given this, there is really no valid response we can give to
1480  // clang for virtual base class offsets, and this should eventually
1481  // be removed from LayoutRecordType() in the external
1482  // AST source in clang.
1483  } else {
1484  layout_info.base_offsets.insert(std::make_pair(
1485  ast->GetAsCXXRecordDecl(base_class_clang_type.GetOpaqueQualType()),
1486  clang::CharUnits::fromQuantity(member_byte_offset)));
1487  }
1488 }
1489 
1491  const SymbolContext &sc, const DWARFDIE &die, TypeSP type_sp) {
1492  if (!type_sp)
1493  return type_sp;
1494 
1495  SymbolFileDWARF *dwarf = die.GetDWARF();
1497  dw_tag_t sc_parent_tag = sc_parent_die.Tag();
1498 
1499  SymbolContextScope *symbol_context_scope = nullptr;
1500  if (sc_parent_tag == DW_TAG_compile_unit ||
1501  sc_parent_tag == DW_TAG_partial_unit) {
1502  symbol_context_scope = sc.comp_unit;
1503  } else if (sc.function != nullptr && sc_parent_die) {
1504  symbol_context_scope =
1505  sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
1506  if (symbol_context_scope == nullptr)
1507  symbol_context_scope = sc.function;
1508  } else {
1509  symbol_context_scope = sc.module_sp.get();
1510  }
1511 
1512  if (symbol_context_scope != nullptr)
1513  type_sp->SetSymbolContextScope(symbol_context_scope);
1514 
1515  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
1516  return type_sp;
1517 }
1518 
1519 TypeSP
1521  const DWARFDIE &die,
1522  ParsedDWARFTypeAttributes &attrs) {
1523  TypeSP type_sp;
1524  CompilerType clang_type;
1525  const dw_tag_t tag = die.Tag();
1526  SymbolFileDWARF *dwarf = die.GetDWARF();
1527  LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
1528  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1529 
1530  // UniqueDWARFASTType is large, so don't create a local variables on the
1531  // stack, put it on the heap. This function is often called recursively and
1532  // clang isn't good at sharing the stack space for variables in different
1533  // blocks.
1534  auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1535 
1536  ConstString unique_typename(attrs.name);
1537  Declaration unique_decl(attrs.decl);
1538 
1539  if (attrs.name) {
1540  if (Language::LanguageIsCPlusPlus(cu_language)) {
1541  // For C++, we rely solely upon the one definition rule that says
1542  // only one thing can exist at a given decl context. We ignore the
1543  // file and line that things are declared on.
1544  std::string qualified_name;
1545  if (die.GetQualifiedName(qualified_name))
1546  unique_typename = ConstString(qualified_name);
1547  unique_decl.Clear();
1548  }
1549 
1550  if (dwarf->GetUniqueDWARFASTTypeMap().Find(
1551  unique_typename, die, unique_decl, attrs.byte_size.value_or(-1),
1552  *unique_ast_entry_up)) {
1553  type_sp = unique_ast_entry_up->m_type_sp;
1554  if (type_sp) {
1555  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
1557  GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), die);
1558  return type_sp;
1559  }
1560  }
1561  }
1562 
1563  DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
1564  DW_TAG_value_to_name(tag), type_name_cstr);
1565 
1566  int tag_decl_kind = -1;
1567  AccessType default_accessibility = eAccessNone;
1568  if (tag == DW_TAG_structure_type) {
1569  tag_decl_kind = clang::TTK_Struct;
1570  default_accessibility = eAccessPublic;
1571  } else if (tag == DW_TAG_union_type) {
1572  tag_decl_kind = clang::TTK_Union;
1573  default_accessibility = eAccessPublic;
1574  } else if (tag == DW_TAG_class_type) {
1575  tag_decl_kind = clang::TTK_Class;
1576  default_accessibility = eAccessPrivate;
1577  }
1578 
1579  if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name &&
1580  !die.HasChildren() && cu_language == eLanguageTypeObjC) {
1581  // Work around an issue with clang at the moment where forward
1582  // declarations for objective C classes are emitted as:
1583  // DW_TAG_structure_type [2]
1584  // DW_AT_name( "ForwardObjcClass" )
1585  // DW_AT_byte_size( 0x00 )
1586  // DW_AT_decl_file( "..." )
1587  // DW_AT_decl_line( 1 )
1588  //
1589  // Note that there is no DW_AT_declaration and there are no children,
1590  // and the byte size is zero.
1591  attrs.is_forward_declaration = true;
1592  }
1593 
1594  if (attrs.class_language == eLanguageTypeObjC ||
1596  if (!attrs.is_complete_objc_class &&
1598  // We have a valid eSymbolTypeObjCClass class symbol whose name
1599  // matches the current objective C class that we are trying to find
1600  // and this DIE isn't the complete definition (we checked
1601  // is_complete_objc_class above and know it is false), so the real
1602  // definition is in here somewhere
1603  type_sp =
1604  dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.name, true);
1605 
1606  if (!type_sp) {
1607  SymbolFileDWARFDebugMap *debug_map_symfile =
1608  dwarf->GetDebugMapSymfile();
1609  if (debug_map_symfile) {
1610  // We weren't able to find a full declaration in this DWARF,
1611  // see if we have a declaration anywhere else...
1612  type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE(
1613  die, attrs.name, true);
1614  }
1615  }
1616 
1617  if (type_sp) {
1618  if (log) {
1619  dwarf->GetObjectFile()->GetModule()->LogMessage(
1620  log,
1621  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
1622  "incomplete objc type, complete type is 0x%8.8" PRIx64,
1623  static_cast<void *>(this), die.GetOffset(),
1624  DW_TAG_value_to_name(tag), attrs.name.GetCString(),
1625  type_sp->GetID());
1626  }
1627 
1628  // We found a real definition for this type elsewhere so lets use
1629  // it and cache the fact that we found a complete type for this
1630  // die
1631  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
1632  return type_sp;
1633  }
1634  }
1635  }
1636 
1637  if (attrs.is_forward_declaration) {
1638  // We have a forward declaration to a type and we need to try and
1639  // find a full declaration. We look in the current type index just in
1640  // case we have a forward declaration followed by an actual
1641  // declarations in the DWARF. If this fails, we need to look
1642  // elsewhere...
1643  if (log) {
1644  dwarf->GetObjectFile()->GetModule()->LogMessage(
1645  log,
1646  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
1647  "forward declaration, trying to find complete type",
1648  static_cast<void *>(this), die.GetOffset(), DW_TAG_value_to_name(tag),
1649  attrs.name.GetCString());
1650  }
1651 
1652  // See if the type comes from a Clang module and if so, track down
1653  // that type.
1654  type_sp = ParseTypeFromClangModule(sc, die, log);
1655  if (type_sp)
1656  return type_sp;
1657 
1659 
1660  // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
1661  // type_name_const_str);
1662  type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
1663 
1664  if (!type_sp) {
1665  SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
1666  if (debug_map_symfile) {
1667  // We weren't able to find a full declaration in this DWARF, see
1668  // if we have a declaration anywhere else...
1669  type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
1670  die_decl_ctx);
1671  }
1672  }
1673 
1674  if (type_sp) {
1675  if (log) {
1676  dwarf->GetObjectFile()->GetModule()->LogMessage(
1677  log,
1678  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
1679  "forward declaration, complete type is 0x%8.8" PRIx64,
1680  static_cast<void *>(this), die.GetOffset(),
1681  DW_TAG_value_to_name(tag), attrs.name.GetCString(),
1682  type_sp->GetID());
1683  }
1684 
1685  // We found a real definition for this type elsewhere so lets use
1686  // it and cache the fact that we found a complete type for this die
1687  dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
1688  clang::DeclContext *defn_decl_ctx =
1689  GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID()));
1690  if (defn_decl_ctx)
1691  LinkDeclContextToDIE(defn_decl_ctx, die);
1692  return type_sp;
1693  }
1694  }
1695  assert(tag_decl_kind != -1);
1696  (void)tag_decl_kind;
1697  bool clang_type_was_created = false;
1698  clang_type.SetCompilerType(
1699  &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
1700  if (!clang_type) {
1701  clang::DeclContext *decl_ctx =
1702  GetClangDeclContextContainingDIE(die, nullptr);
1703 
1705  attrs.name.GetCString());
1706 
1707  if (attrs.accessibility == eAccessNone && decl_ctx) {
1708  // Check the decl context that contains this class/struct/union. If
1709  // it is a class we must give it an accessibility.
1710  const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
1711  if (DeclKindIsCXXClass(containing_decl_kind))
1712  attrs.accessibility = default_accessibility;
1713  }
1714 
1715  ClangASTMetadata metadata;
1716  metadata.SetUserID(die.GetID());
1717  metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
1718 
1719  if (attrs.name.GetStringRef().contains('<')) {
1720  TypeSystemClang::TemplateParameterInfos template_param_infos;
1721  if (ParseTemplateParameterInfos(die, template_param_infos)) {
1722  clang::ClassTemplateDecl *class_template_decl =
1724  decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1725  attrs.name.GetCString(), tag_decl_kind, template_param_infos);
1726  if (!class_template_decl) {
1727  if (log) {
1728  dwarf->GetObjectFile()->GetModule()->LogMessage(
1729  log,
1730  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
1731  "clang::ClassTemplateDecl failed to return a decl.",
1732  static_cast<void *>(this), die.GetOffset(),
1733  DW_TAG_value_to_name(tag), attrs.name.GetCString());
1734  }
1735  return TypeSP();
1736  }
1737 
1738  clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1740  decl_ctx, GetOwningClangModule(die), class_template_decl,
1741  tag_decl_kind, template_param_infos);
1743  class_specialization_decl);
1744  clang_type_was_created = true;
1745 
1746  m_ast.SetMetadata(class_template_decl, metadata);
1747  m_ast.SetMetadata(class_specialization_decl, metadata);
1748  }
1749  }
1750 
1751  if (!clang_type_was_created) {
1752  clang_type_was_created = true;
1753  clang_type = m_ast.CreateRecordType(
1754  decl_ctx, GetOwningClangModule(die), attrs.accessibility,
1755  attrs.name.GetCString(), tag_decl_kind, attrs.class_language,
1756  &metadata, attrs.exports_symbols);
1757  }
1758  }
1759 
1760  // Store a forward declaration to this class type in case any
1761  // parameters in any class methods need it for the clang types for
1762  // function prototypes.
1764  type_sp = std::make_shared<Type>(
1765  die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
1766  LLDB_INVALID_UID, Type::eEncodingIsUID, &attrs.decl, clang_type,
1767  Type::ResolveState::Forward,
1769 
1770  // Add our type to the unique type map so we don't end up creating many
1771  // copies of the same type over and over in the ASTContext for our
1772  // module
1773  unique_ast_entry_up->m_type_sp = type_sp;
1774  unique_ast_entry_up->m_die = die;
1775  unique_ast_entry_up->m_declaration = unique_decl;
1776  unique_ast_entry_up->m_byte_size = attrs.byte_size.value_or(0);
1777  dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1778  *unique_ast_entry_up);
1779 
1780  if (!attrs.is_forward_declaration) {
1781  // Always start the definition for a class type so that if the class
1782  // has child classes or types that require the class to be created
1783  // for use as their decl contexts the class will be ready to accept
1784  // these child definitions.
1785  if (!die.HasChildren()) {
1786  // No children for this struct/union/class, lets finish it
1787  if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
1788  TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
1789  } else {
1790  dwarf->GetObjectFile()->GetModule()->ReportError(
1791  "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
1792  "definition.\nPlease file a bug and attach the file at the "
1793  "start of this error message",
1794  die.GetOffset(), attrs.name.GetCString());
1795  }
1796 
1797  // If the byte size of the record is specified then overwrite the size
1798  // that would be computed by Clang. This is only needed as LLDB's
1799  // TypeSystemClang is always in C++ mode, but some compilers such as
1800  // GCC and Clang give empty structs a size of 0 in C mode (in contrast to
1801  // the size of 1 for empty structs that would be computed in C++ mode).
1802  if (attrs.byte_size) {
1803  clang::RecordDecl *record_decl =
1804  TypeSystemClang::GetAsRecordDecl(clang_type);
1805  if (record_decl) {
1807  layout.bit_size = *attrs.byte_size * 8;
1808  GetClangASTImporter().SetRecordLayout(record_decl, layout);
1809  }
1810  }
1811  } else if (clang_type_was_created) {
1812  // Start the definition if the class is not objective C since the
1813  // underlying decls respond to isCompleteDefinition(). Objective
1814  // C decls don't respond to isCompleteDefinition() so we can't
1815  // start the declaration definition right away. For C++
1816  // class/union/structs we want to start the definition in case the
1817  // class is needed as the declaration context for a contained class
1818  // or type without the need to complete that type..
1819 
1820  if (attrs.class_language != eLanguageTypeObjC &&
1822  TypeSystemClang::StartTagDeclarationDefinition(clang_type);
1823 
1824  // Leave this as a forward declaration until we need to know the
1825  // details of the type. lldb_private::Type will automatically call
1826  // the SymbolFile virtual function
1827  // "SymbolFileDWARF::CompleteType(Type *)" When the definition
1828  // needs to be defined.
1829  assert(!dwarf->GetForwardDeclClangTypeToDie().count(
1830  ClangUtil::RemoveFastQualifiers(clang_type)
1831  .GetOpaqueQualType()) &&
1832  "Type already in the forward declaration map!");
1833  // Can't assume m_ast.GetSymbolFile() is actually a
1834  // SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
1835  // binaries.
1836  dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
1837  clang_type.GetOpaqueQualType();
1838  dwarf->GetForwardDeclClangTypeToDie().try_emplace(
1839  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
1840  *die.GetDIERef());
1841  m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
1842  }
1843  }
1844 
1845  // If we made a clang type, set the trivial abi if applicable: We only
1846  // do this for pass by value - which implies the Trivial ABI. There
1847  // isn't a way to assert that something that would normally be pass by
1848  // value is pass by reference, so we ignore that attribute if set.
1849  if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_value) {
1850  clang::CXXRecordDecl *record_decl =
1852  if (record_decl && record_decl->getDefinition()) {
1853  record_decl->setHasTrivialSpecialMemberForCall();
1854  }
1855  }
1856 
1857  if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_reference) {
1858  clang::CXXRecordDecl *record_decl =
1860  if (record_decl)
1861  record_decl->setArgPassingRestrictions(
1862  clang::RecordDecl::APK_CannotPassInRegs);
1863  }
1864  return type_sp;
1865 }
1866 
1867 // DWARF parsing functions
1868 
1870 public:
1872  const CompilerType &class_opaque_type, const char *property_name,
1873  const CompilerType &property_opaque_type, // The property type is only
1874  // required if you don't have an
1875  // ivar decl
1876  const char *property_setter_name, const char *property_getter_name,
1877  uint32_t property_attributes, const ClangASTMetadata *metadata)
1878  : m_class_opaque_type(class_opaque_type), m_property_name(property_name),
1879  m_property_opaque_type(property_opaque_type),
1880  m_property_setter_name(property_setter_name),
1881  m_property_getter_name(property_getter_name),
1882  m_property_attributes(property_attributes) {
1883  if (metadata != nullptr) {
1884  m_metadata_up = std::make_unique<ClangASTMetadata>();
1885  *m_metadata_up = *metadata;
1886  }
1887  }
1888 
1890  *this = rhs;
1891  }
1892 
1901 
1902  if (rhs.m_metadata_up) {
1903  m_metadata_up = std::make_unique<ClangASTMetadata>();
1904  *m_metadata_up = *rhs.m_metadata_up;
1905  }
1906  return *this;
1907  }
1908 
1909  bool Finalize() {
1910  return TypeSystemClang::AddObjCClassProperty(
1912  /*ivar_decl=*/nullptr, m_property_setter_name, m_property_getter_name,
1914  }
1915 
1916 private:
1918  const char *m_property_name;
1923  std::unique_ptr<ClangASTMetadata> m_metadata_up;
1924 };
1925 
1927  const DWARFDIE &die,
1928  TypeSystemClang::TemplateParameterInfos &template_param_infos) {
1929  const dw_tag_t tag = die.Tag();
1930  bool is_template_template_argument = false;
1931 
1932  switch (tag) {
1933  case DW_TAG_GNU_template_parameter_pack: {
1934  template_param_infos.packed_args =
1935  std::make_unique<TypeSystemClang::TemplateParameterInfos>();
1936  for (DWARFDIE child_die : die.children()) {
1937  if (!ParseTemplateDIE(child_die, *template_param_infos.packed_args))
1938  return false;
1939  }
1940  if (const char *name = die.GetName()) {
1941  template_param_infos.pack_name = name;
1942  }
1943  return true;
1944  }
1945  case DW_TAG_GNU_template_template_param:
1946  is_template_template_argument = true;
1947  [[fallthrough]];
1948  case DW_TAG_template_type_parameter:
1949  case DW_TAG_template_value_parameter: {
1950  DWARFAttributes attributes;
1951  const size_t num_attributes = die.GetAttributes(attributes);
1952  const char *name = nullptr;
1953  const char *template_name = nullptr;
1954  CompilerType clang_type;
1955  uint64_t uval64 = 0;
1956  bool uval64_valid = false;
1957  if (num_attributes > 0) {
1958  DWARFFormValue form_value;
1959  for (size_t i = 0; i < num_attributes; ++i) {
1960  const dw_attr_t attr = attributes.AttributeAtIndex(i);
1961 
1962  switch (attr) {
1963  case DW_AT_name:
1964  if (attributes.ExtractFormValueAtIndex(i, form_value))
1965  name = form_value.AsCString();
1966  break;
1967 
1968  case DW_AT_GNU_template_name:
1969  if (attributes.ExtractFormValueAtIndex(i, form_value))
1970  template_name = form_value.AsCString();
1971  break;
1972 
1973  case DW_AT_type:
1974  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
1975  Type *lldb_type = die.ResolveTypeUID(form_value.Reference());
1976  if (lldb_type)
1977  clang_type = lldb_type->GetForwardCompilerType();
1978  }
1979  break;
1980 
1981  case DW_AT_const_value:
1982  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
1983  uval64_valid = true;
1984  uval64 = form_value.Unsigned();
1985  }
1986  break;
1987  default:
1988  break;
1989  }
1990  }
1991 
1992  clang::ASTContext &ast = m_ast.getASTContext();
1993  if (!clang_type)
1994  clang_type = m_ast.GetBasicType(eBasicTypeVoid);
1995 
1996  if (!is_template_template_argument) {
1997  bool is_signed = false;
1998  if (name && name[0])
1999  template_param_infos.names.push_back(name);
2000  else
2001  template_param_infos.names.push_back(nullptr);
2002 
2003  // Get the signed value for any integer or enumeration if available
2004  clang_type.IsIntegerOrEnumerationType(is_signed);
2005 
2006  if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2007  llvm::Optional<uint64_t> size = clang_type.GetBitSize(nullptr);
2008  if (!size)
2009  return false;
2010  llvm::APInt apint(*size, uval64, is_signed);
2011  template_param_infos.args.push_back(
2012  clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
2013  ClangUtil::GetQualType(clang_type)));
2014  } else {
2015  template_param_infos.args.push_back(
2016  clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
2017  }
2018  } else {
2019  auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name);
2020  template_param_infos.names.push_back(name);
2021  template_param_infos.args.push_back(
2022  clang::TemplateArgument(clang::TemplateName(tplt_type)));
2023  }
2024  }
2025  }
2026  return true;
2027 
2028  default:
2029  break;
2030  }
2031  return false;
2032 }
2033 
2035  const DWARFDIE &parent_die,
2036  TypeSystemClang::TemplateParameterInfos &template_param_infos) {
2037 
2038  if (!parent_die)
2039  return false;
2040 
2041  for (DWARFDIE die : parent_die.children()) {
2042  const dw_tag_t tag = die.Tag();
2043 
2044  switch (tag) {
2045  case DW_TAG_template_type_parameter:
2046  case DW_TAG_template_value_parameter:
2047  case DW_TAG_GNU_template_parameter_pack:
2048  case DW_TAG_GNU_template_template_param:
2049  ParseTemplateDIE(die, template_param_infos);
2050  break;
2051 
2052  default:
2053  break;
2054  }
2055  }
2056  return template_param_infos.args.size() == template_param_infos.names.size();
2057 }
2058 
2060  lldb_private::Type *type,
2061  CompilerType &clang_type) {
2062  const dw_tag_t tag = die.Tag();
2063  SymbolFileDWARF *dwarf = die.GetDWARF();
2064 
2065  ClangASTImporter::LayoutInfo layout_info;
2066 
2067  if (die.HasChildren()) {
2068  const bool type_is_objc_object_or_interface =
2069  TypeSystemClang::IsObjCObjectOrInterfaceType(clang_type);
2070  if (type_is_objc_object_or_interface) {
2071  // For objective C we don't start the definition when the class is
2072  // created.
2073  TypeSystemClang::StartTagDeclarationDefinition(clang_type);
2074  }
2075 
2076  AccessType default_accessibility = eAccessNone;
2077  if (tag == DW_TAG_structure_type) {
2078  default_accessibility = eAccessPublic;
2079  } else if (tag == DW_TAG_union_type) {
2080  default_accessibility = eAccessPublic;
2081  } else if (tag == DW_TAG_class_type) {
2082  default_accessibility = eAccessPrivate;
2083  }
2084 
2085  std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2086  // Parse members and base classes first
2087  std::vector<DWARFDIE> member_function_dies;
2088 
2089  DelayedPropertyList delayed_properties;
2090  ParseChildMembers(die, clang_type, bases, member_function_dies,
2091  delayed_properties, default_accessibility, layout_info);
2092 
2093  // Now parse any methods if there were any...
2094  for (const DWARFDIE &die : member_function_dies)
2095  dwarf->ResolveType(die);
2096 
2097  if (type_is_objc_object_or_interface) {
2098  ConstString class_name(clang_type.GetTypeName());
2099  if (class_name) {
2100  dwarf->GetObjCMethods(class_name, [&](DWARFDIE method_die) {
2101  method_die.ResolveType();
2102  return true;
2103  });
2104 
2105  for (DelayedAddObjCClassProperty &property : delayed_properties)
2106  property.Finalize();
2107  }
2108  }
2109 
2110  if (!bases.empty()) {
2111  // Make sure all base classes refer to complete types and not forward
2112  // declarations. If we don't do this, clang will crash with an
2113  // assertion in the call to clang_type.TransferBaseClasses()
2114  for (const auto &base_class : bases) {
2115  clang::TypeSourceInfo *type_source_info =
2116  base_class->getTypeSourceInfo();
2117  if (type_source_info)
2118  RequireCompleteType(m_ast.GetType(type_source_info->getType()));
2119  }
2120 
2122  std::move(bases));
2123  }
2124  }
2125 
2127  TypeSystemClang::BuildIndirectFields(clang_type);
2128  TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
2129 
2130  if (!layout_info.field_offsets.empty() || !layout_info.base_offsets.empty() ||
2131  !layout_info.vbase_offsets.empty()) {
2132  if (type)
2133  layout_info.bit_size = type->GetByteSize(nullptr).value_or(0) * 8;
2134  if (layout_info.bit_size == 0)
2135  layout_info.bit_size =
2136  die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
2137 
2138  clang::CXXRecordDecl *record_decl =
2140  if (record_decl)
2141  GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
2142  }
2143 
2144  return (bool)clang_type;
2145 }
2146 
2148  lldb_private::Type *type,
2149  CompilerType &clang_type) {
2150  if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
2151  if (die.HasChildren()) {
2152  bool is_signed = false;
2153  clang_type.IsIntegerType(is_signed);
2154  ParseChildEnumerators(clang_type, is_signed,
2155  type->GetByteSize(nullptr).value_or(0), die);
2156  }
2157  TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
2158  }
2159  return (bool)clang_type;
2160 }
2161 
2163  lldb_private::Type *type,
2164  CompilerType &clang_type) {
2165  SymbolFileDWARF *dwarf = die.GetDWARF();
2166 
2167  std::lock_guard<std::recursive_mutex> guard(
2168  dwarf->GetObjectFile()->GetModule()->GetMutex());
2169 
2170  // Disable external storage for this type so we don't get anymore
2171  // clang::ExternalASTSource queries for this type.
2172  m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false);
2173 
2174  if (!die)
2175  return false;
2176 
2177  const dw_tag_t tag = die.Tag();
2178 
2179  assert(clang_type);
2180  DWARFAttributes attributes;
2181  switch (tag) {
2182  case DW_TAG_structure_type:
2183  case DW_TAG_union_type:
2184  case DW_TAG_class_type:
2185  return CompleteRecordType(die, type, clang_type);
2186  case DW_TAG_enumeration_type:
2187  return CompleteEnumType(die, type, clang_type);
2188  default:
2189  assert(false && "not a forward clang type decl!");
2190  break;
2191  }
2192 
2193  return false;
2194 }
2195 
2197  lldb_private::CompilerDeclContext decl_context) {
2198  auto opaque_decl_ctx =
2199  (clang::DeclContext *)decl_context.GetOpaqueDeclContext();
2200  for (auto it = m_decl_ctx_to_die.find(opaque_decl_ctx);
2201  it != m_decl_ctx_to_die.end() && it->first == opaque_decl_ctx;
2202  it = m_decl_ctx_to_die.erase(it))
2203  for (DWARFDIE decl : it->second.children())
2204  GetClangDeclForDIE(decl);
2205 }
2206 
2208  clang::Decl *clang_decl = GetClangDeclForDIE(die);
2209  if (clang_decl != nullptr)
2210  return m_ast.GetCompilerDecl(clang_decl);
2211  return CompilerDecl();
2212 }
2213 
2216  clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
2217  if (clang_decl_ctx)
2218  return m_ast.CreateDeclContext(clang_decl_ctx);
2219  return CompilerDeclContext();
2220 }
2221 
2224  clang::DeclContext *clang_decl_ctx =
2225  GetClangDeclContextContainingDIE(die, nullptr);
2226  if (clang_decl_ctx)
2227  return m_ast.CreateDeclContext(clang_decl_ctx);
2228  return CompilerDeclContext();
2229 }
2230 
2232  lldb_private::CompilerType &clang_type, bool is_signed,
2233  uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
2234  if (!parent_die)
2235  return 0;
2236 
2237  size_t enumerators_added = 0;
2238 
2239  for (DWARFDIE die : parent_die.children()) {
2240  const dw_tag_t tag = die.Tag();
2241  if (tag == DW_TAG_enumerator) {
2242  DWARFAttributes attributes;
2243  const size_t num_child_attributes = die.GetAttributes(attributes);
2244  if (num_child_attributes > 0) {
2245  const char *name = nullptr;
2246  bool got_value = false;
2247  int64_t enum_value = 0;
2248  Declaration decl;
2249 
2250  uint32_t i;
2251  for (i = 0; i < num_child_attributes; ++i) {
2252  const dw_attr_t attr = attributes.AttributeAtIndex(i);
2253  DWARFFormValue form_value;
2254  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
2255  switch (attr) {
2256  case DW_AT_const_value:
2257  got_value = true;
2258  if (is_signed)
2259  enum_value = form_value.Signed();
2260  else
2261  enum_value = form_value.Unsigned();
2262  break;
2263 
2264  case DW_AT_name:
2265  name = form_value.AsCString();
2266  break;
2267 
2268  case DW_AT_description:
2269  default:
2270  case DW_AT_decl_file:
2271  decl.SetFile(attributes.CompileUnitAtIndex(i)->GetFile(
2272  form_value.Unsigned()));
2273  break;
2274  case DW_AT_decl_line:
2275  decl.SetLine(form_value.Unsigned());
2276  break;
2277  case DW_AT_decl_column:
2278  decl.SetColumn(form_value.Unsigned());
2279  break;
2280  case DW_AT_sibling:
2281  break;
2282  }
2283  }
2284  }
2285 
2286  if (name && name[0] && got_value) {
2288  clang_type, decl, name, enum_value, enumerator_byte_size * 8);
2289  ++enumerators_added;
2290  }
2291  }
2292  }
2293  }
2294  return enumerators_added;
2295 }
2296 
2299  bool is_static = false;
2300  bool is_variadic = false;
2301  bool has_template_params = false;
2302  unsigned type_quals = 0;
2303  std::vector<CompilerType> param_types;
2304  std::vector<clang::ParmVarDecl *> param_decls;
2305  StreamString sstr;
2306 
2308  sstr << decl_ctx.GetQualifiedName();
2309 
2310  clang::DeclContext *containing_decl_ctx =
2311  GetClangDeclContextContainingDIE(die, nullptr);
2312  ParseChildParameters(containing_decl_ctx, die, true, is_static, is_variadic,
2313  has_template_params, param_types, param_decls,
2314  type_quals);
2315  sstr << "(";
2316  for (size_t i = 0; i < param_types.size(); i++) {
2317  if (i > 0)
2318  sstr << ", ";
2319  sstr << param_types[i].GetTypeName();
2320  }
2321  if (is_variadic)
2322  sstr << ", ...";
2323  sstr << ")";
2324  if (type_quals & clang::Qualifiers::Const)
2325  sstr << " const";
2326 
2327  return ConstString(sstr.GetString());
2328 }
2329 
2330 Function *
2332  const DWARFDIE &die,
2333  const AddressRange &func_range) {
2334  assert(func_range.GetBaseAddress().IsValid());
2335  DWARFRangeList func_ranges;
2336  const char *name = nullptr;
2337  const char *mangled = nullptr;
2338  int decl_file = 0;
2339  int decl_line = 0;
2340  int decl_column = 0;
2341  int call_file = 0;
2342  int call_line = 0;
2343  int call_column = 0;
2344  DWARFExpressionList frame_base;
2345 
2346  const dw_tag_t tag = die.Tag();
2347 
2348  if (tag != DW_TAG_subprogram)
2349  return nullptr;
2350 
2351  if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
2352  decl_column, call_file, call_line, call_column,
2353  &frame_base)) {
2354  Mangled func_name;
2355  if (mangled)
2356  func_name.SetValue(ConstString(mangled), true);
2357  else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
2358  die.GetParent().Tag() == DW_TAG_partial_unit) &&
2359  Language::LanguageIsCPlusPlus(
2361  !Language::LanguageIsObjC(
2363  name && strcmp(name, "main") != 0) {
2364  // If the mangled name is not present in the DWARF, generate the
2365  // demangled name using the decl context. We skip if the function is
2366  // "main" as its name is never mangled.
2367  func_name.SetValue(ConstructDemangledNameFromDWARF(die), false);
2368  } else
2369  func_name.SetValue(ConstString(name), false);
2370 
2371  FunctionSP func_sp;
2372  std::unique_ptr<Declaration> decl_up;
2373  if (decl_file != 0 || decl_line != 0 || decl_column != 0)
2374  decl_up = std::make_unique<Declaration>(die.GetCU()->GetFile(decl_file),
2375  decl_line, decl_column);
2376 
2377  SymbolFileDWARF *dwarf = die.GetDWARF();
2378  // Supply the type _only_ if it has already been parsed
2379  Type *func_type = dwarf->GetDIEToType().lookup(die.GetDIE());
2380 
2381  assert(func_type == nullptr || func_type != DIE_IS_BEING_PARSED);
2382 
2383  const user_id_t func_user_id = die.GetID();
2384  func_sp =
2385  std::make_shared<Function>(&comp_unit,
2386  func_user_id, // UserID is the DIE offset
2387  func_user_id, func_name, func_type,
2388  func_range); // first address range
2389 
2390  if (func_sp.get() != nullptr) {
2391  if (frame_base.IsValid())
2392  func_sp->GetFrameBaseExpression() = frame_base;
2393  comp_unit.AddFunction(func_sp);
2394  return func_sp.get();
2395  }
2396  }
2397  return nullptr;
2398 }
2399 
2400 namespace {
2401 /// Parsed form of all attributes that are relevant for parsing type members.
2402 struct MemberAttributes {
2403  explicit MemberAttributes(const DWARFDIE &die, const DWARFDIE &parent_die,
2404  ModuleSP module_sp);
2405  const char *name = nullptr;
2406  /// Indicates how many bits into the word (according to the host endianness)
2407  /// the low-order bit of the field starts. Can be negative.
2408  int64_t bit_offset = 0;
2409  /// Indicates the size of the field in bits.
2410  size_t bit_size = 0;
2411  uint64_t data_bit_offset = UINT64_MAX;
2412  AccessType accessibility = eAccessNone;
2413  llvm::Optional<uint64_t> byte_size;
2414  llvm::Optional<DWARFFormValue> const_value_form;
2415  DWARFFormValue encoding_form;
2416  /// Indicates the byte offset of the word from the base address of the
2417  /// structure.
2418  uint32_t member_byte_offset;
2419  bool is_artificial = false;
2420 };
2421 
2422 /// Parsed form of all attributes that are relevant for parsing Objective-C
2423 /// properties.
2424 struct PropertyAttributes {
2425  explicit PropertyAttributes(const DWARFDIE &die);
2426  const char *prop_name = nullptr;
2427  const char *prop_getter_name = nullptr;
2428  const char *prop_setter_name = nullptr;
2429  /// \see clang::ObjCPropertyAttribute
2430  uint32_t prop_attributes = 0;
2431 };
2432 } // namespace
2433 
2434 MemberAttributes::MemberAttributes(const DWARFDIE &die,
2435  const DWARFDIE &parent_die,
2436  ModuleSP module_sp) {
2437  member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
2438 
2439  DWARFAttributes attributes;
2440  const size_t num_attributes = die.GetAttributes(attributes);
2441  for (std::size_t i = 0; i < num_attributes; ++i) {
2442  const dw_attr_t attr = attributes.AttributeAtIndex(i);
2443  DWARFFormValue form_value;
2444  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
2445  switch (attr) {
2446  case DW_AT_name:
2447  name = form_value.AsCString();
2448  break;
2449  case DW_AT_type:
2450  encoding_form = form_value;
2451  break;
2452  case DW_AT_bit_offset:
2453  bit_offset = form_value.Signed();
2454  break;
2455  case DW_AT_bit_size:
2456  bit_size = form_value.Unsigned();
2457  break;
2458  case DW_AT_byte_size:
2459  byte_size = form_value.Unsigned();
2460  break;
2461  case DW_AT_const_value:
2462  const_value_form = form_value;
2463  break;
2464  case DW_AT_data_bit_offset:
2465  data_bit_offset = form_value.Unsigned();
2466  break;
2467  case DW_AT_data_member_location:
2468  if (form_value.BlockData()) {
2469  Value initialValue(0);
2470  Value memberOffset(0);
2471  const DWARFDataExtractor &debug_info_data = die.GetData();
2472  uint32_t block_length = form_value.Unsigned();
2473  uint32_t block_offset =
2474  form_value.BlockData() - debug_info_data.GetDataStart();
2475  if (DWARFExpression::Evaluate(
2476  nullptr, // ExecutionContext *
2477  nullptr, // RegisterContext *
2478  module_sp,
2479  DataExtractor(debug_info_data, block_offset, block_length),
2480  die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
2481  memberOffset, nullptr)) {
2482  member_byte_offset = memberOffset.ResolveValue(nullptr).UInt();
2483  }
2484  } else {
2485  // With DWARF 3 and later, if the value is an integer constant,
2486  // this form value is the offset in bytes from the beginning of
2487  // the containing entity.
2488  member_byte_offset = form_value.Unsigned();
2489  }
2490  break;
2491 
2492  case DW_AT_accessibility:
2493  accessibility = DWARFASTParser::GetAccessTypeFromDWARF(form_value.Unsigned());
2494  break;
2495  case DW_AT_artificial:
2496  is_artificial = form_value.Boolean();
2497  break;
2498  default:
2499  break;
2500  }
2501  }
2502  }
2503 
2504  // Clang has a DWARF generation bug where sometimes it represents
2505  // fields that are references with bad byte size and bit size/offset
2506  // information such as:
2507  //
2508  // DW_AT_byte_size( 0x00 )
2509  // DW_AT_bit_size( 0x40 )
2510  // DW_AT_bit_offset( 0xffffffffffffffc0 )
2511  //
2512  // So check the bit offset to make sure it is sane, and if the values
2513  // are not sane, remove them. If we don't do this then we will end up
2514  // with a crash if we try to use this type in an expression when clang
2515  // becomes unhappy with its recycled debug info.
2516  if (byte_size.value_or(0) == 0 && bit_offset < 0) {
2517  bit_size = 0;
2518  bit_offset = 0;
2519  }
2520 }
2521 
2522 PropertyAttributes::PropertyAttributes(const DWARFDIE &die) {
2523 
2524  DWARFAttributes attributes;
2525  const size_t num_attributes = die.GetAttributes(attributes);
2526  for (size_t i = 0; i < num_attributes; ++i) {
2527  const dw_attr_t attr = attributes.AttributeAtIndex(i);
2528  DWARFFormValue form_value;
2529  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
2530  switch (attr) {
2531  case DW_AT_APPLE_property_name:
2532  prop_name = form_value.AsCString();
2533  break;
2534  case DW_AT_APPLE_property_getter:
2535  prop_getter_name = form_value.AsCString();
2536  break;
2537  case DW_AT_APPLE_property_setter:
2538  prop_setter_name = form_value.AsCString();
2539  break;
2540  case DW_AT_APPLE_property_attribute:
2541  prop_attributes = form_value.Unsigned();
2542  break;
2543  default:
2544  break;
2545  }
2546  }
2547  }
2548 
2549  if (!prop_name)
2550  return;
2551  ConstString fixed_setter;
2552 
2553  // Check if the property getter/setter were provided as full names.
2554  // We want basenames, so we extract them.
2555  if (prop_getter_name && prop_getter_name[0] == '-') {
2556  ObjCLanguage::MethodName prop_getter_method(prop_getter_name, true);
2557  prop_getter_name = prop_getter_method.GetSelector().GetCString();
2558  }
2559 
2560  if (prop_setter_name && prop_setter_name[0] == '-') {
2561  ObjCLanguage::MethodName prop_setter_method(prop_setter_name, true);
2562  prop_setter_name = prop_setter_method.GetSelector().GetCString();
2563  }
2564 
2565  // If the names haven't been provided, they need to be filled in.
2566  if (!prop_getter_name)
2567  prop_getter_name = prop_name;
2568  if (!prop_setter_name && prop_name[0] &&
2569  !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2570  StreamString ss;
2571 
2572  ss.Printf("set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2573 
2574  fixed_setter.SetString(ss.GetString());
2575  prop_setter_name = fixed_setter.GetCString();
2576  }
2577 }
2578 
2580  const DWARFDIE &die, const DWARFDIE &parent_die,
2581  const lldb_private::CompilerType &class_clang_type,
2582  DelayedPropertyList &delayed_properties) {
2583  // This function can only parse DW_TAG_APPLE_property.
2584  assert(die.Tag() == DW_TAG_APPLE_property);
2585 
2586  ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
2587 
2588  const MemberAttributes attrs(die, parent_die, module_sp);
2589  const PropertyAttributes propAttrs(die);
2590 
2591  if (!propAttrs.prop_name) {
2592  module_sp->ReportError(
2593  "0x%8.8" PRIx64 ": DW_TAG_APPLE_property has no name.", die.GetID());
2594  return;
2595  }
2596 
2597  Type *member_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
2598  if (!member_type) {
2599  module_sp->ReportError("0x%8.8" PRIx64
2600  ": DW_TAG_APPLE_property '%s' refers to type 0x%8.8x"
2601  " which was unable to be parsed",
2602  die.GetID(), propAttrs.prop_name,
2603  attrs.encoding_form.Reference().GetOffset());
2604  return;
2605  }
2606 
2607  ClangASTMetadata metadata;
2608  metadata.SetUserID(die.GetID());
2609  delayed_properties.push_back(DelayedAddObjCClassProperty(
2610  class_clang_type, propAttrs.prop_name,
2611  member_type->GetLayoutCompilerType(), propAttrs.prop_setter_name,
2612  propAttrs.prop_getter_name, propAttrs.prop_attributes, &metadata));
2613 }
2614 
2616  const CompilerType &int_type, const DWARFFormValue &form_value) const {
2617  clang::QualType qt = ClangUtil::GetQualType(int_type);
2618  assert(qt->isIntegralOrEnumerationType());
2619  TypeSystemClang &ts = *llvm::cast<TypeSystemClang>(int_type.GetTypeSystem());
2620  clang::ASTContext &ast = ts.getASTContext();
2621 
2622  const unsigned type_bits = ast.getIntWidth(qt);
2623  const bool is_unsigned = qt->isUnsignedIntegerType();
2624 
2625  // The maximum int size supported at the moment by this function. Limited
2626  // by the uint64_t return type of DWARFFormValue::Signed/Unsigned.
2627  constexpr std::size_t max_bit_size = 64;
2628 
2629  // For values bigger than 64 bit (e.g. __int128_t values),
2630  // DWARFFormValue's Signed/Unsigned functions will return wrong results so
2631  // emit an error for now.
2632  if (type_bits > max_bit_size) {
2633  auto msg = llvm::formatv("Can only parse integers with up to {0} bits, but "
2634  "given integer has {1} bits.",
2635  max_bit_size, type_bits);
2636  return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2637  }
2638 
2639  // Construct an APInt with the maximum bit size and the given integer.
2640  llvm::APInt result(max_bit_size, form_value.Unsigned(), !is_unsigned);
2641 
2642  // Calculate how many bits are required to represent the input value.
2643  // For unsigned types, take the number of active bits in the APInt.
2644  // For signed types, ask APInt how many bits are required to represent the
2645  // signed integer.
2646  const unsigned required_bits =
2647  is_unsigned ? result.getActiveBits() : result.getMinSignedBits();
2648 
2649  // If the input value doesn't fit into the integer type, return an error.
2650  if (required_bits > type_bits) {
2651  std::string value_as_str = is_unsigned
2652  ? std::to_string(form_value.Unsigned())
2653  : std::to_string(form_value.Signed());
2654  auto msg = llvm::formatv("Can't store {0} value {1} in integer with {2} "
2655  "bits.",
2656  (is_unsigned ? "unsigned" : "signed"),
2657  value_as_str, type_bits);
2658  return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2659  }
2660 
2661  // Trim the result to the bit width our the int type.
2662  if (result.getBitWidth() > type_bits)
2663  result = result.trunc(type_bits);
2664  return result;
2665 }
2666 
2668  const DWARFDIE &die, const DWARFDIE &parent_die,
2669  const lldb_private::CompilerType &class_clang_type,
2670  lldb::AccessType default_accessibility,
2672  FieldInfo &last_field_info) {
2673  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
2674  // This function can only parse DW_TAG_member.
2675  assert(die.Tag() == DW_TAG_member);
2676 
2677  ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
2678  const dw_tag_t tag = die.Tag();
2679  // Get the parent byte size so we can verify any members will fit
2680  const uint64_t parent_byte_size =
2681  parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
2682  const uint64_t parent_bit_size =
2683  parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
2684 
2685  // FIXME: Remove the workarounds below and make this const.
2686  MemberAttributes attrs(die, parent_die, module_sp);
2687 
2688  const bool class_is_objc_object_or_interface =
2689  TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
2690 
2691  // FIXME: Make Clang ignore Objective-C accessibility for expressions
2692  if (class_is_objc_object_or_interface)
2693  attrs.accessibility = eAccessNone;
2694 
2695  // Handle static members, which is any member that doesn't have a bit or a
2696  // byte member offset.
2697  if (attrs.member_byte_offset == UINT32_MAX &&
2698  attrs.data_bit_offset == UINT64_MAX) {
2699  Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
2700 
2701  if (var_type) {
2702  if (attrs.accessibility == eAccessNone)
2703  attrs.accessibility = eAccessPublic;
2704  CompilerType ct = var_type->GetForwardCompilerType();
2705  clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
2706  class_clang_type, attrs.name, ct, attrs.accessibility);
2707  if (!v) {
2708  LLDB_LOG(log, "Failed to add variable to the record type");
2709  return;
2710  }
2711 
2712  bool unused;
2713  // TODO: Support float/double static members as well.
2714  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
2715  return;
2716  llvm::Expected<llvm::APInt> const_value_or_err =
2717  ExtractIntFromFormValue(ct, *attrs.const_value_form);
2718  if (!const_value_or_err) {
2719  LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
2720  "Failed to add const value to variable {1}: {0}",
2721  v->getQualifiedNameAsString());
2722  return;
2723  }
2724  TypeSystemClang::SetIntegerInitializerForVariable(v, *const_value_or_err);
2725  }
2726  return;
2727  }
2728 
2729  Type *member_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
2730  if (!member_type) {
2731  if (attrs.name)
2732  module_sp->ReportError(
2733  "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
2734  " which was unable to be parsed",
2735  die.GetID(), attrs.name, attrs.encoding_form.Reference().GetOffset());
2736  else
2737  module_sp->ReportError(
2738  "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
2739  " which was unable to be parsed",
2740  die.GetID(), attrs.encoding_form.Reference().GetOffset());
2741  return;
2742  }
2743 
2744  const uint64_t character_width = 8;
2745  const uint64_t word_width = 32;
2746  CompilerType member_clang_type = member_type->GetLayoutCompilerType();
2747 
2748  if (attrs.accessibility == eAccessNone)
2749  attrs.accessibility = default_accessibility;
2750 
2751  uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
2752  ? 0
2753  : (attrs.member_byte_offset * 8ULL));
2754 
2755  if (attrs.bit_size > 0) {
2756  FieldInfo this_field_info;
2757  this_field_info.bit_offset = field_bit_offset;
2758  this_field_info.bit_size = attrs.bit_size;
2759 
2760  if (attrs.data_bit_offset != UINT64_MAX) {
2761  this_field_info.bit_offset = attrs.data_bit_offset;
2762  } else {
2763  if (!attrs.byte_size)
2764  attrs.byte_size = member_type->GetByteSize(nullptr);
2765 
2766  ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
2767  if (objfile->GetByteOrder() == eByteOrderLittle) {
2768  this_field_info.bit_offset += attrs.byte_size.value_or(0) * 8;
2769  this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size);
2770  } else {
2771  this_field_info.bit_offset += attrs.bit_offset;
2772  }
2773  }
2774 
2775  // The ObjC runtime knows the byte offset but we still need to provide
2776  // the bit-offset in the layout. It just means something different then
2777  // what it does in C and C++. So we skip this check for ObjC types.
2778  //
2779  // We also skip this for fields of a union since they will all have a
2780  // zero offset.
2781  if (!TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type) &&
2782  !(parent_die.Tag() == DW_TAG_union_type &&
2783  this_field_info.bit_offset == 0) &&
2784  ((this_field_info.bit_offset >= parent_bit_size) ||
2785  (last_field_info.IsBitfield() &&
2786  !last_field_info.NextBitfieldOffsetIsValid(
2787  this_field_info.bit_offset)))) {
2788  ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
2789  objfile->GetModule()->ReportWarning(
2790  "0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
2791  "bit offset (0x%8.8" PRIx64
2792  ") member will be ignored. Please file a bug against the "
2793  "compiler and include the preprocessed output for %s\n",
2794  die.GetID(), DW_TAG_value_to_name(tag), attrs.name,
2795  this_field_info.bit_offset, GetUnitName(parent_die).c_str());
2796  return;
2797  }
2798 
2799  // Update the field bit offset we will report for layout
2800  field_bit_offset = this_field_info.bit_offset;
2801 
2802  // Objective-C has invalid DW_AT_bit_offset values in older
2803  // versions of clang, so we have to be careful and only insert
2804  // unnamed bitfields if we have a new enough clang.
2805  bool detect_unnamed_bitfields = true;
2806 
2807  if (class_is_objc_object_or_interface)
2808  detect_unnamed_bitfields =
2810 
2811  if (detect_unnamed_bitfields) {
2812  llvm::Optional<FieldInfo> unnamed_field_info;
2813  uint64_t last_field_end = 0;
2814 
2815  last_field_end = last_field_info.bit_offset + last_field_info.bit_size;
2816 
2817  if (!last_field_info.IsBitfield()) {
2818  // The last field was not a bit-field...
2819  // but if it did take up the entire word then we need to extend
2820  // last_field_end so the bit-field does not step into the last
2821  // fields padding.
2822  if (last_field_end != 0 && ((last_field_end % word_width) != 0))
2823  last_field_end += word_width - (last_field_end % word_width);
2824  }
2825 
2826  // If we have a gap between the last_field_end and the current
2827  // field we have an unnamed bit-field.
2828  // If we have a base class, we assume there is no unnamed
2829  // bit-field if this is the first field since the gap can be
2830  // attributed to the members from the base class. This assumption
2831  // is not correct if the first field of the derived class is
2832  // indeed an unnamed bit-field. We currently do not have the
2833  // machinary to track the offset of the last field of classes we
2834  // have seen before, so we are not handling this case.
2835  if (this_field_info.bit_offset != last_field_end &&
2836  this_field_info.bit_offset > last_field_end &&
2837  !(last_field_info.bit_offset == 0 &&
2838  last_field_info.bit_size == 0 &&
2839  layout_info.base_offsets.size() != 0)) {
2840  unnamed_field_info = FieldInfo{};
2841  unnamed_field_info->bit_size =
2842  this_field_info.bit_offset - last_field_end;
2843  unnamed_field_info->bit_offset = last_field_end;
2844  }
2845 
2846  if (unnamed_field_info) {
2847  clang::FieldDecl *unnamed_bitfield_decl =
2848  TypeSystemClang::AddFieldToRecordType(
2849  class_clang_type, llvm::StringRef(),
2851  word_width),
2852  attrs.accessibility, unnamed_field_info->bit_size);
2853 
2854  layout_info.field_offsets.insert(std::make_pair(
2855  unnamed_bitfield_decl, unnamed_field_info->bit_offset));
2856  }
2857  }
2858 
2859  last_field_info = this_field_info;
2860  last_field_info.SetIsBitfield(true);
2861  } else {
2862  last_field_info.bit_offset = field_bit_offset;
2863 
2864  if (llvm::Optional<uint64_t> clang_type_size =
2865  member_type->GetByteSize(nullptr)) {
2866  last_field_info.bit_size = *clang_type_size * character_width;
2867  }
2868 
2869  last_field_info.SetIsBitfield(false);
2870  }
2871 
2872  // Don't turn artificial members such as vtable pointers into real FieldDecls
2873  // in our AST. Clang will re-create those articial members and they would
2874  // otherwise just overlap in the layout with the FieldDecls we add here.
2875  // This needs to be done after updating FieldInfo which keeps track of where
2876  // field start/end so we don't later try to fill the the space of this
2877  // artificial member with (unnamed bitfield) padding.
2878  // FIXME: This check should verify that this is indeed an artificial member
2879  // we are supposed to ignore.
2880  if (attrs.is_artificial)
2881  return;
2882 
2883  if (!member_clang_type.IsCompleteType())
2884  member_clang_type.GetCompleteType();
2885 
2886  {
2887  // Older versions of clang emit array[0] and array[1] in the
2888  // same way (<rdar://problem/12566646>). If the current field
2889  // is at the end of the structure, then there is definitely no
2890  // room for extra elements and we override the type to
2891  // array[0].
2892 
2893  CompilerType member_array_element_type;
2894  uint64_t member_array_size;
2895  bool member_array_is_incomplete;
2896 
2897  if (member_clang_type.IsArrayType(&member_array_element_type,
2898  &member_array_size,
2899  &member_array_is_incomplete) &&
2900  !member_array_is_incomplete) {
2901  uint64_t parent_byte_size =
2902  parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
2903 
2904  if (attrs.member_byte_offset >= parent_byte_size) {
2905  if (member_array_size != 1 &&
2906  (member_array_size != 0 ||
2907  attrs.member_byte_offset > parent_byte_size)) {
2908  module_sp->ReportError(
2909  "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
2910  " which extends beyond the bounds of 0x%8.8" PRIx64,
2911  die.GetID(), attrs.name,
2912  attrs.encoding_form.Reference().GetOffset(),
2913  parent_die.GetID());
2914  }
2915 
2916  member_clang_type =
2917  m_ast.CreateArrayType(member_array_element_type, 0, false);
2918  }
2919  }
2920  }
2921 
2922  RequireCompleteType(member_clang_type);
2923 
2924  clang::FieldDecl *field_decl = TypeSystemClang::AddFieldToRecordType(
2925  class_clang_type, attrs.name, member_clang_type, attrs.accessibility,
2926  attrs.bit_size);
2927 
2928  m_ast.SetMetadataAsUserID(field_decl, die.GetID());
2929 
2930  layout_info.field_offsets.insert(
2931  std::make_pair(field_decl, field_bit_offset));
2932 }
2933 
2935  const DWARFDIE &parent_die, CompilerType &class_clang_type,
2936  std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
2937  std::vector<DWARFDIE> &member_function_dies,
2938  DelayedPropertyList &delayed_properties,
2939  const AccessType default_accessibility,
2940  ClangASTImporter::LayoutInfo &layout_info) {
2941  if (!parent_die)
2942  return false;
2943 
2944  FieldInfo last_field_info;
2945 
2946  ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
2947  TypeSystemClang *ast =
2948  llvm::dyn_cast_or_null<TypeSystemClang>(class_clang_type.GetTypeSystem());
2949  if (ast == nullptr)
2950  return false;
2951 
2952  for (DWARFDIE die : parent_die.children()) {
2953  dw_tag_t tag = die.Tag();
2954 
2955  switch (tag) {
2956  case DW_TAG_APPLE_property:
2957  ParseObjCProperty(die, parent_die, class_clang_type, delayed_properties);
2958  break;
2959 
2960  case DW_TAG_member:
2961  ParseSingleMember(die, parent_die, class_clang_type,
2962  default_accessibility, layout_info, last_field_info);
2963  break;
2964 
2965  case DW_TAG_subprogram:
2966  // Let the type parsing code handle this one for us.
2967  member_function_dies.push_back(die);
2968  break;
2969 
2970  case DW_TAG_inheritance:
2971  ParseInheritance(die, parent_die, class_clang_type, default_accessibility,
2972  module_sp, base_classes, layout_info);
2973  break;
2974 
2975  default:
2976  break;
2977  }
2978  }
2979 
2980  return true;
2981 }
2982 
2984  clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die,
2985  bool skip_artificial, bool &is_static, bool &is_variadic,
2986  bool &has_template_params, std::vector<CompilerType> &function_param_types,
2987  std::vector<clang::ParmVarDecl *> &function_param_decls,
2988  unsigned &type_quals) {
2989  if (!parent_die)
2990  return 0;
2991 
2992  size_t arg_idx = 0;
2993  for (DWARFDIE die : parent_die.children()) {
2994  const dw_tag_t tag = die.Tag();
2995  switch (tag) {
2996  case DW_TAG_formal_parameter: {
2997  DWARFAttributes attributes;
2998  const size_t num_attributes = die.GetAttributes(attributes);
2999  if (num_attributes > 0) {
3000  const char *name = nullptr;
3001  DWARFFormValue param_type_die_form;
3002  bool is_artificial = false;
3003  // one of None, Auto, Register, Extern, Static, PrivateExtern
3004 
3005  clang::StorageClass storage = clang::SC_None;
3006  uint32_t i;
3007  for (i = 0; i < num_attributes; ++i) {
3008  const dw_attr_t attr = attributes.AttributeAtIndex(i);
3009  DWARFFormValue form_value;
3010  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
3011  switch (attr) {
3012  case DW_AT_name:
3013  name = form_value.AsCString();
3014  break;
3015  case DW_AT_type:
3016  param_type_die_form = form_value;
3017  break;
3018  case DW_AT_artificial:
3019  is_artificial = form_value.Boolean();
3020  break;
3021  case DW_AT_location:
3022  case DW_AT_const_value:
3023  case DW_AT_default_value:
3024  case DW_AT_description:
3025  case DW_AT_endianity:
3026  case DW_AT_is_optional:
3027  case DW_AT_segment:
3028  case DW_AT_variable_parameter:
3029  default:
3030  case DW_AT_abstract_origin:
3031  case DW_AT_sibling:
3032  break;
3033  }
3034  }
3035  }
3036 
3037  bool skip = false;
3038  if (skip_artificial && is_artificial) {
3039  // In order to determine if a C++ member function is "const" we
3040  // have to look at the const-ness of "this"...
3041  if (arg_idx == 0 &&
3042  DeclKindIsCXXClass(containing_decl_ctx->getDeclKind()) &&
3043  // Often times compilers omit the "this" name for the
3044  // specification DIEs, so we can't rely upon the name being in
3045  // the formal parameter DIE...
3046  (name == nullptr || ::strcmp(name, "this") == 0)) {
3047  Type *this_type =
3048  die.ResolveTypeUID(param_type_die_form.Reference());
3049  if (this_type) {
3050  uint32_t encoding_mask = this_type->GetEncodingMask();
3051  if (encoding_mask & Type::eEncodingIsPointerUID) {
3052  is_static = false;
3053 
3054  if (encoding_mask & (1u << Type::eEncodingIsConstUID))
3055  type_quals |= clang::Qualifiers::Const;
3056  if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
3057  type_quals |= clang::Qualifiers::Volatile;
3058  }
3059  }
3060  }
3061  skip = true;
3062  }
3063 
3064  if (!skip) {
3065  Type *type = die.ResolveTypeUID(param_type_die_form.Reference());
3066  if (type) {
3067  function_param_types.push_back(type->GetForwardCompilerType());
3068 
3069  clang::ParmVarDecl *param_var_decl =
3071  containing_decl_ctx, GetOwningClangModule(die), name,
3072  type->GetForwardCompilerType(), storage);
3073  assert(param_var_decl);
3074  function_param_decls.push_back(param_var_decl);
3075 
3076  m_ast.SetMetadataAsUserID(param_var_decl, die.GetID());
3077  }
3078  }
3079  }
3080  arg_idx++;
3081  } break;
3082 
3083  case DW_TAG_unspecified_parameters:
3084  is_variadic = true;
3085  break;
3086 
3087  case DW_TAG_template_type_parameter:
3088  case DW_TAG_template_value_parameter:
3089  case DW_TAG_GNU_template_parameter_pack:
3090  // The one caller of this was never using the template_param_infos, and
3091  // the local variable was taking up a large amount of stack space in
3092  // SymbolFileDWARF::ParseType() so this was removed. If we ever need the
3093  // template params back, we can add them back.
3094  // ParseTemplateDIE (dwarf_cu, die, template_param_infos);
3095  has_template_params = true;
3096  break;
3097 
3098  default:
3099  break;
3100  }
3101  }
3102  return arg_idx;
3103 }
3104 
3106  if (die) {
3107  SymbolFileDWARF *dwarf = die.GetDWARF();
3108  DWARFAttributes attributes;
3109  const size_t num_attributes = die.GetAttributes(attributes);
3110  if (num_attributes > 0) {
3111  DWARFFormValue type_die_form;
3112  for (size_t i = 0; i < num_attributes; ++i) {
3113  dw_attr_t attr = attributes.AttributeAtIndex(i);
3114  DWARFFormValue form_value;
3115 
3116  if (attr == DW_AT_type &&
3117  attributes.ExtractFormValueAtIndex(i, form_value))
3118  return dwarf->ResolveTypeUID(form_value.Reference(), true);
3119  }
3120  }
3121  }
3122 
3123  return nullptr;
3124 }
3125 
3127  if (!die)
3128  return nullptr;
3129 
3130  switch (die.Tag()) {
3131  case DW_TAG_variable:
3132  case DW_TAG_constant:
3133  case DW_TAG_formal_parameter:
3134  case DW_TAG_imported_declaration:
3135  case DW_TAG_imported_module:
3136  break;
3137  default:
3138  return nullptr;
3139  }
3140 
3141  DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
3142  if (cache_pos != m_die_to_decl.end())
3143  return cache_pos->second;
3144 
3145  if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification)) {
3146  clang::Decl *decl = GetClangDeclForDIE(spec_die);
3147  m_die_to_decl[die.GetDIE()] = decl;
3148  return decl;
3149  }
3150 
3151  if (DWARFDIE abstract_origin_die =
3152  die.GetReferencedDIE(DW_AT_abstract_origin)) {
3153  clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
3154  m_die_to_decl[die.GetDIE()] = decl;
3155  return decl;
3156  }
3157 
3158  clang::Decl *decl = nullptr;
3159  switch (die.Tag()) {
3160  case DW_TAG_variable:
3161  case DW_TAG_constant:
3162  case DW_TAG_formal_parameter: {
3163  SymbolFileDWARF *dwarf = die.GetDWARF();
3164  Type *type = GetTypeForDIE(die);
3165  if (dwarf && type) {
3166  const char *name = die.GetName();
3167  clang::DeclContext *decl_context =
3168  TypeSystemClang::DeclContextGetAsDeclContext(
3169  dwarf->GetDeclContextContainingUID(die.GetID()));
3171  decl_context, GetOwningClangModule(die), name,
3172  ClangUtil::GetQualType(type->GetForwardCompilerType()));
3173  }
3174  break;
3175  }
3176  case DW_TAG_imported_declaration: {
3177  SymbolFileDWARF *dwarf = die.GetDWARF();
3178  DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
3179  if (imported_uid) {
3180  CompilerDecl imported_decl = SymbolFileDWARF::GetDecl(imported_uid);
3181  if (imported_decl) {
3182  clang::DeclContext *decl_context =
3183  TypeSystemClang::DeclContextGetAsDeclContext(
3184  dwarf->GetDeclContextContainingUID(die.GetID()));
3185  if (clang::NamedDecl *clang_imported_decl =
3186  llvm::dyn_cast<clang::NamedDecl>(
3187  (clang::Decl *)imported_decl.GetOpaqueDecl()))
3189  decl_context, OptionalClangModuleID(), clang_imported_decl);
3190  }
3191  }
3192  break;
3193  }
3194  case DW_TAG_imported_module: {
3195  SymbolFileDWARF *dwarf = die.GetDWARF();
3196  DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
3197 
3198  if (imported_uid) {
3199  CompilerDeclContext imported_decl_ctx =
3200  SymbolFileDWARF::GetDeclContext(imported_uid);
3201  if (imported_decl_ctx) {
3202  clang::DeclContext *decl_context =
3203  TypeSystemClang::DeclContextGetAsDeclContext(
3204  dwarf->GetDeclContextContainingUID(die.GetID()));
3205  if (clang::NamespaceDecl *ns_decl =
3206  TypeSystemClang::DeclContextGetAsNamespaceDecl(
3207  imported_decl_ctx))
3209  decl_context, OptionalClangModuleID(), ns_decl);
3210  }
3211  }
3212  break;
3213  }
3214  default:
3215  break;
3216  }
3217 
3218  m_die_to_decl[die.GetDIE()] = decl;
3219 
3220  return decl;
3221 }
3222 
3223 clang::DeclContext *
3225  if (die) {
3226  clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE(die);
3227  if (decl_ctx)
3228  return decl_ctx;
3229 
3230  bool try_parsing_type = true;
3231  switch (die.Tag()) {
3232  case DW_TAG_compile_unit:
3233  case DW_TAG_partial_unit:
3234  decl_ctx = m_ast.GetTranslationUnitDecl();
3235  try_parsing_type = false;
3236  break;
3237 
3238  case DW_TAG_namespace:
3239  decl_ctx = ResolveNamespaceDIE(die);
3240  try_parsing_type = false;
3241  break;
3242 
3243  case DW_TAG_lexical_block:
3244  decl_ctx = GetDeclContextForBlock(die);
3245  try_parsing_type = false;
3246  break;
3247 
3248  default:
3249  break;
3250  }
3251 
3252  if (decl_ctx == nullptr && try_parsing_type) {
3253  Type *type = die.GetDWARF()->ResolveType(die);
3254  if (type)
3255  decl_ctx = GetCachedClangDeclContextForDIE(die);
3256  }
3257 
3258  if (decl_ctx) {
3259  LinkDeclContextToDIE(decl_ctx, die);
3260  return decl_ctx;
3261  }
3262  }
3263  return nullptr;
3264 }
3265 
3268  if (!die.IsValid())
3269  return {};
3270 
3271  for (DWARFDIE parent = die.GetParent(); parent.IsValid();
3272  parent = parent.GetParent()) {
3273  const dw_tag_t tag = parent.Tag();
3274  if (tag == DW_TAG_module) {
3275  DWARFDIE module_die = parent;
3276  auto it = m_die_to_module.find(module_die.GetDIE());
3277  if (it != m_die_to_module.end())
3278  return it->second;
3279  const char *name =
3280  module_die.GetAttributeValueAsString(DW_AT_name, nullptr);
3281  if (!name)
3282  return {};
3283 
3286  m_die_to_module.insert({module_die.GetDIE(), id});
3287  return id;
3288  }
3289  }
3290  return {};
3291 }
3292 
3293 static bool IsSubroutine(const DWARFDIE &die) {
3294  switch (die.Tag()) {
3295  case DW_TAG_subprogram:
3296  case DW_TAG_inlined_subroutine:
3297  return true;
3298  default:
3299  return false;
3300  }
3301 }
3302 
3304  for (DWARFDIE candidate = die; candidate; candidate = candidate.GetParent()) {
3305  if (IsSubroutine(candidate)) {
3306  if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3307  return candidate;
3308  } else {
3309  return DWARFDIE();
3310  }
3311  }
3312  }
3313  assert(0 && "Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3314  "something not in a function");
3315  return DWARFDIE();
3316 }
3317 
3319  for (DWARFDIE candidate : context.children()) {
3320  if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3321  return candidate;
3322  }
3323  }
3324  return DWARFDIE();
3325 }
3326 
3328  const DWARFDIE &function) {
3329  assert(IsSubroutine(function));
3330  for (DWARFDIE context = block; context != function.GetParent();
3331  context = context.GetParent()) {
3332  assert(!IsSubroutine(context) || context == function);
3333  if (DWARFDIE child = FindAnyChildWithAbstractOrigin(context)) {
3334  return child;
3335  }
3336  }
3337  return DWARFDIE();
3338 }
3339 
3340 clang::DeclContext *
3342  assert(die.Tag() == DW_TAG_lexical_block);
3343  DWARFDIE containing_function_with_abstract_origin =
3345  if (!containing_function_with_abstract_origin) {
3346  return (clang::DeclContext *)ResolveBlockDIE(die);
3347  }
3349  die, containing_function_with_abstract_origin);
3350  CompilerDeclContext decl_context =
3352  return (clang::DeclContext *)decl_context.GetOpaqueDeclContext();
3353 }
3354 
3355 clang::BlockDecl *DWARFASTParserClang::ResolveBlockDIE(const DWARFDIE &die) {
3356  if (die && die.Tag() == DW_TAG_lexical_block) {
3357  clang::BlockDecl *decl =
3358  llvm::cast_or_null<clang::BlockDecl>(m_die_to_decl_ctx[die.GetDIE()]);
3359 
3360  if (!decl) {
3361  DWARFDIE decl_context_die;
3362  clang::DeclContext *decl_context =
3363  GetClangDeclContextContainingDIE(die, &decl_context_die);
3364  decl =
3366 
3367  if (decl)
3368  LinkDeclContextToDIE((clang::DeclContext *)decl, die);
3369  }
3370 
3371  return decl;
3372  }
3373  return nullptr;
3374 }
3375 
3376 clang::NamespaceDecl *
3378  if (die && die.Tag() == DW_TAG_namespace) {
3379  // See if we already parsed this namespace DIE and associated it with a
3380  // uniqued namespace declaration
3381  clang::NamespaceDecl *namespace_decl =
3382  static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]);
3383  if (namespace_decl)
3384  return namespace_decl;
3385  else {
3386  const char *namespace_name = die.GetName();
3387  clang::DeclContext *containing_decl_ctx =
3388  GetClangDeclContextContainingDIE(die, nullptr);
3389  bool is_inline =
3390  die.GetAttributeValueAsUnsigned(DW_AT_export_symbols, 0) != 0;
3391 
3392  namespace_decl = m_ast.GetUniqueNamespaceDeclaration(
3393  namespace_name, containing_decl_ctx, GetOwningClangModule(die),
3394  is_inline);
3395 
3396  if (namespace_decl)
3397  LinkDeclContextToDIE((clang::DeclContext *)namespace_decl, die);
3398  return namespace_decl;
3399  }
3400  }
3401  return nullptr;
3402 }
3403 
3405  const DWARFDIE &die, DWARFDIE *decl_ctx_die_copy) {
3406  SymbolFileDWARF *dwarf = die.GetDWARF();
3407 
3408  DWARFDIE decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE(die);
3409 
3410  if (decl_ctx_die_copy)
3411  *decl_ctx_die_copy = decl_ctx_die;
3412 
3413  if (decl_ctx_die) {
3414  clang::DeclContext *clang_decl_ctx =
3415  GetClangDeclContextForDIE(decl_ctx_die);
3416  if (clang_decl_ctx)
3417  return clang_decl_ctx;
3418  }
3419  return m_ast.GetTranslationUnitDecl();
3420 }
3421 
3422 clang::DeclContext *
3424  if (die) {
3425  DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE());
3426  if (pos != m_die_to_decl_ctx.end())
3427  return pos->second;
3428  }
3429  return nullptr;
3430 }
3431 
3432 void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx,
3433  const DWARFDIE &die) {
3434  m_die_to_decl_ctx[die.GetDIE()] = decl_ctx;
3435  // There can be many DIEs for a single decl context
3436  // m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE());
3437  m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die));
3438 }
3439 
3441  const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die,
3442  lldb_private::Type *class_type, std::vector<DWARFDIE> &failures) {
3443  if (!class_type || !src_class_die || !dst_class_die)
3444  return false;
3445  if (src_class_die.Tag() != dst_class_die.Tag())
3446  return false;
3447 
3448  // We need to complete the class type so we can get all of the method types
3449  // parsed so we can then unique those types to their equivalent counterparts
3450  // in "dst_cu" and "dst_class_die"
3451  class_type->GetFullCompilerType();
3452 
3453  auto gather = [](DWARFDIE die, UniqueCStringMap<DWARFDIE> &map,
3454  UniqueCStringMap<DWARFDIE> &map_artificial) {
3455  if (die.Tag() != DW_TAG_subprogram)
3456  return;
3457  // Make sure this is a declaration and not a concrete instance by looking
3458  // for DW_AT_declaration set to 1. Sometimes concrete function instances are
3459  // placed inside the class definitions and shouldn't be included in the list
3460  // of things are are tracking here.
3461  if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) != 1)
3462  return;
3463 
3464  if (const char *name = die.GetMangledName()) {
3465  ConstString const_name(name);
3466  if (die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
3467  map_artificial.Append(const_name, die);
3468  else
3469  map.Append(const_name, die);
3470  }
3471  };
3472 
3473  UniqueCStringMap<DWARFDIE> src_name_to_die;
3474  UniqueCStringMap<DWARFDIE> dst_name_to_die;
3475  UniqueCStringMap<DWARFDIE> src_name_to_die_artificial;
3476  UniqueCStringMap<DWARFDIE> dst_name_to_die_artificial;
3477  for (DWARFDIE src_die = src_class_die.GetFirstChild(); src_die.IsValid();
3478  src_die = src_die.GetSibling()) {
3479  gather(src_die, src_name_to_die, src_name_to_die_artificial);
3480  }
3481  for (DWARFDIE dst_die = dst_class_die.GetFirstChild(); dst_die.IsValid();
3482  dst_die = dst_die.GetSibling()) {
3483  gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3484  }
3485  const uint32_t src_size = src_name_to_die.GetSize();
3486  const uint32_t dst_size = dst_name_to_die.GetSize();
3487 
3488  // Is everything kosher so we can go through the members at top speed?
3489  bool fast_path = true;
3490 
3491  if (src_size != dst_size)
3492  fast_path = false;
3493 
3494  uint32_t idx;
3495 
3496  if (fast_path) {
3497  for (idx = 0; idx < src_size; ++idx) {
3498  DWARFDIE src_die = src_name_to_die.GetValueAtIndexUnchecked(idx);
3499  DWARFDIE dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
3500 
3501  if (src_die.Tag() != dst_die.Tag())
3502  fast_path = false;
3503 
3504  const char *src_name = src_die.GetMangledName();
3505  const char *dst_name = dst_die.GetMangledName();
3506 
3507  // Make sure the names match
3508  if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3509  continue;
3510 
3511  fast_path = false;
3512  }
3513  }
3514 
3515  DWARFASTParserClang *src_dwarf_ast_parser =
3516  static_cast<DWARFASTParserClang *>(
3517  SymbolFileDWARF::GetDWARFParser(*src_class_die.GetCU()));
3518  DWARFASTParserClang *dst_dwarf_ast_parser =
3519  static_cast<DWARFASTParserClang *>(
3520  SymbolFileDWARF::GetDWARFParser(*dst_class_die.GetCU()));
3521  auto link = [&](DWARFDIE src, DWARFDIE dst) {
3522  SymbolFileDWARF::DIEToTypePtr &die_to_type =
3523  dst_class_die.GetDWARF()->GetDIEToType();
3524  clang::DeclContext *dst_decl_ctx =
3525  dst_dwarf_ast_parser->m_die_to_decl_ctx[dst.GetDIE()];
3526  if (dst_decl_ctx)
3527  src_dwarf_ast_parser->LinkDeclContextToDIE(dst_decl_ctx, src);
3528 
3529  if (Type *src_child_type = die_to_type[src.GetDIE()])
3530  die_to_type[dst.GetDIE()] = src_child_type;
3531  };
3532 
3533  // Now do the work of linking the DeclContexts and Types.
3534  if (fast_path) {
3535  // We can do this quickly. Just run across the tables index-for-index
3536  // since we know each node has matching names and tags.
3537  for (idx = 0; idx < src_size; ++idx) {
3538  link(src_name_to_die.GetValueAtIndexUnchecked(idx),
3539  dst_name_to_die.GetValueAtIndexUnchecked(idx));
3540  }
3541  } else {
3542  // We must do this slowly. For each member of the destination, look up a
3543  // member in the source with the same name, check its tag, and unique them
3544  // if everything matches up. Report failures.
3545 
3546  if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty()) {
3547  src_name_to_die.Sort();
3548 
3549  for (idx = 0; idx < dst_size; ++idx) {
3550  ConstString dst_name = dst_name_to_die.GetCStringAtIndex(idx);
3551  DWARFDIE dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
3552  DWARFDIE src_die = src_name_to_die.Find(dst_name, DWARFDIE());
3553 
3554  if (src_die && (src_die.Tag() == dst_die.Tag()))
3555  link(src_die, dst_die);
3556  else
3557  failures.push_back(dst_die);
3558  }
3559  }
3560  }
3561 
3562  const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize();
3563  const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize();
3564 
3565  if (src_size_artificial && dst_size_artificial) {
3566  dst_name_to_die_artificial.Sort();
3567 
3568  for (idx = 0; idx < src_size_artificial; ++idx) {
3569  ConstString src_name_artificial =
3570  src_name_to_die_artificial.GetCStringAtIndex(idx);
3571  DWARFDIE src_die =
3572  src_name_to_die_artificial.GetValueAtIndexUnchecked(idx);
3573  DWARFDIE dst_die =
3574  dst_name_to_die_artificial.Find(src_name_artificial, DWARFDIE());
3575 
3576  // Both classes have the artificial types, link them
3577  if (dst_die)
3578  link(src_die, dst_die);
3579  }
3580  }
3581 
3582  if (dst_size_artificial) {
3583  for (idx = 0; idx < dst_size_artificial; ++idx) {
3584  failures.push_back(
3585  dst_name_to_die_artificial.GetValueAtIndexUnchecked(idx));
3586  }
3587  }
3588 
3589  return !failures.empty();
3590 }
lldb_private::Declaration::SetLine
void SetLine(uint32_t line)
Set accessor for the declaration line number.
Definition: Declaration.h:168
lldb_private::ClangASTImporter::LayoutInfo::field_offsets
llvm::DenseMap< const clang::FieldDecl *, uint64_t > field_offsets
Definition: ClangASTImporter.h:73
lldb_private::TypeSystemClang::CreateBlockPointerType
CompilerType CreateBlockPointerType(const CompilerType &function_type)
Definition: TypeSystemClang.cpp:2235
ParsedDWARFTypeAttributes::is_vector
bool is_vector
Definition: DWARFASTParserClang.h:286
DWARFASTParserClang::DelayedAddObjCClassProperty
Definition: DWARFASTParserClang.cpp:1869
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
DWARFASTParserClang::CopyUniqueClassMethodTypes
bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die, lldb_private::Type *class_type, std::vector< DWARFDIE > &failures)
Definition: DWARFASTParserClang.cpp:3440
SymbolFileDWARFDebugMap.h
lldb_private::TypeSystemClang::CreateParameterDeclaration
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType &param_type, int storage, bool add_decl=false)
Definition: TypeSystemClang.cpp:2210
lldb_private::TypeSystemClang::CreateBlockDeclaration
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
Definition: TypeSystemClang.cpp:1921
lldb_private::DW_TAG_value_to_name
const char * DW_TAG_value_to_name(uint32_t val)
Definition: DWARFDefines.cpp:17
DWARFASTParserClang::DelayedAddObjCClassProperty::m_metadata_up
std::unique_ptr< ClangASTMetadata > m_metadata_up
Definition: DWARFASTParserClang.cpp:1923
DWARFASTParserClang::GetTypeForDIE
lldb_private::Type * GetTypeForDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3105
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::ClangASTImporter::CopyType
CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
Definition: ClangASTImporter.cpp:32
lldb_private::Type::EncodingDataType
EncodingDataType
Definition: Type.h:68
DWARFFormValue::Reference
DWARFDIE Reference() const
Definition: DWARFFormValue.cpp:502
DWARFDIE::GetParent
DWARFDIE GetParent() const
Definition: DWARFDIE.cpp:91
lldb_private::UniqueCStringMap::Sort
void Sort()
Definition: UniqueCStringMap.h:168
DWARFBaseDIE::GetData
const lldb_private::DWARFDataExtractor & GetData() const
Definition: DWARFBaseDIE.cpp:130
FindFirstChildWithAbstractOrigin
static DWARFDIE FindFirstChildWithAbstractOrigin(const DWARFDIE &block, const DWARFDIE &function)
Definition: DWARFASTParserClang.cpp:3327
lldb_private::TypeSystemClang::TransferBaseClasses
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier >> bases)
Definition: TypeSystemClang.cpp:7823
lldb_private::TypeSystemClang::GetCompilerDecl
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
Definition: TypeSystemClang.h:462
lldb_private::TypeSystemClang::getASTContext
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
Definition: TypeSystemClang.cpp:686
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
DWARFASTParserClang::DelayedAddObjCClassProperty::DelayedAddObjCClassProperty
DelayedAddObjCClassProperty(const CompilerType &class_opaque_type, const char *property_name, const CompilerType &property_opaque_type, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, const ClangASTMetadata *metadata)
Definition: DWARFASTParserClang.cpp:1871
ParsedDWARFTypeAttributes::name
lldb_private::ConstString name
Definition: DWARFASTParserClang.h:292
DWARFBaseDIE::GetDIERef
llvm::Optional< DIERef > GetDIERef() const
Definition: DWARFBaseDIE.cpp:21
lldb_private::TypeSystemClang::CreateDeclContext
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
Definition: TypeSystemClang.cpp:1200
ParsedDWARFTypeAttributes
Parsed form of all attributes that are relevant for type reconstruction.
Definition: DWARFASTParserClang.h:276
CompileUnit.h
lldb_private::TypeSystemClang::CreateTemplateTemplateParmDecl
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
Definition: TypeSystemClang.cpp:1640
lldb::eRegisterKindDWARF
@ eRegisterKindDWARF
the register numbers seen DWARF
Definition: lldb-enumerations.h:229
lldb_private::TypeSystemClang::CreateFunctionType
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C)
Definition: TypeSystemClang.cpp:2172
DWARFASTParserClang::GetCachedClangDeclContextForDIE
clang::DeclContext * GetCachedClangDeclContextForDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3423
lldb_private::CompilerType::IsDefined
bool IsDefined() const
Definition: CompilerType.cpp:201
TypeMap.h
ParsedDWARFTypeAttributes::type
DWARFFormValue type
Definition: DWARFASTParserClang.h:299
lldb_private::Value
Definition: Value.h:38
DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type
bool Supports_DW_AT_APPLE_objc_complete_type() const
Definition: DWARFBaseDIE.cpp:110
ParsedDWARFTypeAttributes::is_forward_declaration
bool is_forward_declaration
Definition: DWARFASTParserClang.h:283
DWARFASTParserClang::DelayedAddObjCClassProperty::m_property_setter_name
const char * m_property_setter_name
Definition: DWARFASTParserClang.cpp:1920
Host.h
SymbolFileDWARF::GetParentSymbolContextDIE
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:390
lldb_private::TypeMap::GetTypeAtIndex
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeMap.cpp:83
DWARFASTParserClang::ParseChildMembers
bool ParseChildMembers(const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier >> &base_classes, std::vector< DWARFDIE > &member_function_dies, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
Definition: DWARFASTParserClang.cpp:2934
DWARFBaseDIE::GetAttributes
size_t GetAttributes(DWARFAttributes &attributes, Recurse recurse=Recurse::yes) const
Definition: DWARFBaseDIE.cpp:114
lldb_private::CompilerDeclContext::GetOpaqueDeclContext
void * GetOpaqueDeclContext() const
Definition: CompilerDeclContext.h:103
lldb_private::TypeSystemClang::CreateFunctionDeclaration
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline)
Definition: TypeSystemClang.cpp:2139
lldb_private::TypeSystemClang::GetTranslationUnitDecl
clang::TranslationUnitDecl * GetTranslationUnitDecl()
Definition: TypeSystemClang.h:223
dw_tag_t
llvm::dwarf::Tag dw_tag_t
Definition: dwarf.h:28
DWARFASTParserClang::DelayedPropertyList
std::vector< DelayedAddObjCClassProperty > DelayedPropertyList
Definition: DWARFASTParserClang.h:93
DWARFASTParser::ParseChildArrayInfo
static llvm::Optional< lldb_private::SymbolFile::ArrayInfo > ParseChildArrayInfo(const DWARFDIE &parent_die, const lldb_private::ExecutionContext *exe_ctx=nullptr)
Definition: DWARFASTParser.cpp:22
ParsedDWARFTypeAttributes::class_language
lldb::LanguageType class_language
Definition: DWARFASTParserClang.h:300
lldb_private::ClangASTMetadata::SetUserID
void SetUserID(lldb::user_id_t user_id)
Definition: ClangASTMetadata.h:29
lldb_private::Type::GetLayoutCompilerType
CompilerType GetLayoutCompilerType()
Definition: Type.cpp:650
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
lldb_private::CompilerType::IsCompleteType
bool IsCompleteType() const
Definition: CompilerType.cpp:83
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::CompilerDecl::GetOpaqueDecl
void * GetOpaqueDecl() const
Definition: CompilerDecl.h:58
DWARFASTParserClang::ResolveNamespaceDIE
clang::NamespaceDecl * ResolveNamespaceDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3377
lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
Definition: TypeSystemClang.cpp:795
Module.h
DWARFASTParserClang::ParseArrayType
lldb::TypeSP ParseArrayType(const DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:1296
ParsedDWARFTypeAttributes::signature
DWARFFormValue signature
Definition: DWARFASTParserClang.h:297
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation)
Definition: SymbolFileDWARFDebugMap.cpp:1128
lldb_private::TypeSystemClang::CreateEnumerationType
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
Definition: TypeSystemClang.cpp:2309
IsClangModuleFwdDecl
static bool IsClangModuleFwdDecl(const DWARFDIE &Die)
Detect a forward declaration that is nested in a DW_TAG_module.
Definition: DWARFASTParserClang.cpp:87
DWARFASTParserClang::GetDeclForUIDFromDWARF
lldb_private::CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) override
Definition: DWARFASTParserClang.cpp:2207
SymbolFileDWARF
Definition: SymbolFileDWARF.h:60
DWARFASTParserClang::DelayedAddObjCClassProperty::m_property_attributes
uint32_t m_property_attributes
Definition: DWARFASTParserClang.cpp:1922
DIE_IS_BEING_PARSED
#define DIE_IS_BEING_PARSED
Definition: SymbolFileDWARF.h:58
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
SymbolFileDWARF.h
lldb_private::ClangASTImporter::LayoutInfo
Definition: ClangASTImporter.h:66
ParsedDWARFTypeAttributes::byte_stride
uint32_t byte_stride
Definition: DWARFASTParserClang.h:304
lldb_private::CompilerDecl
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:301
lldb_private::Module
Definition: Module.h:85
DWARFASTParserClang::ParseTemplateParameterInfos
bool ParseTemplateParameterInfos(const DWARFDIE &parent_die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos)
Definition: DWARFASTParserClang.cpp:2034
lldb_private::CompilerType::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:489
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:173
DWARFDIE::GetDeclContext
void GetDeclContext(llvm::SmallVectorImpl< lldb_private::CompilerContext > &context) const
Return this DIE's decl context as it is needed to look up types in Clang's -gmodules debug info forma...
Definition: DWARFDIE.cpp:388
lldb_private::ClangASTImporter::RequireCompleteType
bool RequireCompleteType(clang::QualType type)
Definition: ClangASTImporter.cpp:684
DWARFBaseDIE::GetDWARF
SymbolFileDWARF * GetDWARF() const
Definition: DWARFBaseDIE.cpp:99
lldb_private::TypePayloadClang
The implementation of lldb::Type's m_payload field for TypeSystemClang.
Definition: TypeSystemClang.h:67
lldb_private::LanguageSet::Insert
void Insert(lldb::LanguageType language)
Definition: TypeSystem.cpp:33
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:302
lldb_private::DWARFDataExtractor
Definition: DWARFDataExtractor.h:18
UniqueDWARFASTType.h
Language.h
lldb_private::UniqueCStringMap::Find
T Find(ConstString unique_cstr, T fail_value) const
Definition: UniqueCStringMap.h:86
DWARFDIE::ResolveType
lldb_private::Type * ResolveType() const
Definition: DWARFDIE.cpp:361
DWARFBaseDIE::GetCU
DWARFUnit * GetCU() const
Definition: DWARFBaseDIE.h:54
DWARFASTParserClang::ParseStructureLikeDIE
lldb::TypeSP ParseStructureLikeDIE(const lldb_private::SymbolContext &sc, const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
Parse a structure, class, or union type DIE.
Definition: DWARFASTParserClang.cpp:1520
DWARFASTParserClang::DelayedAddObjCClassProperty::m_property_opaque_type
CompilerType m_property_opaque_type
Definition: DWARFASTParserClang.cpp:1919
DWARFASTParserClang::DelayedAddObjCClassProperty::m_property_getter_name
const char * m_property_getter_name
Definition: DWARFASTParserClang.cpp:1921
ForcefullyCompleteType
static void ForcefullyCompleteType(CompilerType type)
Definition: DWARFASTParserClang.cpp:221
IsSubroutine
static bool IsSubroutine(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3293
lldb_private::SymbolContext
Definition: SymbolContext.h:33
DWARFASTParserClang::ParseFunctionFromDWARF
lldb_private::Function * ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die, const lldb_private::AddressRange &func_range) override
Definition: DWARFASTParserClang.cpp:2331
DWARFDefines.h
DWARFDIE::ResolveTypeUID
lldb_private::Type * ResolveTypeUID(const DWARFDIE &die) const
Definition: DWARFDIE.cpp:368
lldb_private::TypeMap::GetSize
uint32_t GetSize() const
Definition: TypeMap.cpp:75
lldb_private::ObjCLanguage::MethodName::GetClassName
ConstString GetClassName()
Definition: ObjCLanguage.cpp:110
lldb_private::TypeSystemClang::CreateArrayType
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
Definition: TypeSystemClang.cpp:2244
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
DWARFAttributes
Definition: DWARFAttribute.h:44
DWARFDIE::GetAttributeValueAsReferenceDIE
DWARFDIE GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const
Definition: DWARFDIE.cpp:131
DWARFDeclContext.h
lldb_private::UniqueCStringMap::IsEmpty
bool IsEmpty() const
Definition: UniqueCStringMap.h:151
ClangUtil.h
lldb_private::CompileUnit
Definition: CompileUnit.h:38
lldb_private::CompilerType::IsIntegerOrEnumerationType
bool IsIntegerOrEnumerationType(bool &is_signed) const
Definition: CompilerType.cpp:153
DWARFDIE
Definition: DWARFDIE.h:16
DWARFFormValue::Boolean
bool Boolean() const
Definition: DWARFFormValue.h:63
DWARFASTParserClang::GetClangDeclForDIE
clang::Decl * GetClangDeclForDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3126
lldb_private::Type::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
Definition: Type.cpp:340
lldb_private::Type::ResolveState
ResolveState
Definition: Type.h:96
DEBUG_PRINTF
#define DEBUG_PRINTF(fmt,...)
Definition: DWARFASTParserClang.cpp:56
lldb_private::UniqueCStringMap::GetValueAtIndexUnchecked
T GetValueAtIndexUnchecked(uint32_t idx) const
Definition: UniqueCStringMap.h:68
lldb_private::ClangASTImporter::LayoutInfo::base_offsets
OffsetMap base_offsets
Definition: ClangASTImporter.h:74
lldb::eEncodingInvalid
@ eEncodingInvalid
Definition: lldb-enumerations.h:147
SymbolFileDWARFDwo.h
DWARFASTParserClang::LinkDeclContextToDIE
void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3432
DWARFASTParserClang::ParseChildParameters
size_t ParseChildParameters(clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, bool &has_template_params, std::vector< lldb_private::CompilerType > &function_args, std::vector< clang::ParmVarDecl * > &function_param_decls, unsigned &type_quals)
Definition: DWARFASTParserClang.cpp:2983
lldb::eEncodingSint
@ eEncodingSint
signed integer
Definition: lldb-enumerations.h:149
DWARFASTParserClang::GetClangDeclContextContainingDIE
clang::DeclContext * GetClangDeclContextContainingDIE(const DWARFDIE &die, DWARFDIE *decl_ctx_die)
Definition: DWARFASTParserClang.cpp:3404
GetUnitName
static std::string GetUnitName(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:419
lldb_private::Function
Definition: Function.h:409
SymbolFileDWARF::ForEachExternalModule
bool ForEachExternalModule(lldb_private::CompileUnit &, llvm::DenseSet< lldb_private::SymbolFile * > &, llvm::function_ref< bool(lldb_private::Module &)>) override
Definition: SymbolFileDWARF.cpp:961
DWARFUnit
Definition: DWARFUnit.h:83
DWARFASTParserClang::ExtractIntFromFormValue
llvm::Expected< llvm::APInt > ExtractIntFromFormValue(const lldb_private::CompilerType &int_type, const DWARFFormValue &form_value) const
Extracts an value for a given Clang integer type from a DWARFFormValue.
Definition: DWARFASTParserClang.cpp:2615
DWARFASTParserClang::ConstructDemangledNameFromDWARF
lldb_private::ConstString ConstructDemangledNameFromDWARF(const DWARFDIE &die) override
Definition: DWARFASTParserClang.cpp:2298
LLDBAssert.h
DWARFASTParserClang::UpdateSymbolContextScopeForType
lldb::TypeSP UpdateSymbolContextScopeForType(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb::TypeSP type_sp)
If type_sp is valid, calculate and set its symbol context scope, and update the type list for its bac...
Definition: DWARFASTParserClang.cpp:1490
lldb_private::ConstString::SetString
void SetString(const llvm::StringRef &s)
Definition: ConstString.cpp:305
DeclKindIsCXXClass
static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind)
Definition: DWARFASTParserClang.cpp:67
ClangASTMetadata.h
DWARFDIE::GetQualifiedName
const char * GetQualifiedName(std::string &storage) const
Definition: DWARFDIE.cpp:218
DWARFASTParserClang::GetClangDeclContextForDIE
clang::DeclContext * GetClangDeclContextForDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3224
dwarf
Definition: ABISysV_arc.cpp:61
lldb_private::TypeSystemClang::GetAsCXXRecordDecl
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
Definition: TypeSystemClang.cpp:7304
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
ParsedDWARFTypeAttributes::storage
clang::StorageClass storage
Definition: DWARFASTParserClang.h:290
SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext
lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx)
Definition: SymbolFileDWARFDebugMap.cpp:1102
Log.h
DWARFASTParserClang::DelayedAddObjCClassProperty::Finalize
bool Finalize()
Definition: DWARFASTParserClang.cpp:1909
ParsedDWARFTypeAttributes::is_inline
bool is_inline
Definition: DWARFASTParserClang.h:284
lldb_private::UniqueCStringMap::GetSize
size_t GetSize() const
Definition: UniqueCStringMap.h:148
lldb_private::ClangASTMetadata::SetObjectPtrName
void SetObjectPtrName(const char *name)
Definition: ClangASTMetadata.h:55
lldb_private::Declaration::SetColumn
void SetColumn(uint16_t column)
Set accessor for the declaration column number.
Definition: Declaration.h:175
DWARFASTParserClang::FieldInfo::NextBitfieldOffsetIsValid
bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const
Definition: DWARFASTParserClang.h:203
lldb_private::Function::GetBlock
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:345
DWARFASTParserClang::m_die_to_module
DIEToModuleMap m_die_to_module
Definition: DWARFASTParserClang.h:110
DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF
lldb_private::CompilerDeclContext GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override
Definition: DWARFASTParserClang.cpp:2223
lldb_private::TypeMap::Empty
bool Empty() const
Definition: TypeMap.cpp:77
DWARFASTParserClang::CompleteRecordType
bool CompleteRecordType(const DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &clang_type)
Definition: DWARFASTParserClang.cpp:2059
DWARFASTParserClang::ParseTypeFromDWARF
lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, bool *type_is_new_ptr) override
Definition: DWARFASTParserClang.cpp:425
DWARFDeclContext::GetQualifiedName
const char * GetQualifiedName() const
Definition: DWARFDeclContext.cpp:13
ParsedDWARFTypeAttributes::accessibility
lldb::AccessType accessibility
Definition: DWARFASTParserClang.h:279
DWARFASTParserClang::FieldInfo::bit_offset
uint64_t bit_offset
Definition: DWARFASTParserClang.h:195
lldb::eAccessNone
@ eAccessNone
Definition: lldb-enumerations.h:508
lldb_private::TypeSystemClang::SetMetadata
void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data)
Definition: TypeSystemClang.cpp:2556
lldb_private::TypeSystemClang::SetObjCSuperClass
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
Definition: TypeSystemClang.cpp:7842
DWARFBaseDIE::GetTagAsCString
const char * GetTagAsCString() const
Definition: DWARFBaseDIE.cpp:36
DWARFASTParserClang::FieldInfo::SetIsBitfield
void SetIsBitfield(bool flag)
Definition: DWARFASTParserClang.h:200
DWARFDIE::GetName
void GetName(lldb_private::Stream &s) const
Definition: DWARFDIE.cpp:230
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
StreamString.h
SymbolFileDWARF::GetLanguageFamily
static lldb::LanguageType GetLanguageFamily(DWARFUnit &unit)
Same as GetLanguage() but reports all C++ versions as C++ (no version).
Definition: SymbolFileDWARF.cpp:4112
lldb_private::CompileUnit::AddFunction
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
Definition: CompileUnit.cpp:139
DWARFASTParser.h
lldb::eBasicTypeInt
@ eBasicTypeInt
Definition: lldb-enumerations.h:761
DWARFDIE::GetMangledName
const char * GetMangledName() const
Definition: DWARFDIE.cpp:204
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::ConstString
Definition: ConstString.h:39
SymbolFileDWARFDebugMap
Definition: SymbolFileDWARFDebugMap.h:25
GetContainingClangModule
static lldb::ModuleSP GetContainingClangModule(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:118
lldb_private::TypeSystemClang::GetTypeForDecl
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
Definition: TypeSystemClang.cpp:1206
lldb_private::ObjectFile::GetByteOrder
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::AddressRange
Definition: AddressRange.h:25
ParsedDWARFTypeAttributes::abstract_origin
DWARFFormValue abstract_origin
Definition: DWARFASTParserClang.h:295
lldb_private::Scalar::UInt
unsigned int UInt(unsigned int fail_value=0) const
Definition: Scalar.cpp:320
SymbolFileDWARF::GetDWARFDeclContext
static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4086
ObjCLanguage.h
DWARFUnit::Supports_unnamed_objc_bitfields
bool Supports_unnamed_objc_bitfields()
Definition: DWARFUnit.cpp:673
SymbolFileDWARF::DIEToTypePtr
llvm::DenseMap< const DWARFDebugInfoEntry *, lldb_private::Type * > DIEToTypePtr
Definition: SymbolFileDWARF.h:338
DWARFFormValue
Definition: DWARFFormValue.h:20
SymbolFileDWARF::GetDIEToType
virtual DIEToTypePtr & GetDIEToType()
Definition: SymbolFileDWARF.h:495
lldb_private::ClangASTMetadata::SetIsDynamicCXXType
void SetIsDynamicCXXType(bool b)
Definition: ClangASTMetadata.h:27
GetContainingClangModuleDIE
static DWARFDIE GetContainingClangModuleDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:99
lldb_private::Declaration::SetFile
void SetFile(const FileSpec &file_spec)
Set accessor for the declaration file specification.
Definition: Declaration.h:161
DWARFFormValue::Clear
void Clear()
Definition: DWARFFormValue.cpp:25
DWARFASTParserClang::DelayedAddObjCClassProperty::m_class_opaque_type
CompilerType m_class_opaque_type
Definition: DWARFASTParserClang.cpp:1917
lldb::eBasicTypeVoid
@ eBasicTypeVoid
Definition: lldb-enumerations.h:749
DWARFASTParserClang::ParseInheritance
void ParseInheritance(const DWARFDIE &die, const DWARFDIE &parent_die, const lldb_private::CompilerType class_clang_type, const lldb::AccessType default_accessibility, const lldb::ModuleSP &module_sp, std::vector< std::unique_ptr< clang::CXXBaseSpecifier >> &base_classes, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
Parses a DW_TAG_inheritance DIE into a base/super class.
Definition: DWARFASTParserClang.cpp:1373
DWARFDIE::GetReferencedDIE
DWARFDIE GetReferencedDIE(const dw_attr_t attr) const
Definition: DWARFDIE.cpp:115
lldb_private::TypeSystemClang::CreateClassTemplateSpecializationType
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
Definition: TypeSystemClang.cpp:1697
DWARFASTParserClang::m_die_to_decl_ctx
DIEToDeclContextMap m_die_to_decl_ctx
Definition: DWARFASTParserClang.h:108
lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
Definition: TypeSystemClang.cpp:1857
lldb_private::CompilerType::IsIntegerType
bool IsIntegerType(bool &is_signed) const
Definition: CompilerType.cpp:141
DWARFBaseDIE::GetAttributeValueAsString
const char * GetAttributeValueAsString(const dw_attr_t attr, const char *fail_value) const
Definition: DWARFBaseDIE.cpp:40
FindAnyChildWithAbstractOrigin
static DWARFDIE FindAnyChildWithAbstractOrigin(const DWARFDIE &context)
Definition: DWARFASTParserClang.cpp:3318
lldb::eLanguageTypeObjC
@ eLanguageTypeObjC
Objective-C.
Definition: lldb-enumerations.h:453
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
DWARFDIE::GetFirstChild
DWARFDIE GetFirstChild() const
Definition: DWARFDIE.cpp:99
DWARFDebugInfo.h
lldb_private::TypeSystemClang::TemplateParameterInfos::pack_name
const char * pack_name
Definition: TypeSystemClang.h:338
SymbolFileDWARF::GetExternalModule
lldb::ModuleSP GetExternalModule(lldb_private::ConstString name)
Definition: SymbolFileDWARF.cpp:1680
lldb_private::TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
Definition: TypeSystemClang.cpp:941
lldb_private::ClangASTMetadata
Definition: ClangASTMetadata.h:18
ParsedDWARFTypeAttributes::is_explicit
bool is_explicit
Definition: DWARFASTParserClang.h:282
lldb_private::DWARFExpressionList::IsValid
bool IsValid() const
Return true if the location expression contains data.
Definition: DWARFExpressionList.h:40
lldb::eBasicTypeObjCClass
@ eBasicTypeObjCClass
Definition: lldb-enumerations.h:778
lldb::eLanguageTypeObjC_plus_plus
@ eLanguageTypeObjC_plus_plus
Objective-C++.
Definition: lldb-enumerations.h:454
DWARFAttributes::ExtractFormValueAtIndex
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
Definition: DWARFAttribute.cpp:38
lldb_private::RangeVector
Definition: RangeMap.h:136
ParsedDWARFTypeAttributes::is_objc_direct_call
bool is_objc_direct_call
Definition: DWARFASTParserClang.h:288
lldb_private::ObjCLanguage::MethodName
Definition: ObjCLanguage.h:26
lldb_private::TypeSystemClang::GetOrCreateClangModule
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
Definition: TypeSystemClang.cpp:1236
DWARFFormValue::Unsigned
uint64_t Unsigned() const
Definition: DWARFFormValue.h:64
ParsedDWARFTypeAttributes::bit_stride
uint32_t bit_stride
Definition: DWARFASTParserClang.h:303
lldb_private::UniqueCStringMap
Definition: UniqueCStringMap.h:26
lldb_private::TypeMap
Definition: TypeMap.h:20
SymbolFileDWARF::GetDWARFParser
static DWARFASTParser * GetDWARFParser(DWARFUnit &unit)
Definition: SymbolFileDWARF.cpp:4057
DWARFFormValue::Signed
int64_t Signed() const
Definition: DWARFFormValue.h:66
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
DWARFASTParserClang::FieldInfo
Definition: DWARFASTParserClang.h:193
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
ObjectFile.h
DWARFASTParserClang::GetClangASTImporter
lldb_private::ClangASTImporter & GetClangASTImporter()
Definition: DWARFASTParserClang.cpp:79
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::TypeSystemClang::GetType
CompilerType GetType(clang::QualType qt)
Creates a CompilerType form the given QualType with the current TypeSystemClang instance as the Compi...
Definition: TypeSystemClang.h:237
lldb_private::Type::GetEncodingMask
uint32_t GetEncodingMask()
Definition: Type.cpp:636
lldb_private::TypeSystemClang::AddMethodOverridesForCXXRecordType
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
Definition: TypeSystemClang.cpp:7800
lldb_private::CompilerType::GetCompleteType
bool GetCompleteType() const
Type Completion.
Definition: CompilerType.cpp:264
lldb_private::ClangASTImporter::SetRecordLayout
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
Definition: ClangASTImporter.cpp:548
lldb_private::Value::ResolveValue
Scalar & ResolveValue(ExecutionContext *exe_ctx)
Definition: Value.cpp:560
lldb_private::TypeSystemClang::SetFunctionParameters
void SetFunctionParameters(clang::FunctionDecl *function_decl, llvm::ArrayRef< clang::ParmVarDecl * > params)
Definition: TypeSystemClang.cpp:2228
lldb_private::ClangASTImporter::LayoutInfo::vbase_offsets
OffsetMap vbase_offsets
Definition: ClangASTImporter.h:75
lldb_private::Declaration::Clear
void Clear()
Clear the object's state.
Definition: Declaration.h:57
lldb::eAccessPublic
@ eAccessPublic
Definition: lldb-enumerations.h:509
SymbolFileDWARF::ResolveType
lldb_private::Type * ResolveType(const DWARFDIE &die, bool assert_not_being_parsed=true, bool resolve_function_context=false)
Definition: SymbolFileDWARF.cpp:1616
lldb::eBasicTypeObjCID
@ eBasicTypeObjCID
Definition: lldb-enumerations.h:777
TypeList.h
ParsedDWARFTypeAttributes::calling_convention
size_t calling_convention
Definition: DWARFASTParserClang.h:302
DWARFASTParserClang::DelayedAddObjCClassProperty::operator=
DelayedAddObjCClassProperty & operator=(const DelayedAddObjCClassProperty &rhs)
Definition: DWARFASTParserClang.cpp:1894
lldb_private::UniqueCStringMap::GetCStringAtIndex
ConstString GetCStringAtIndex(uint32_t idx) const
Definition: UniqueCStringMap.h:76
DWARFASTParserClang::FieldInfo::IsBitfield
bool IsBitfield()
Definition: DWARFASTParserClang.h:201
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
ParsedDWARFTypeAttributes::encoding
uint32_t encoding
Definition: DWARFASTParserClang.h:305
DWARFASTParserClang::~DWARFASTParserClang
~DWARFASTParserClang() override
DWARFASTParserClang
Definition: DWARFASTParserClang.h:37
ParsedDWARFTypeAttributes::is_complete_objc_class
bool is_complete_objc_class
Definition: DWARFASTParserClang.h:281
SymbolFileDWARF::GetDecl
static lldb_private::CompilerDecl GetDecl(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4067
DWARFBaseDIE::GetAttributeValueAsUnsigned
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
Definition: DWARFBaseDIE.cpp:48
lldb_private::TypeSystemClang::ParseClassTemplateDecl
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
Definition: TypeSystemClang.cpp:9320
SymbolFileDWARF::GetLanguage
static lldb::LanguageType GetLanguage(DWARFUnit &unit)
Definition: SymbolFileDWARF.cpp:4108
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:56
ConvertDWARFCallingConventionToClang
static clang::CallingConv ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:866
uint32_t
DWARFASTParserClang::FieldInfo::bit_size
uint64_t bit_size
Definition: DWARFASTParserClang.h:194
DWARFASTParserClang::ParseTypeModifier
lldb::TypeSP ParseTypeModifier(const lldb_private::SymbolContext &sc, const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:535
lldb::eAccessPrivate
@ eAccessPrivate
Definition: lldb-enumerations.h:510
DWARFFormValue::BlockData
const uint8_t * BlockData() const
Definition: DWARFFormValue.cpp:567
lldb_private::CompilerType::SetCompilerType
void SetCompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
Definition: CompilerType.cpp:312
lldb_private::TypeSystemClang::GetEnumerationIntegerType
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
Definition: TypeSystemClang.cpp:4300
ParsedDWARFTypeAttributes::mangled_name
const char * mangled_name
Definition: DWARFASTParserClang.h:291
DWARFASTParserClang.h
DWARFASTParserClang::GetDeclContextForUIDFromDWARF
lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override
Definition: DWARFASTParserClang.cpp:2215
id
void * id
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:20
SymbolFileDWARF::GetDeclContext
static lldb_private::CompilerDeclContext GetDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4073
ParsedDWARFTypeAttributes::byte_size
llvm::Optional< uint64_t > byte_size
Definition: DWARFASTParserClang.h:301
lldb_private::TypeSystemClang::CreateVariableDeclaration
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
Definition: TypeSystemClang.cpp:1989
DWARFASTParserClang::m_die_to_decl
DIEToDeclMap m_die_to_decl
Definition: DWARFASTParserClang.h:107
lldb_private::CompilerType::GetTypeSystem
TypeSystem * GetTypeSystem() const
Accessors.
Definition: CompilerType.h:162
lldb_private::CompilerType::GetBitSize
llvm::Optional< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
Definition: CompilerType.cpp:482
DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed
void EnsureAllDIEsInDeclContextHaveBeenParsed(lldb_private::CompilerDeclContext decl_context) override
Definition: DWARFASTParserClang.cpp:2196
lldb_private::CompilerType::GetTypeName
ConstString GetTypeName() const
Definition: CompilerType.cpp:277
lldb_private::Type
Definition: Type.h:66
DWARFASTParserClang::CompleteTypeFromDWARF
bool CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &compiler_type) override
Definition: DWARFASTParserClang.cpp:2162
RequireCompleteType
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
Definition: DWARFASTParserClang.cpp:234
DWARFBaseDIE::GetOffset
dw_offset_t GetOffset() const
Definition: DWARFBaseDIE.cpp:92
DWARFASTParserClang::m_ast
lldb_private::TypeSystemClang & m_ast
Definition: DWARFASTParserClang.h:106
lldb_private::CompilerType::IsArrayType
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
Definition: CompilerType.cpp:49
DWARFDIE::GetDIE
DWARFDIE GetDIE(dw_offset_t die_offset) const
Definition: DWARFDIE.cpp:123
lldb_private::TypeSystemClang::CreateFunctionTemplateDecl
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
Definition: TypeSystemClang.cpp:1432
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:655
DWARFASTParserClang::ParseEnum
lldb::TypeSP ParseEnum(const lldb_private::SymbolContext &sc, const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:757
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
DWARFASTParserClang::ParseObjCProperty
void ParseObjCProperty(const DWARFDIE &die, const DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, DelayedPropertyList &delayed_properties)
Parses a DW_TAG_APPLE_property DIE and appends the parsed data to the list of delayed Objective-C pro...
Definition: DWARFASTParserClang.cpp:2579
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
uint16_t
lldb::eBasicTypeNullPtr
@ eBasicTypeNullPtr
Definition: lldb-enumerations.h:780
DWARFBaseDIE::GetID
lldb::user_id_t GetID() const
Definition: DWARFBaseDIE.cpp:71
lldb_private::ClangASTImporter
Manages and observes all Clang AST node importing in LLDB.
Definition: ClangASTImporter.h:64
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
DWARFFormValue::AsCString
const char * AsCString() const
Definition: DWARFFormValue.cpp:459
lldb_private::TypeSystemClang::CreateRecordType
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
Definition: TypeSystemClang.cpp:1270
DWARFAttributes::AttributeAtIndex
dw_attr_t AttributeAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:55
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
Function.h
ParsedDWARFTypeAttributes::specification
DWARFFormValue specification
Definition: DWARFASTParserClang.h:298
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
ParsedDWARFTypeAttributes::decl
lldb_private::Declaration decl
Definition: DWARFASTParserClang.h:293
DWARFASTParserClang::ResolveBlockDIE
clang::BlockDecl * ResolveBlockDIE(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3355
lldb_private::TypeSystemClang::TemplateParameterInfos::args
llvm::SmallVector< clang::TemplateArgument, 2 > args
Definition: TypeSystemClang.h:336
lldb_private::SymbolFileCommon::GetObjectFile
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:435
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
ParsedDWARFTypeAttributes::containing_type
DWARFFormValue containing_type
Definition: DWARFASTParserClang.h:296
DWARFDeclContext
Definition: DWARFDeclContext.h:23
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
DWARFDIE::children
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
Definition: DWARFDIE.cpp:465
PrepareContextToReceiveMembers
static void PrepareContextToReceiveMembers(TypeSystemClang &ast, ClangASTImporter &ast_importer, clang::DeclContext *decl_ctx, DWARFDIE die, const char *type_name_cstr)
This function serves a similar purpose as RequireCompleteType above, but it avoids completing the typ...
Definition: DWARFASTParserClang.cpp:255
DWARFASTParserClang::ParseSubroutine
lldb::TypeSP ParseSubroutine(const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:895
lldb_private::Block::FindBlockByID
Block * FindBlockByID(lldb::user_id_t block_id)
Definition: Block.cpp:112
GetContainingFunctionWithAbstractOrigin
static DWARFDIE GetContainingFunctionWithAbstractOrigin(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3303
lldb_private::ObjCLanguage::MethodName::IsValid
bool IsValid(bool strict) const
Definition: ObjCLanguage.h:45
DWARFASTParser::GetAccessTypeFromDWARF
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility)
Definition: DWARFASTParser.cpp:103
lldb_private::TypeSystemClang::GetBasicType
CompilerType GetBasicType(lldb::BasicType type)
Definition: TypeSystemClang.cpp:930
DWARFASTParserClang::DelayedAddObjCClassProperty::DelayedAddObjCClassProperty
DelayedAddObjCClassProperty(const DelayedAddObjCClassProperty &rhs)
Definition: DWARFASTParserClang.cpp:1889
lldb_private::TypeSystemClang::CreateUsingDirectiveDeclaration
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
Definition: TypeSystemClang.cpp:1951
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
lldb_private::CompilerType::IsBeingDefined
bool IsBeingDefined() const
Definition: CompilerType.cpp:256
DWARFASTParserClang::ParseTemplateDIE
bool ParseTemplateDIE(const DWARFDIE &die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos)
Definition: DWARFASTParserClang.cpp:1926
ClangASTImporter.h
lldb_private::TypeSystemClang::AddEnumerationValueToEnumerationType
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
Definition: TypeSystemClang.cpp:8420
lldb_private::LanguageSet
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:40
lldb_private::DWARFExpressionList
Definition: DWARFExpressionList.h:24
ParsedDWARFTypeAttributes::is_scoped_enum
bool is_scoped_enum
Definition: DWARFASTParserClang.h:285
DWARFDIE::GetDIENamesAndRanges
bool GetDIENamesAndRanges(const char *&name, const char *&mangled, DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column, int &call_file, int &call_line, int &call_column, lldb_private::DWARFExpressionList *frame_base) const
Definition: DWARFDIE.cpp:452
DWARFASTParserClang::GetOwningClangModule
lldb_private::OptionalClangModuleID GetOwningClangModule(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3267
DWARFASTParserClang::ParseTypeFromClangModule
lldb::TypeSP ParseTypeFromClangModule(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log)
Follow Clang Module Skeleton CU references to find a type definition.
Definition: DWARFASTParserClang.cpp:132
lldb_private::TypeSystemClang::SetHasExternalStorage
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
Definition: TypeSystemClang.cpp:8212
lldb_private::TypeSystemClang::TemplateParameterInfos
Definition: TypeSystemClang.h:322
lldb::eBasicTypeObjCSel
@ eBasicTypeObjCSel
Definition: lldb-enumerations.h:779
lldb_private::Log
Definition: Log.h:115
DWARFASTParserClang::GetDeclContextForBlock
clang::DeclContext * GetDeclContextForBlock(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:3341
DWARFUnit::GetSymbolFileDWARF
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition: DWARFUnit.h:199
DWARFASTParserClang::ParseSingleMember
void ParseSingleMember(const DWARFDIE &die, const DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info, FieldInfo &last_field_info)
Definition: DWARFASTParserClang.cpp:2667
lldb_private::TypeSystemClang::AddMethodToCXXRecordType
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
Definition: TypeSystemClang.cpp:7604
DWARFASTParserClang::DelayedAddObjCClassProperty::m_property_name
const char * m_property_name
Definition: DWARFASTParserClang.cpp:1918
ParsedDWARFTypeAttributes::is_artificial
bool is_artificial
Definition: DWARFASTParserClang.h:280
ParsedDWARFTypeAttributes::object_pointer
DWARFDIE object_pointer
Definition: DWARFASTParserClang.h:294
DWARFASTParserClang::m_decl_ctx_to_die
DeclContextToDIEMap m_decl_ctx_to_die
Definition: DWARFASTParserClang.h:109
lldb_private::TypeSystemClang::AddMethodToObjCObjectType
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, lldb::AccessType access, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
Definition: TypeSystemClang.cpp:8078
lldb_private::TypeSystemClang::GetDeclContextForType
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
Definition: TypeSystemClang.cpp:2635
lldb_private::ClangASTImporter::CanImport
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
Definition: ClangASTImporter.cpp:358
DWARFASTParserClang::DWARFASTParserClang
DWARFASTParserClang(lldb_private::TypeSystemClang &ast)
Definition: DWARFASTParserClang.cpp:62
ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes
ParsedDWARFTypeAttributes(const DWARFDIE &die)
Definition: DWARFASTParserClang.cpp:290
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::Declaration
Definition: Declaration.h:24
DWARFAttributes::CompileUnitAtIndex
DWARFUnit * CompileUnitAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:51
lldb::eByteOrderLittle
@ eByteOrderLittle
Definition: lldb-enumerations.h:142
lldb_private::TypeSystemClang::CreateUsingDeclaration
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
Definition: TypeSystemClang.cpp:1970
ParsedDWARFTypeAttributes::exports_symbols
bool exports_symbols
Definition: DWARFASTParserClang.h:289
lldb_private::TypeSystemClang::CreateClassTemplateSpecializationDecl
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
Definition: TypeSystemClang.cpp:1663
lldb
Definition: SBAddress.h:15
DWARFBaseDIE::Tag
dw_tag_t Tag() const
Definition: DWARFBaseDIE.cpp:29
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:360
Value.h
lldb_private::TypeSystemClang::CreateFunctionTemplateSpecializationInfo
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
Definition: TypeSystemClang.cpp:1464
lldb_private::Type::GetFullCompilerType
CompilerType GetFullCompilerType()
Definition: Type.cpp:645
lldb_private::TypeSystemClang::SetMetadataAsUserID
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
Definition: TypeSystemClang.cpp:2542
DWARFASTParserClang::CompleteEnumType
bool CompleteEnumType(const DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &clang_type)
Definition: DWARFASTParserClang.cpp:2147
lldb::AccessType
AccessType
Definition: lldb-enumerations.h:507
SymbolFile.h
DWARFASTParserClang::ParsePointerToMemberType
lldb::TypeSP ParsePointerToMemberType(const DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
Definition: DWARFASTParserClang.cpp:1350
DWARFASTParserClang::ParseChildEnumerators
size_t ParseChildEnumerators(lldb_private::CompilerType &compiler_type, bool is_signed, uint32_t enumerator_byte_size, const DWARFDIE &parent_die)
Definition: DWARFASTParserClang.cpp:2231
DWARFBaseDIE::HasChildren
bool HasChildren() const
Definition: DWARFBaseDIE.cpp:106
lldb_private::dwarf
Definition: dwarf.h:19
lldb_private::TypeSystemClang::CreateBaseClassSpecifier
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
Definition: TypeSystemClang.cpp:7810
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb_private::ClangASTImporter::LayoutInfo::bit_size
uint64_t bit_size
Definition: ClangASTImporter.h:71
DWARFASTParserClang::m_clang_ast_importer_up
std::unique_ptr< lldb_private::ClangASTImporter > m_clang_ast_importer_up
Definition: DWARFASTParserClang.h:111
ParsedDWARFTypeAttributes::is_virtual
bool is_virtual
Definition: DWARFASTParserClang.h:287
DWARFFormValue::IsValid
bool IsValid() const
Definition: DWARFFormValue.h:70
UINT64_MAX
#define UINT64_MAX
Definition: lldb-defines.h:23
DWARFUnit::GetFile
lldb_private::FileSpec GetFile(size_t file_idx)
Definition: DWARFUnit.cpp:771
lldb_private::TypeSystemClang::TemplateParameterInfos::names
llvm::SmallVector< const char *, 2 > names
Definition: TypeSystemClang.h:335
DWARFBaseDIE::IsValid
bool IsValid() const
Definition: DWARFBaseDIE.h:45
lldb_private::TypeSystemClang::TemplateParameterInfos::packed_args
std::unique_ptr< TemplateParameterInfos > packed_args
Definition: TypeSystemClang.h:339