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 "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" 28 29 class DWARFDebugInfoEntry; 30 class DWARFDIECollection; 31 32 class DWARFASTParserClang : public DWARFASTParser 33 { 34 public: 35 DWARFASTParserClang (lldb_private::ClangASTContext &ast); 36 37 ~DWARFASTParserClang() override; 38 39 // DWARFASTParser interface. 40 lldb::TypeSP 41 ParseTypeFromDWARF (const lldb_private::SymbolContext& sc, 42 const DWARFDIE &die, 43 lldb_private::Log *log, 44 bool *type_is_new_ptr) override; 45 46 47 lldb_private::Function * 48 ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc, 49 const DWARFDIE &die) override; 50 51 bool 52 CompleteTypeFromDWARF (const DWARFDIE &die, 53 lldb_private::Type *type, 54 lldb_private::CompilerType &compiler_type) override; 55 56 lldb_private::CompilerDecl 57 GetDeclForUIDFromDWARF (const DWARFDIE &die) override; 58 59 std::vector<DWARFDIE> 60 GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override; 61 62 lldb_private::CompilerDeclContext 63 GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override; 64 65 lldb_private::CompilerDeclContext 66 GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override; 67 68 lldb_private::ClangASTImporter & 69 GetClangASTImporter(); 70 71 protected: 72 class DelayedAddObjCClassProperty; 73 typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList; 74 75 clang::BlockDecl * 76 ResolveBlockDIE (const DWARFDIE &die); 77 78 clang::NamespaceDecl * 79 ResolveNamespaceDIE (const DWARFDIE &die); 80 81 bool 82 ParseTemplateDIE (const DWARFDIE &die, 83 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); 84 bool 85 ParseTemplateParameterInfos (const DWARFDIE &parent_die, 86 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); 87 88 bool 89 ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die, 90 lldb_private::CompilerType &class_compiler_type, const lldb::LanguageType class_language, 91 std::vector<clang::CXXBaseSpecifier *> &base_classes, std::vector<int> &member_accessibilities, 92 DWARFDIECollection &member_function_dies, DelayedPropertyList &delayed_properties, 93 lldb::AccessType &default_accessibility, bool &is_a_class, 94 lldb_private::ClangASTImporter::LayoutInfo &layout_info); 95 96 size_t 97 ParseChildParameters (const lldb_private::SymbolContext& sc, 98 clang::DeclContext *containing_decl_ctx, 99 const DWARFDIE &parent_die, 100 bool skip_artificial, 101 bool &is_static, 102 bool &is_variadic, 103 bool &has_template_params, 104 std::vector<lldb_private::CompilerType>& function_args, 105 std::vector<clang::ParmVarDecl*>& function_param_decls, 106 unsigned &type_quals); 107 108 void 109 ParseChildArrayInfo (const lldb_private::SymbolContext& sc, 110 const DWARFDIE &parent_die, 111 int64_t& first_index, 112 std::vector<uint64_t>& element_orders, 113 uint32_t& byte_stride, 114 uint32_t& bit_stride); 115 116 size_t 117 ParseChildEnumerators (const lldb_private::SymbolContext& sc, 118 lldb_private::CompilerType &compiler_type, 119 bool is_signed, 120 uint32_t enumerator_byte_size, 121 const DWARFDIE &parent_die); 122 123 lldb_private::Type * 124 GetTypeForDIE (const DWARFDIE &die); 125 126 clang::Decl * 127 GetClangDeclForDIE (const DWARFDIE &die); 128 129 clang::DeclContext * 130 GetClangDeclContextForDIE (const DWARFDIE &die); 131 132 clang::DeclContext * 133 GetClangDeclContextContainingDIE (const DWARFDIE &die, 134 DWARFDIE *decl_ctx_die); 135 136 bool 137 CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die, 138 const DWARFDIE &dst_class_die, 139 lldb_private::Type *class_type, 140 DWARFDIECollection &failures); 141 142 clang::DeclContext * 143 GetCachedClangDeclContextForDIE (const DWARFDIE &die); 144 145 void 146 LinkDeclContextToDIE (clang::DeclContext *decl_ctx, 147 const DWARFDIE &die); 148 149 void 150 LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die); 151 152 lldb::TypeSP 153 ParseTypeFromDWO (const DWARFDIE &die, lldb_private::Log *log); 154 155 //---------------------------------------------------------------------- 156 // Return true if this type is a declaration to a type in an external 157 // module. 158 //---------------------------------------------------------------------- 159 lldb::ModuleSP 160 GetModuleForType (const DWARFDIE &die); 161 162 typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; 163 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; 164 //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap; 165 typedef std::multimap<const clang::DeclContext *, const DWARFDIE> DeclContextToDIEMap; 166 typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> DIEToDeclMap; 167 typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap; 168 169 lldb_private::ClangASTContext &m_ast; 170 DIEToDeclMap m_die_to_decl; 171 DeclToDIEMap m_decl_to_die; 172 DIEToDeclContextMap m_die_to_decl_ctx; 173 DeclContextToDIEMap m_decl_ctx_to_die; 174 std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap; 175 }; 176 177 #endif // SymbolFileDWARF_DWARFASTParserClang_h_ 178