LLDB mainline
UdtRecordCompleter.h
Go to the documentation of this file.
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 "PdbAstBuilder.h"
13#include "PdbSymUid.h"
14#include "PdbUtil.h"
16#include "llvm/DebugInfo/CodeView/CVRecord.h"
17#include "llvm/DebugInfo/CodeView/TypeRecord.h"
18#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
19#include <optional>
20
21namespace clang {
22class CXXBaseSpecifier;
23class QualType;
24class TagDecl;
25} // namespace clang
26
27namespace llvm {
28namespace pdb {
29class TpiStream;
30class GlobalsStream;
31}
32} // namespace llvm
33
34namespace lldb_private {
35class Type;
36class CompilerType;
37namespace npdb {
38class PdbAstBuilder;
39class PdbIndex;
40
43 std::pair<uint64_t, std::unique_ptr<clang::CXXBaseSpecifier>>;
44
48 clang::TagDecl &m_tag_decl;
51 std::vector<IndexedBase> m_bases;
53 llvm::DenseMap<clang::Decl *, DeclStatus> &m_decl_to_status;
54 llvm::DenseMap<lldb::opaque_compiler_type_t,
55 llvm::SmallSet<std::pair<llvm::StringRef, CompilerType>, 8>>
57
58public:
60 PdbTypeSymId id, CompilerType &derived_ct, clang::TagDecl &tag_decl,
61 PdbAstBuilder &ast_builder, PdbIndex &index,
62 llvm::DenseMap<clang::Decl *, DeclStatus> &decl_to_status,
63 llvm::DenseMap<lldb::opaque_compiler_type_t,
64 llvm::SmallSet<std::pair<llvm::StringRef, CompilerType>,
65 8>> &cxx_record_map);
66
67#define MEMBER_RECORD(EnumName, EnumVal, Name) \
68 llvm::Error visitKnownMember(llvm::codeview::CVMemberRecord &CVR, \
69 llvm::codeview::Name##Record &Record) override;
70#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
71#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
72
73 struct Member;
74 using MemberUP = std::unique_ptr<Member>;
75
76 struct Member {
78 // Following are only used for field.
79 llvm::StringRef name;
80 uint64_t bit_offset;
81 uint64_t bit_size;
82 clang::QualType qt;
85 // Following are Only used for struct or union.
86 uint64_t base_offset;
87 llvm::SmallVector<MemberUP, 1> fields;
88
89 Member() = default;
91 : kind(kind), name(), bit_offset(0), bit_size(0), qt(),
92 access(lldb::eAccessPublic), bitfield_width(0), base_offset(0) {}
93 Member(llvm::StringRef name, uint64_t bit_offset, uint64_t bit_size,
94 clang::QualType qt, lldb::AccessType access, uint32_t bitfield_width)
97 base_offset(0) {}
99 kind = Struct;
101 fields.push_back(std::make_unique<Member>(name, bit_offset, bit_size, qt,
103 name = llvm::StringRef();
104 qt = clang::QualType();
107 }
108 };
109
110 struct Record {
111 // Top level record.
114 std::map<uint64_t, llvm::SmallVector<MemberUP, 1>> fields_map;
115 void CollectMember(llvm::StringRef name, uint64_t offset,
116 uint64_t field_size, clang::QualType qt,
117 lldb::AccessType access, uint64_t bitfield_width);
118 void ConstructRecord();
119 };
120 void complete();
121
122private:
124 clang::QualType AddBaseClassForTypeIndex(
125 llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access,
126 std::optional<uint64_t> vtable_idx = std::optional<uint64_t>());
127 void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx,
128 llvm::codeview::MemberAccess access,
129 llvm::codeview::MethodOptions options,
130 llvm::codeview::MemberAttributes attrs);
131 void FinishRecord();
132 uint64_t AddMember(TypeSystemClang &clang, Member *field, uint64_t bit_offset,
133 CompilerType parent_ct,
134 ClangASTImporter::LayoutInfo &parent_layout,
135 clang::DeclContext *decl_ctx);
136};
137
138} // namespace npdb
139} // namespace lldb_private
140
141#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
Generic representation of a type in a programming language.
A TypeSystem implementation based on Clang.
PdbIndex - Lazy access to the important parts of a PDB file.
Definition PdbIndex.h:47
llvm::DenseMap< lldb::opaque_compiler_type_t, llvm::SmallSet< std::pair< llvm::StringRef, CompilerType >, 8 > > & m_cxx_record_map
ClangASTImporter::LayoutInfo m_layout
std::pair< uint64_t, std::unique_ptr< clang::CXXBaseSpecifier > > IndexedBase
llvm::DenseMap< clang::Decl *, DeclStatus > & m_decl_to_status
uint64_t AddMember(TypeSystemClang &clang, Member *field, uint64_t bit_offset, CompilerType parent_ct, ClangASTImporter::LayoutInfo &parent_layout, clang::DeclContext *decl_ctx)
clang::QualType AddBaseClassForTypeIndex(llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access, std::optional< uint64_t > vtable_idx=std::optional< uint64_t >())
void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx, llvm::codeview::MemberAccess access, llvm::codeview::MethodOptions options, llvm::codeview::MemberAttributes attrs)
UdtRecordCompleter(PdbTypeSymId id, CompilerType &derived_ct, clang::TagDecl &tag_decl, PdbAstBuilder &ast_builder, PdbIndex &index, llvm::DenseMap< clang::Decl *, DeclStatus > &decl_to_status, llvm::DenseMap< lldb::opaque_compiler_type_t, llvm::SmallSet< std::pair< llvm::StringRef, CompilerType >, 8 > > &cxx_record_map)
#define UINT64_MAX
A class that represents a running process on the host machine.
void * opaque_compiler_type_t
Definition lldb-types.h:89
Member(llvm::StringRef name, uint64_t bit_offset, uint64_t bit_size, clang::QualType qt, lldb::AccessType access, uint32_t bitfield_width)
enum lldb_private::npdb::UdtRecordCompleter::Member::Kind kind
void CollectMember(llvm::StringRef name, uint64_t offset, uint64_t field_size, clang::QualType qt, lldb::AccessType access, uint64_t bitfield_width)
std::map< uint64_t, llvm::SmallVector< MemberUP, 1 > > fields_map