1 //===-- DWARFASTParserClang.h -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SymbolFileDWARF_DWARFASTParserClang_h_
11 #define SymbolFileDWARF_DWARFASTParserClang_h_
15 // Other libraries and framework includes
16 #include "clang/AST/CharUnits.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/ADT/SmallVector.h"
22 #include "DWARFASTParser.h"
23 #include "DWARFDefines.h"
24 #include "lldb/Core/ClangForward.h"
25 #include "lldb/Core/PluginInterface.h"
26 #include "lldb/Symbol/ClangASTContext.h"
27 #include "lldb/Symbol/ClangASTImporter.h"
29 class DWARFDebugInfoEntry;
30 class DWARFDIECollection;
32 class DWARFASTParserClang : public DWARFASTParser {
34 DWARFASTParserClang(lldb_private::ClangASTContext &ast);
36 ~DWARFASTParserClang() override;
38 // DWARFASTParser interface.
39 lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
40 const DWARFDIE &die, lldb_private::Log *log,
41 bool *type_is_new_ptr) override;
43 lldb_private::Function *
44 ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
45 const DWARFDIE &die) override;
48 CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
49 lldb_private::CompilerType &compiler_type) override;
51 lldb_private::CompilerDecl
52 GetDeclForUIDFromDWARF(const DWARFDIE &die) override;
55 GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) override;
57 lldb_private::CompilerDeclContext
58 GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override;
60 lldb_private::CompilerDeclContext
61 GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override;
63 lldb_private::ClangASTImporter &GetClangASTImporter();
66 class DelayedAddObjCClassProperty;
67 typedef std::vector<DelayedAddObjCClassProperty> DelayedPropertyList;
69 clang::DeclContext *GetDeclContextForBlock(const DWARFDIE &die);
71 clang::BlockDecl *ResolveBlockDIE(const DWARFDIE &die);
73 clang::NamespaceDecl *ResolveNamespaceDIE(const DWARFDIE &die);
75 bool ParseTemplateDIE(const DWARFDIE &die,
76 lldb_private::ClangASTContext::TemplateParameterInfos
77 &template_param_infos);
78 bool ParseTemplateParameterInfos(
79 const DWARFDIE &parent_die,
80 lldb_private::ClangASTContext::TemplateParameterInfos
81 &template_param_infos);
84 ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
85 lldb_private::CompilerType &class_compiler_type,
86 const lldb::LanguageType class_language,
87 std::vector<clang::CXXBaseSpecifier *> &base_classes,
88 std::vector<int> &member_accessibilities,
89 DWARFDIECollection &member_function_dies,
90 DelayedPropertyList &delayed_properties,
91 lldb::AccessType &default_accessibility, bool &is_a_class,
92 lldb_private::ClangASTImporter::LayoutInfo &layout_info);
95 ParseChildParameters(const lldb_private::SymbolContext &sc,
96 clang::DeclContext *containing_decl_ctx,
97 const DWARFDIE &parent_die, bool skip_artificial,
98 bool &is_static, bool &is_variadic,
99 bool &has_template_params,
100 std::vector<lldb_private::CompilerType> &function_args,
101 std::vector<clang::ParmVarDecl *> &function_param_decls,
102 unsigned &type_quals);
104 void ParseChildArrayInfo(const lldb_private::SymbolContext &sc,
105 const DWARFDIE &parent_die, int64_t &first_index,
106 std::vector<uint64_t> &element_orders,
107 uint32_t &byte_stride, uint32_t &bit_stride);
109 size_t ParseChildEnumerators(const lldb_private::SymbolContext &sc,
110 lldb_private::CompilerType &compiler_type,
111 bool is_signed, uint32_t enumerator_byte_size,
112 const DWARFDIE &parent_die);
114 lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
116 clang::Decl *GetClangDeclForDIE(const DWARFDIE &die);
118 clang::DeclContext *GetClangDeclContextForDIE(const DWARFDIE &die);
120 clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE &die,
121 DWARFDIE *decl_ctx_die);
123 bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
124 const DWARFDIE &dst_class_die,
125 lldb_private::Type *class_type,
126 DWARFDIECollection &failures);
128 clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die);
130 void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die);
132 void LinkDeclToDIE(clang::Decl *decl, const DWARFDIE &die);
134 lldb::TypeSP ParseTypeFromDWO(const DWARFDIE &die, lldb_private::Log *log);
136 //----------------------------------------------------------------------
137 // Return true if this type is a declaration to a type in an external
139 //----------------------------------------------------------------------
140 lldb::ModuleSP GetModuleForType(const DWARFDIE &die);
142 typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
143 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *>
145 // typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet>
146 // DeclContextToDIEMap;
147 typedef std::multimap<const clang::DeclContext *, const DWARFDIE>
149 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *>
151 typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap;
153 lldb_private::ClangASTContext &m_ast;
154 DIEToDeclMap m_die_to_decl;
155 DeclToDIEMap m_decl_to_die;
156 DIEToDeclContextMap m_die_to_decl_ctx;
157 DeclContextToDIEMap m_decl_ctx_to_die;
158 std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap;
161 #endif // SymbolFileDWARF_DWARFASTParserClang_h_