DWARFASTParserClang.h revision 296417
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 28class DWARFDebugInfoEntry; 29class DWARFDIECollection; 30 31class DWARFASTParserClang : public DWARFASTParser 32{ 33public: 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 80protected: 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 std::vector<lldb_private::CompilerType>& function_args, 137 std::vector<clang::ParmVarDecl*>& function_param_decls, 138 unsigned &type_quals); 139 140 void 141 ParseChildArrayInfo (const lldb_private::SymbolContext& sc, 142 const DWARFDIE &parent_die, 143 int64_t& first_index, 144 std::vector<uint64_t>& element_orders, 145 uint32_t& byte_stride, 146 uint32_t& bit_stride); 147 148 size_t 149 ParseChildEnumerators (const lldb_private::SymbolContext& sc, 150 lldb_private::CompilerType &compiler_type, 151 bool is_signed, 152 uint32_t enumerator_byte_size, 153 const DWARFDIE &parent_die); 154 155 lldb_private::Type * 156 GetTypeForDIE (const DWARFDIE &die); 157 158 clang::Decl * 159 GetClangDeclForDIE (const DWARFDIE &die); 160 161 clang::DeclContext * 162 GetClangDeclContextForDIE (const DWARFDIE &die); 163 164 clang::DeclContext * 165 GetClangDeclContextContainingDIE (const DWARFDIE &die, 166 DWARFDIE *decl_ctx_die); 167 168 bool 169 CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die, 170 const DWARFDIE &dst_class_die, 171 lldb_private::Type *class_type, 172 DWARFDIECollection &failures); 173 174 clang::DeclContext * 175 GetCachedClangDeclContextForDIE (const DWARFDIE &die); 176 177 void 178 LinkDeclContextToDIE (clang::DeclContext *decl_ctx, 179 const DWARFDIE &die); 180 181 void 182 LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die); 183 184 lldb_private::ClangASTImporter & 185 GetClangASTImporter(); 186 187 lldb::TypeSP 188 ParseTypeFromDWO (const DWARFDIE &die, lldb_private::Log *log); 189 190 //---------------------------------------------------------------------- 191 // Return true if this type is a declaration to a type in an external 192 // module. 193 //---------------------------------------------------------------------- 194 lldb::ModuleSP 195 GetModuleForType (const DWARFDIE &die); 196 197 typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; 198 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; 199 //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap; 200 typedef std::multimap<const clang::DeclContext *, const DWARFDIE> DeclContextToDIEMap; 201 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> DIEToDeclMap; 202 typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap; 203 204 lldb_private::ClangASTContext &m_ast; 205 DIEToDeclMap m_die_to_decl; 206 DeclToDIEMap m_decl_to_die; 207 DIEToDeclContextMap m_die_to_decl_ctx; 208 DeclContextToDIEMap m_decl_ctx_to_die; 209 RecordDeclToLayoutMap m_record_decl_to_layout_map; 210 std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap; 211}; 212 213#endif // SymbolFileDWARF_DWARFASTParserClang_h_ 214