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