1 //===-- DWARFASTParserClang.h -----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef SymbolFileDWARF_DWARFASTParserClang_h_ 11 #define SymbolFileDWARF_DWARFASTParserClang_h_ 12 13 // C Includes 14 // C++ Includes 15 // Other libraries and framework includes 16 #include "llvm/ADT/DenseMap.h" 17 #include "llvm/ADT/SmallPtrSet.h" 18 #include "llvm/ADT/SmallVector.h" 19 #include "clang/AST/CharUnits.h" 20 21 // Project includes 22 #include "lldb/Core/ClangForward.h" 23 #include "lldb/Core/PluginInterface.h" 24 #include "lldb/Symbol/ClangASTContext.h" 25 #include "DWARFDefines.h" 26 #include "DWARFASTParser.h" 27 28 class DWARFDebugInfoEntry; 29 class DWARFDIECollection; 30 31 class DWARFASTParserClang : public DWARFASTParser 32 { 33 public: 34 DWARFASTParserClang (lldb_private::ClangASTContext &ast); 35 36 ~DWARFASTParserClang() override; 37 38 lldb::TypeSP 39 ParseTypeFromDWARF (const lldb_private::SymbolContext& sc, 40 const DWARFDIE &die, 41 lldb_private::Log *log, 42 bool *type_is_new_ptr) override; 43 44 45 lldb_private::Function * 46 ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc, 47 const DWARFDIE &die) override; 48 49 bool 50 CanCompleteType (const lldb_private::CompilerType &compiler_type) override; 51 52 bool 53 CompleteType (const lldb_private::CompilerType &compiler_type) override; 54 55 bool 56 CompleteTypeFromDWARF (const DWARFDIE &die, 57 lldb_private::Type *type, 58 lldb_private::CompilerType &compiler_type) override; 59 60 lldb_private::CompilerDecl 61 GetDeclForUIDFromDWARF (const DWARFDIE &die) override; 62 63 std::vector<DWARFDIE> 64 GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override; 65 66 lldb_private::CompilerDeclContext 67 GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override; 68 69 lldb_private::CompilerDeclContext 70 GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override; 71 72 bool 73 LayoutRecordType(const clang::RecordDecl *record_decl, 74 uint64_t &bit_size, 75 uint64_t &alignment, 76 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets, 77 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets, 78 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); 79 80 protected: 81 class DelayedAddObjCClassProperty; 82 typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList; 83 84 struct LayoutInfo 85 { 86 LayoutInfo () : 87 bit_size(0), 88 alignment(0), 89 field_offsets(), 90 base_offsets(), 91 vbase_offsets() 92 { 93 } 94 uint64_t bit_size; 95 uint64_t alignment; 96 llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets; 97 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets; 98 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets; 99 }; 100 101 clang::BlockDecl * 102 ResolveBlockDIE (const DWARFDIE &die); 103 104 clang::NamespaceDecl * 105 ResolveNamespaceDIE (const DWARFDIE &die); 106 107 typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap; 108 109 bool 110 ParseTemplateDIE (const DWARFDIE &die, 111 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); 112 bool 113 ParseTemplateParameterInfos (const DWARFDIE &parent_die, 114 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); 115 116 bool 117 ParseChildMembers (const lldb_private::SymbolContext& sc, 118 const DWARFDIE &die, 119 lldb_private::CompilerType &class_compiler_type, 120 const lldb::LanguageType class_language, 121 std::vector<clang::CXXBaseSpecifier *>& base_classes, 122 std::vector<int>& member_accessibilities, 123 DWARFDIECollection& member_function_dies, 124 DelayedPropertyList& delayed_properties, 125 lldb::AccessType &default_accessibility, 126 bool &is_a_class, 127 LayoutInfo &layout_info); 128 129 size_t 130 ParseChildParameters (const lldb_private::SymbolContext& sc, 131 clang::DeclContext *containing_decl_ctx, 132 const DWARFDIE &parent_die, 133 bool skip_artificial, 134 bool &is_static, 135 bool &is_variadic, 136 bool &has_template_params, 137 std::vector<lldb_private::CompilerType>& function_args, 138 std::vector<clang::ParmVarDecl*>& function_param_decls, 139 unsigned &type_quals); 140 141 void 142 ParseChildArrayInfo (const lldb_private::SymbolContext& sc, 143 const DWARFDIE &parent_die, 144 int64_t& first_index, 145 std::vector<uint64_t>& element_orders, 146 uint32_t& byte_stride, 147 uint32_t& bit_stride); 148 149 size_t 150 ParseChildEnumerators (const lldb_private::SymbolContext& sc, 151 lldb_private::CompilerType &compiler_type, 152 bool is_signed, 153 uint32_t enumerator_byte_size, 154 const DWARFDIE &parent_die); 155 156 lldb_private::Type * 157 GetTypeForDIE (const DWARFDIE &die); 158 159 clang::Decl * 160 GetClangDeclForDIE (const DWARFDIE &die); 161 162 clang::DeclContext * 163 GetClangDeclContextForDIE (const DWARFDIE &die); 164 165 clang::DeclContext * 166 GetClangDeclContextContainingDIE (const DWARFDIE &die, 167 DWARFDIE *decl_ctx_die); 168 169 bool 170 CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die, 171 const DWARFDIE &dst_class_die, 172 lldb_private::Type *class_type, 173 DWARFDIECollection &failures); 174 175 clang::DeclContext * 176 GetCachedClangDeclContextForDIE (const DWARFDIE &die); 177 178 void 179 LinkDeclContextToDIE (clang::DeclContext *decl_ctx, 180 const DWARFDIE &die); 181 182 void 183 LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die); 184 185 lldb_private::ClangASTImporter & 186 GetClangASTImporter(); 187 188 lldb::TypeSP 189 ParseTypeFromDWO (const DWARFDIE &die, lldb_private::Log *log); 190 191 //---------------------------------------------------------------------- 192 // Return true if this type is a declaration to a type in an external 193 // module. 194 //---------------------------------------------------------------------- 195 lldb::ModuleSP 196 GetModuleForType (const DWARFDIE &die); 197 198 typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; 199 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; 200 //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap; 201 typedef std::multimap<const clang::DeclContext *, const DWARFDIE> DeclContextToDIEMap; 202 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> DIEToDeclMap; 203 typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap; 204 205 lldb_private::ClangASTContext &m_ast; 206 DIEToDeclMap m_die_to_decl; 207 DeclToDIEMap m_decl_to_die; 208 DIEToDeclContextMap m_die_to_decl_ctx; 209 DeclContextToDIEMap m_decl_ctx_to_die; 210 RecordDeclToLayoutMap m_record_decl_to_layout_map; 211 std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap; 212 }; 213 214 #endif // SymbolFileDWARF_DWARFASTParserClang_h_ 215