xref: /llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (revision 081723b9db84e78d7dd240b46af2aeb3b51b00be)
1 //===-- DWARFASTParserClang.h -----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
11 
12 #include "clang/AST/CharUnits.h"
13 #include "clang/AST/Type.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/SmallPtrSet.h"
16 #include "llvm/ADT/SmallVector.h"
17 
18 #include "DWARFASTParser.h"
19 #include "DWARFDIE.h"
20 #include "DWARFDefines.h"
21 #include "DWARFFormValue.h"
22 #include "LogChannelDWARF.h"
23 #include "lldb/Core/PluginInterface.h"
24 
25 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
26 #include "Plugins/Language/ObjC/ObjCLanguage.h"
27 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
28 
29 #include <optional>
30 #include <vector>
31 
32 namespace lldb_private {
33 class CompileUnit;
34 }
35 namespace lldb_private::plugin {
36 namespace dwarf {
37 class DWARFDebugInfoEntry;
38 class SymbolFileDWARF;
39 } // namespace dwarf
40 } // namespace lldb_private::plugin
41 
42 struct ParsedDWARFTypeAttributes;
43 
44 class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
45 public:
46   DWARFASTParserClang(lldb_private::TypeSystemClang &ast);
47 
48   ~DWARFASTParserClang() override;
49 
50   // DWARFASTParser interface.
51   lldb::TypeSP
52   ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
53                      const lldb_private::plugin::dwarf::DWARFDIE &die,
54                      bool *type_is_new_ptr) override;
55 
56   lldb_private::ConstString ConstructDemangledNameFromDWARF(
57       const lldb_private::plugin::dwarf::DWARFDIE &die) override;
58 
59   lldb_private::Function *
60   ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
61                          const lldb_private::plugin::dwarf::DWARFDIE &die,
62                          lldb_private::AddressRanges func_ranges) override;
63 
64   bool CompleteTypeFromDWARF(
65       const lldb_private::plugin::dwarf::DWARFDIE &die,
66       lldb_private::Type *type,
67       const lldb_private::CompilerType &compiler_type) override;
68 
69   lldb_private::CompilerDecl GetDeclForUIDFromDWARF(
70       const lldb_private::plugin::dwarf::DWARFDIE &die) override;
71 
72   void EnsureAllDIEsInDeclContextHaveBeenParsed(
73       lldb_private::CompilerDeclContext decl_context) override;
74 
75   lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF(
76       const lldb_private::plugin::dwarf::DWARFDIE &die) override;
77 
78   lldb_private::CompilerDeclContext GetDeclContextContainingUIDFromDWARF(
79       const lldb_private::plugin::dwarf::DWARFDIE &die) override;
80 
81   lldb_private::ClangASTImporter &GetClangASTImporter();
82 
83   /// Extracts an value for a given Clang integer type from a DWARFFormValue.
84   ///
85   /// \param int_type The Clang type that defines the bit size and signedness
86   ///                 of the integer that should be extracted. Has to be either
87   ///                 an integer type or an enum type. For enum types the
88   ///                 underlying integer type will be considered as the
89   ///                 expected integer type that should be extracted.
90   /// \param form_value The DWARFFormValue that contains the integer value.
91   /// \return An APInt containing the same integer value as the given
92   ///         DWARFFormValue with the bit width of the given integer type.
93   ///         Returns an error if the value in the DWARFFormValue does not fit
94   ///         into the given integer type or the integer type isn't supported.
95   llvm::Expected<llvm::APInt> ExtractIntFromFormValue(
96       const lldb_private::CompilerType &int_type,
97       const lldb_private::plugin::dwarf::DWARFFormValue &form_value) const;
98 
99   /// Returns the template parameters of a class DWARFDIE as a string.
100   ///
101   /// This is mostly useful for -gsimple-template-names which omits template
102   /// parameters from the DIE name and instead always adds template parameter
103   /// children DIEs.
104   ///
105   /// \param die The struct/class DWARFDIE containing template parameters.
106   /// \return A string, including surrounding '<>', of the template parameters.
107   /// If the DIE's name already has '<>', returns an empty string because
108   /// it's assumed that the caller is using the DIE name anyway.
109   std::string
110   GetDIEClassTemplateParams(lldb_private::plugin::dwarf::DWARFDIE die) override;
111 
112   void MapDeclDIEToDefDIE(const lldb_private::plugin::dwarf::DWARFDIE &decl_die,
113                           const lldb_private::plugin::dwarf::DWARFDIE &def_die);
114 
115 protected:
116   /// Protected typedefs and members.
117   /// @{
118   class DelayedAddObjCClassProperty;
119   typedef std::vector<DelayedAddObjCClassProperty> DelayedPropertyList;
120 
121   typedef llvm::DenseMap<
122       const lldb_private::plugin::dwarf::DWARFDebugInfoEntry *,
123       clang::DeclContext *>
124       DIEToDeclContextMap;
125   typedef std::multimap<const clang::DeclContext *,
126                         const lldb_private::plugin::dwarf::DWARFDIE>
127       DeclContextToDIEMap;
128   typedef llvm::DenseMap<
129       const lldb_private::plugin::dwarf::DWARFDebugInfoEntry *,
130       lldb_private::OptionalClangModuleID>
131       DIEToModuleMap;
132   typedef llvm::DenseMap<
133       const lldb_private::plugin::dwarf::DWARFDebugInfoEntry *, clang::Decl *>
134       DIEToDeclMap;
135 
136   lldb_private::TypeSystemClang &m_ast;
137   DIEToDeclMap m_die_to_decl;
138   DIEToDeclContextMap m_die_to_decl_ctx;
139   DeclContextToDIEMap m_decl_ctx_to_die;
140   DIEToModuleMap m_die_to_module;
141   std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up;
142   /// @}
143 
144   clang::DeclContext *
145   GetDeclContextForBlock(const lldb_private::plugin::dwarf::DWARFDIE &die);
146 
147   clang::BlockDecl *
148   ResolveBlockDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
149 
150   clang::NamespaceDecl *
151   ResolveNamespaceDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
152 
153   /// Returns the namespace decl that a DW_TAG_imported_declaration imports.
154   ///
155   /// \param[in] die The import declaration to resolve. If the DIE is not a
156   ///                DW_TAG_imported_declaration the behaviour is undefined.
157   ///
158   /// \returns The decl corresponding to the namespace that the specified
159   ///          'die' imports. If the imported entity is not a namespace
160   ///          or another import declaration, returns nullptr. If an error
161   ///          occurs, returns nullptr.
162   clang::NamespaceDecl *ResolveImportedDeclarationDIE(
163       const lldb_private::plugin::dwarf::DWARFDIE &die);
164 
165   bool ParseTemplateDIE(const lldb_private::plugin::dwarf::DWARFDIE &die,
166                         lldb_private::TypeSystemClang::TemplateParameterInfos
167                             &template_param_infos);
168 
169   bool ParseTemplateParameterInfos(
170       const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
171       lldb_private::TypeSystemClang::TemplateParameterInfos
172           &template_param_infos);
173 
174   void GetUniqueTypeNameAndDeclaration(
175       const lldb_private::plugin::dwarf::DWARFDIE &die,
176       lldb::LanguageType language, lldb_private::ConstString &unique_typename,
177       lldb_private::Declaration &decl_declaration);
178 
179   bool ParseChildMembers(
180       const lldb_private::plugin::dwarf::DWARFDIE &die,
181       const lldb_private::CompilerType &class_compiler_type,
182       std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
183       std::vector<lldb_private::plugin::dwarf::DWARFDIE> &member_function_dies,
184       std::vector<lldb_private::plugin::dwarf::DWARFDIE> &contained_type_dies,
185       DelayedPropertyList &delayed_properties,
186       const lldb::AccessType default_accessibility,
187       lldb_private::ClangASTImporter::LayoutInfo &layout_info);
188 
189   void ParseChildParameters(
190       clang::DeclContext *containing_decl_ctx,
191       const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
192       bool &is_variadic, bool &has_template_params,
193       std::vector<lldb_private::CompilerType> &function_param_types,
194       llvm::SmallVectorImpl<llvm::StringRef> &function_param_names);
195 
196   size_t ParseChildEnumerators(
197       const lldb_private::CompilerType &compiler_type, bool is_signed,
198       uint32_t enumerator_byte_size,
199       const lldb_private::plugin::dwarf::DWARFDIE &parent_die);
200 
201   /// Parse a structure, class, or union type DIE.
202   lldb::TypeSP
203   ParseStructureLikeDIE(const lldb_private::SymbolContext &sc,
204                         const lldb_private::plugin::dwarf::DWARFDIE &die,
205                         ParsedDWARFTypeAttributes &attrs);
206 
207   clang::Decl *
208   GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
209 
210   clang::DeclContext *
211   GetClangDeclContextForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
212 
213   clang::DeclContext *GetClangDeclContextContainingDIE(
214       const lldb_private::plugin::dwarf::DWARFDIE &die,
215       lldb_private::plugin::dwarf::DWARFDIE *decl_ctx_die);
216   lldb_private::OptionalClangModuleID
217   GetOwningClangModule(const lldb_private::plugin::dwarf::DWARFDIE &die);
218 
219   bool CopyUniqueClassMethodTypes(
220       const lldb_private::plugin::dwarf::DWARFDIE &src_class_die,
221       const lldb_private::plugin::dwarf::DWARFDIE &dst_class_die,
222       lldb_private::Type *class_type,
223       std::vector<lldb_private::plugin::dwarf::DWARFDIE> &failures);
224 
225   clang::DeclContext *GetCachedClangDeclContextForDIE(
226       const lldb_private::plugin::dwarf::DWARFDIE &die);
227 
228   void LinkDeclContextToDIE(clang::DeclContext *decl_ctx,
229                             const lldb_private::plugin::dwarf::DWARFDIE &die);
230 
231   void LinkDeclToDIE(clang::Decl *decl,
232                      const lldb_private::plugin::dwarf::DWARFDIE &die);
233 
234   /// If \p type_sp is valid, calculate and set its symbol context scope, and
235   /// update the type list for its backing symbol file.
236   ///
237   /// Returns \p type_sp.
238   lldb::TypeSP UpdateSymbolContextScopeForType(
239       const lldb_private::SymbolContext &sc,
240       const lldb_private::plugin::dwarf::DWARFDIE &die, lldb::TypeSP type_sp);
241 
242   /// Follow Clang Module Skeleton CU references to find a type definition.
243   lldb::TypeSP
244   ParseTypeFromClangModule(const lldb_private::SymbolContext &sc,
245                            const lldb_private::plugin::dwarf::DWARFDIE &die,
246                            lldb_private::Log *log);
247 
248   // Return true if this type is a declaration to a type in an external
249   // module.
250   lldb::ModuleSP
251   GetModuleForType(const lldb_private::plugin::dwarf::DWARFDIE &die);
252 
253   static bool classof(const DWARFASTParser *Parser) {
254     return Parser->GetKind() == Kind::DWARFASTParserClang;
255   }
256 
257 private:
258   struct FieldInfo {
259     /// Size in bits that this field occupies. Can but
260     /// need not be the DW_AT_bit_size of the field.
261     uint64_t bit_size = 0;
262 
263     /// Offset of this field in bits from the beginning
264     /// of the containing struct. Can but need not
265     /// be the DW_AT_data_bit_offset of the field.
266     uint64_t bit_offset = 0;
267 
268     /// In case this field is folded into the storage
269     /// of a previous member's storage (for example
270     /// with [[no_unique_address]]), the effective field
271     /// end is the offset in bits from the beginning of
272     /// the containing struct where the field we were
273     /// folded into ended.
274     std::optional<uint64_t> effective_field_end;
275 
276     /// Set to 'true' if this field is a bit-field.
277     bool is_bitfield = false;
278 
279     /// Set to 'true' if this field is DW_AT_artificial.
280     bool is_artificial = false;
281 
282     FieldInfo() = default;
283 
284     void SetIsBitfield(bool flag) { is_bitfield = flag; }
285     bool IsBitfield() const { return is_bitfield; }
286 
287     void SetIsArtificial(bool flag) { is_artificial = flag; }
288     bool IsArtificial() const { return is_artificial; }
289 
290     bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const {
291       // Any subsequent bitfields must not overlap and must be at a higher
292       // bit offset than any previous bitfield + size.
293       return (bit_size + bit_offset) <= next_bit_offset;
294     }
295 
296     /// Returns the offset in bits of where the storage this field
297     /// occupies ends.
298     uint64_t GetFieldEnd() const { return bit_size + bit_offset; }
299 
300     void SetEffectiveFieldEnd(uint64_t val) { effective_field_end = val; }
301 
302     /// If this field was folded into storage of a previous field,
303     /// returns the offset in bits of where that storage ends. Otherwise,
304     /// returns the regular field end (see \ref GetFieldEnd).
305     uint64_t GetEffectiveFieldEnd() const {
306       return effective_field_end.value_or(GetFieldEnd());
307     }
308   };
309 
310   /// Parsed form of all attributes that are relevant for parsing type members.
311   struct MemberAttributes {
312     explicit MemberAttributes(
313         const lldb_private::plugin::dwarf::DWARFDIE &die,
314         const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
315         lldb::ModuleSP module_sp);
316     const char *name = nullptr;
317     /// Indicates how many bits into the word (according to the host endianness)
318     /// the low-order bit of the field starts. Can be negative.
319     int64_t bit_offset = 0;
320     /// Indicates the size of the field in bits.
321     size_t bit_size = 0;
322     uint64_t data_bit_offset = UINT64_MAX;
323     lldb::AccessType accessibility = lldb::eAccessNone;
324     std::optional<uint64_t> byte_size;
325     std::optional<lldb_private::plugin::dwarf::DWARFFormValue> const_value_form;
326     lldb_private::plugin::dwarf::DWARFFormValue encoding_form;
327     /// Indicates the byte offset of the word from the base address of the
328     /// structure.
329     uint32_t member_byte_offset = UINT32_MAX;
330     bool is_artificial = false;
331     bool is_declaration = false;
332   };
333 
334   /// Returns 'true' if we should create an unnamed bitfield
335   /// and add it to the parser's current AST.
336   ///
337   /// \param[in] last_field_info FieldInfo of the previous DW_TAG_member
338   ///            we parsed.
339   /// \param[in] last_field_end Offset (in bits) where the last parsed field
340   ///            ended.
341   /// \param[in] this_field_info FieldInfo of the current DW_TAG_member
342   ///            being parsed.
343   /// \param[in] layout_info Layout information of all decls parsed by the
344   ///            current parser.
345   bool ShouldCreateUnnamedBitfield(
346       FieldInfo const &last_field_info, uint64_t last_field_end,
347       FieldInfo const &this_field_info,
348       lldb_private::ClangASTImporter::LayoutInfo const &layout_info) const;
349 
350   /// Tries to detect whether \ref class_clang_type contained an unnamed
351   /// bit-field between \ref previous_field and \ref current_field, and if
352   /// so, adds a clang::FieldDecl representing that bit-field to
353   /// \ref class_clang_type.
354   ///
355   /// This is necessary because Clang (and GCC) doesn't emit a DW_TAG_member
356   /// entry for unnamed bit-fields. So we derive it (with some exceptions),
357   /// by checking whether there is a gap between where the storage of a
358   /// DW_TAG_member ended and the subsequent DW_TAG_member began.
359   ///
360   /// \param[in,out] layout_info Layout information of all decls parsed by the
361   ///                            current parser. Will contain an entry for
362   ///                            the unnamed bit-field if this function created
363   ///                            one.
364   ///
365   /// \param[in] class_clang_type The RecordType to which the unnamed bit-field
366   ///                             will be added (if any).
367   ///
368   /// \param[in] previous_field FieldInfo of the previous DW_TAG_member
369   ///                           we parsed.
370   ///
371   /// \param[in] current_field FieldInfo of the current DW_TAG_member
372   ///                          being parsed.
373   ///
374   void AddUnnamedBitfieldToRecordTypeIfNeeded(
375       lldb_private::ClangASTImporter::LayoutInfo &class_layout_info,
376       const lldb_private::CompilerType &class_clang_type,
377       const FieldInfo &previous_field, const FieldInfo &current_field);
378 
379   /// Parses a DW_TAG_APPLE_property DIE and appends the parsed data to the
380   /// list of delayed Objective-C properties.
381   ///
382   /// Note: The delayed property needs to be finalized to actually create the
383   /// property declarations in the module AST.
384   ///
385   /// \param die The DW_TAG_APPLE_property DIE that will be parsed.
386   /// \param parent_die The parent DIE.
387   /// \param class_clang_type The Objective-C class that will contain the
388   /// created property.
389   /// \param delayed_properties The list of delayed properties that the result
390   /// will be appended to.
391   void
392   ParseObjCProperty(const lldb_private::plugin::dwarf::DWARFDIE &die,
393                     const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
394                     const lldb_private::CompilerType &class_clang_type,
395                     DelayedPropertyList &delayed_properties);
396 
397   void
398   ParseSingleMember(const lldb_private::plugin::dwarf::DWARFDIE &die,
399                     const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
400                     const lldb_private::CompilerType &class_clang_type,
401                     lldb::AccessType default_accessibility,
402                     lldb_private::ClangASTImporter::LayoutInfo &layout_info,
403                     FieldInfo &last_field_info);
404 
405   /// If the specified 'die' represents a static data member, creates
406   /// a 'clang::VarDecl' for it and attaches it to specified parent
407   /// 'class_clang_type'.
408   ///
409   /// \param[in] die The member declaration we want to create a
410   ///                clang::VarDecl for.
411   ///
412   /// \param[in] attrs The parsed attributes for the specified 'die'.
413   ///
414   /// \param[in] class_clang_type The parent RecordType of the static
415   ///                             member this function will create.
416   void CreateStaticMemberVariable(
417       const lldb_private::plugin::dwarf::DWARFDIE &die,
418       const MemberAttributes &attrs,
419       const lldb_private::CompilerType &class_clang_type);
420 
421   bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die,
422                           const lldb_private::CompilerType &clang_type);
423   bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die,
424                         lldb_private::Type *type,
425                         const lldb_private::CompilerType &clang_type);
426 
427   lldb::TypeSP
428   ParseTypeModifier(const lldb_private::SymbolContext &sc,
429                     const lldb_private::plugin::dwarf::DWARFDIE &die,
430                     ParsedDWARFTypeAttributes &attrs);
431   lldb::TypeSP ParseEnum(const lldb_private::SymbolContext &sc,
432                          const lldb_private::plugin::dwarf::DWARFDIE &die,
433                          ParsedDWARFTypeAttributes &attrs);
434   lldb::TypeSP ParseSubroutine(const lldb_private::plugin::dwarf::DWARFDIE &die,
435                                const ParsedDWARFTypeAttributes &attrs);
436 
437   /// Helper function called by \ref ParseSubroutine when parsing ObjC-methods.
438   ///
439   /// \param[in] objc_method Name of the ObjC method being parsed.
440   ///
441   /// \param[in] die The DIE that represents the ObjC method being parsed.
442   ///
443   /// \param[in] clang_type The CompilerType representing the function prototype
444   ///                       of the ObjC method being parsed.
445   ///
446   /// \param[in] attrs DWARF attributes for \ref die.
447   ///
448   /// \param[in] is_variadic Is true iff we're parsing a variadic method.
449   ///
450   /// \returns true on success
451   bool
452   ParseObjCMethod(const lldb_private::ObjCLanguage::MethodName &objc_method,
453                   const lldb_private::plugin::dwarf::DWARFDIE &die,
454                   lldb_private::CompilerType clang_type,
455                   const ParsedDWARFTypeAttributes &attrs, bool is_variadic);
456 
457   /// Helper function called by \ref ParseSubroutine when parsing C++ methods.
458   ///
459   /// \param[in] die The DIE that represents the C++ method being parsed.
460   ///
461   /// \param[in] clang_type The CompilerType representing the function prototype
462   ///                       of the C++ method being parsed.
463   ///
464   /// \param[in] attrs DWARF attributes for \ref die.
465   ///
466   /// \param[in] decl_ctx_die The DIE representing the DeclContext of the C++
467   ///                         method being parsed.
468   ///
469   /// \param[in] is_static Is true iff we're parsing a static method.
470   ///
471   /// \param[out] ignore_containing_context Will get set to true if the caller
472   ///             should treat this C++ method as-if it was not a C++ method.
473   ///             Currently used as a hack to work around templated C++ methods
474   ///             causing class definitions to mismatch between CUs.
475   ///
476   /// \returns A pair of <bool, TypeSP>. The first element is 'true' on success.
477   ///          The second element is non-null if we have previously parsed this
478   ///          method (a null TypeSP does not indicate failure).
479   std::pair<bool, lldb::TypeSP>
480   ParseCXXMethod(const lldb_private::plugin::dwarf::DWARFDIE &die,
481                  lldb_private::CompilerType clang_type,
482                  const ParsedDWARFTypeAttributes &attrs,
483                  const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die,
484                  bool is_static, bool &ignore_containing_context);
485 
486   lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die,
487                               const ParsedDWARFTypeAttributes &attrs);
488   lldb::TypeSP
489   ParsePointerToMemberType(const lldb_private::plugin::dwarf::DWARFDIE &die,
490                            const ParsedDWARFTypeAttributes &attrs);
491 
492   /// Parses a DW_TAG_inheritance DIE into a base/super class.
493   ///
494   /// \param die The DW_TAG_inheritance DIE to parse.
495   /// \param parent_die The parent DIE of the given DIE.
496   /// \param class_clang_type The C++/Objective-C class representing parent_die.
497   /// For an Objective-C class this method sets the super class on success. For
498   /// a C++ class this will *not* add the result as a base class.
499   /// \param default_accessibility The default accessibility that is given to
500   /// base classes if they don't have an explicit accessibility set.
501   /// \param module_sp The current Module.
502   /// \param base_classes The list of C++ base classes that will be appended
503   /// with the parsed base class on success.
504   /// \param layout_info The layout information that will be updated for C++
505   /// base classes with the base offset.
506   void ParseInheritance(
507       const lldb_private::plugin::dwarf::DWARFDIE &die,
508       const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
509       const lldb_private::CompilerType class_clang_type,
510       const lldb::AccessType default_accessibility,
511       const lldb::ModuleSP &module_sp,
512       std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
513       lldb_private::ClangASTImporter::LayoutInfo &layout_info);
514 
515   /// Parses DW_TAG_variant_part DIE into a structure that encodes all variants
516   /// Note that this is currently being emitted by rustc and not Clang
517   /// \param die DW_TAG_variant_part DIE to parse
518   /// \param parent_die The parent DW_TAG_structure_type to parse
519   /// \param class_clang_type The Rust struct representing parent_die.
520   /// \param default_accesibility The default accessibility that is given to
521   ///  base classes if they don't have an explicit accessibility set
522   /// \param layout_info The layout information that will be updated for
523   //   base classes with the base offset
524   void
525   ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die,
526                        const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
527                        const lldb_private::CompilerType &class_clang_type,
528                        const lldb::AccessType default_accesibility,
529                        lldb_private::ClangASTImporter::LayoutInfo &layout_info);
530 };
531 
532 /// Parsed form of all attributes that are relevant for type reconstruction.
533 /// Some attributes are relevant for all kinds of types (declaration), while
534 /// others are only meaningful to a specific type (is_virtual)
535 struct ParsedDWARFTypeAttributes {
536   explicit ParsedDWARFTypeAttributes(
537       const lldb_private::plugin::dwarf::DWARFDIE &die);
538 
539   lldb::AccessType accessibility = lldb::eAccessNone;
540   bool is_artificial = false;
541   bool is_complete_objc_class = false;
542   bool is_explicit = false;
543   bool is_forward_declaration = false;
544   bool is_inline = false;
545   bool is_scoped_enum = false;
546   bool is_vector = false;
547   bool is_virtual = false;
548   bool is_objc_direct_call = false;
549   bool exports_symbols = false;
550   clang::StorageClass storage = clang::SC_None;
551   const char *mangled_name = nullptr;
552   lldb_private::ConstString name;
553   lldb_private::Declaration decl;
554   lldb_private::plugin::dwarf::DWARFDIE object_pointer;
555   lldb_private::plugin::dwarf::DWARFFormValue abstract_origin;
556   lldb_private::plugin::dwarf::DWARFFormValue containing_type;
557   lldb_private::plugin::dwarf::DWARFFormValue signature;
558   lldb_private::plugin::dwarf::DWARFFormValue specification;
559   lldb_private::plugin::dwarf::DWARFFormValue type;
560   lldb::LanguageType class_language = lldb::eLanguageTypeUnknown;
561   std::optional<uint64_t> byte_size;
562   std::optional<uint64_t> alignment;
563   size_t calling_convention = llvm::dwarf::DW_CC_normal;
564   uint32_t bit_stride = 0;
565   uint32_t byte_stride = 0;
566   uint32_t encoding = 0;
567   clang::RefQualifierKind ref_qual =
568       clang::RQ_None; ///< Indicates ref-qualifier of
569                       ///< C++ member function if present.
570                       ///< Is RQ_None otherwise.
571 };
572 
573 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
574