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 58 public: 59 UdtRecordCompleter(PdbTypeSymId id, CompilerType &derived_ct, 60 clang::TagDecl &tag_decl, PdbAstBuilder &ast_builder, 61 PdbIndex &index); 62 63 #define MEMBER_RECORD(EnumName, EnumVal, Name) \ 64 llvm::Error visitKnownMember(llvm::codeview::CVMemberRecord &CVR, \ 65 llvm::codeview::Name##Record &Record) override; 66 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 67 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" 68 69 void complete(); 70 71 private: 72 clang::QualType AddBaseClassForTypeIndex( 73 llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access, 74 llvm::Optional<uint64_t> vtable_idx = llvm::Optional<uint64_t>()); 75 void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx, 76 llvm::codeview::MemberAccess access, 77 llvm::codeview::MethodOptions options, 78 llvm::codeview::MemberAttributes attrs); 79 }; 80 81 } // namespace npdb 82 } // namespace lldb_private 83 84 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H 85