1 //===-- UdtRecordCompleter.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_NATIVEPDB_UDTRECORDCOMPLETER_H 10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H 11 12 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h" 13 #include "llvm/DebugInfo/CodeView/CVRecord.h" 14 #include "llvm/DebugInfo/CodeView/TypeRecord.h" 15 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" 16 17 #include "PdbSymUid.h" 18 19 namespace clang { 20 class CXXBaseSpecifier; 21 class QualType; 22 class TagDecl; 23 } // namespace clang 24 25 namespace llvm { 26 namespace pdb { 27 class TpiStream; 28 class GlobalsStream; 29 } 30 } // namespace llvm 31 32 namespace lldb_private { 33 class Type; 34 class CompilerType; 35 namespace npdb { 36 class PdbAstBuilder; 37 class PdbIndex; 38 39 class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks { 40 using IndexedBase = 41 std::pair<uint64_t, std::unique_ptr<clang::CXXBaseSpecifier>>; 42 43 union UdtTagRecord { 44 UdtTagRecord() {} 45 llvm::codeview::UnionRecord ur; 46 llvm::codeview::ClassRecord cr; 47 llvm::codeview::EnumRecord er; 48 } m_cvr; 49 50 PdbTypeSymId m_id; 51 CompilerType &m_derived_ct; 52 clang::TagDecl &m_tag_decl; 53 PdbAstBuilder &m_ast_builder; 54 PdbIndex &m_index; 55 std::vector<IndexedBase> m_bases; 56 ClangASTImporter::LayoutInfo m_layout; 57 llvm::DenseMap<lldb::opaque_compiler_type_t, 58 llvm::SmallSet<std::pair<llvm::StringRef, CompilerType>, 8>> 59 &m_cxx_record_map; 60 61 public: 62 UdtRecordCompleter( 63 PdbTypeSymId id, CompilerType &derived_ct, clang::TagDecl &tag_decl, 64 PdbAstBuilder &ast_builder, PdbIndex &index, 65 llvm::DenseMap<lldb::opaque_compiler_type_t, 66 llvm::SmallSet<std::pair<llvm::StringRef, CompilerType>, 67 8>> &cxx_record_map); 68 69 #define MEMBER_RECORD(EnumName, EnumVal, Name) \ 70 llvm::Error visitKnownMember(llvm::codeview::CVMemberRecord &CVR, \ 71 llvm::codeview::Name##Record &Record) override; 72 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 73 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" 74 75 void complete(); 76 77 private: 78 clang::QualType AddBaseClassForTypeIndex( 79 llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access, 80 llvm::Optional<uint64_t> vtable_idx = llvm::Optional<uint64_t>()); 81 void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx, 82 llvm::codeview::MemberAccess access, 83 llvm::codeview::MethodOptions options, 84 llvm::codeview::MemberAttributes attrs); 85 }; 86 87 } // namespace npdb 88 } // namespace lldb_private 89 90 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H 91