1//===-- PDBASTParser.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_PDB_PDBASTPARSER_H
10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
11
12#include "lldb/lldb-forward.h"
13
14#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
15
16class SymbolFilePDB;
17
18namespace clang {
19class CharUnits;
20class CXXRecordDecl;
21class FieldDecl;
22class RecordDecl;
23} // namespace clang
24
25namespace lldb_private {
26class TypeSystemClang;
27class CompilerType;
28} // namespace lldb_private
29
30namespace llvm {
31namespace pdb {
32template <typename ChildType> class ConcreteSymbolEnumerator;
33
34class PDBSymbol;
35class PDBSymbolData;
36class PDBSymbolFunc;
37class PDBSymbolTypeBaseClass;
38class PDBSymbolTypeBuiltin;
39class PDBSymbolTypeUDT;
40} // namespace pdb
41} // namespace llvm
42
43class PDBASTParser {
44public:
45 PDBASTParser(lldb_private::TypeSystemClang &ast);
46 ~PDBASTParser();
47
48 lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type);
49 bool CompleteTypeFromPDB(lldb_private::CompilerType &compiler_type);
50
51 clang::Decl *GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol);
52
53 clang::DeclContext *
54 GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol);
55 clang::DeclContext *
56 GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol);
57
58 void ParseDeclsForDeclContext(const clang::DeclContext *decl_context);
59
60 clang::NamespaceDecl *FindNamespaceDecl(const clang::DeclContext *parent,
61 llvm::StringRef name);
62
63 lldb_private::ClangASTImporter &GetClangASTImporter() {
64 return m_ast_importer;
65 }
66
67private:
68 typedef llvm::DenseMap<clang::CXXRecordDecl *, lldb::user_id_t>
69 CXXRecordDeclToUidMap;
70 typedef llvm::DenseMap<lldb::user_id_t, clang::Decl *> UidToDeclMap;
71 typedef std::set<clang::NamespaceDecl *> NamespacesSet;
72 typedef llvm::DenseMap<clang::DeclContext *, NamespacesSet>
73 ParentToNamespacesMap;
74 typedef llvm::DenseMap<clang::DeclContext *, lldb::user_id_t>
75 DeclContextToUidMap;
76 typedef llvm::pdb::ConcreteSymbolEnumerator<llvm::pdb::PDBSymbolData>
77 PDBDataSymbolEnumerator;
78 typedef llvm::pdb::ConcreteSymbolEnumerator<llvm::pdb::PDBSymbolTypeBaseClass>
79 PDBBaseClassSymbolEnumerator;
80 typedef llvm::pdb::ConcreteSymbolEnumerator<llvm::pdb::PDBSymbolFunc>
81 PDBFuncSymbolEnumerator;
82
83 bool AddEnumValue(lldb_private::CompilerType enum_type,
84 const llvm::pdb::PDBSymbolData &data);
85 bool CompleteTypeFromUDT(lldb_private::SymbolFile &symbol_file,
86 lldb_private::CompilerType &compiler_type,
87 llvm::pdb::PDBSymbolTypeUDT &udt);
88 void
89 AddRecordMembers(lldb_private::SymbolFile &symbol_file,
90 lldb_private::CompilerType &record_type,
91 PDBDataSymbolEnumerator &members_enum,
92 lldb_private::ClangASTImporter::LayoutInfo &layout_info);
93 void
94 AddRecordBases(lldb_private::SymbolFile &symbol_file,
95 lldb_private::CompilerType &record_type, int record_kind,
96 PDBBaseClassSymbolEnumerator &bases_enum,
97 lldb_private::ClangASTImporter::LayoutInfo &layout_info) const;
98 void AddRecordMethods(lldb_private::SymbolFile &symbol_file,
99 lldb_private::CompilerType &record_type,
100 PDBFuncSymbolEnumerator &methods_enum);
101 clang::CXXMethodDecl *
102 AddRecordMethod(lldb_private::SymbolFile &symbol_file,
103 lldb_private::CompilerType &record_type,
104 const llvm::pdb::PDBSymbolFunc &method) const;
105
106 lldb_private::TypeSystemClang &m_ast;
107 lldb_private::ClangASTImporter m_ast_importer;
108
109 CXXRecordDeclToUidMap m_forward_decl_to_uid;
110 UidToDeclMap m_uid_to_decl;
111 ParentToNamespacesMap m_parent_to_namespaces;
112 NamespacesSet m_namespaces;
113 DeclContextToUidMap m_decl_context_to_uid;
114};
115
116#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
117

source code of lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h