LLDB  mainline
ClangExternalASTSourceCallbacks.h
Go to the documentation of this file.
1 //===-- ClangExternalASTSourceCallbacks.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_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
10 #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
11 
13 #include "clang/Basic/Module.h"
14 
15 namespace lldb_private {
16 
17 class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
18  /// LLVM RTTI support.
19  static char ID;
20 
21 public:
22  /// LLVM RTTI support.
23  bool isA(const void *ClassID) const override { return ClassID == &ID; }
24  static bool classof(const clang::ExternalASTSource *s) { return s->isA(&ID); }
25 
27 
29  const clang::DeclContext *DC,
30  llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
31  llvm::SmallVectorImpl<clang::Decl *> &Result) override;
32 
33  bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC,
34  clang::DeclarationName Name) override;
35 
36  void CompleteType(clang::TagDecl *tag_decl) override;
37 
38  void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
39 
40  bool layoutRecordType(
41  const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
42  llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
43  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
44  &BaseOffsets,
45  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
46  &VirtualBaseOffsets) override;
47 
48  TypeSystemClang &GetTypeSystem() const { return m_ast; }
49 
50  /// Module-related methods.
51  /// \{
52  llvm::Optional<clang::ASTSourceDescriptor>
53  getSourceDescriptor(unsigned ID) override;
54  clang::Module *getModule(unsigned ID) override;
55  OptionalClangModuleID RegisterModule(clang::Module *module);
56  OptionalClangModuleID GetIDForModule(clang::Module *module);
57  /// \}
58 private:
60  std::vector<clang::Module *> m_modules;
61  llvm::DenseMap<clang::Module *, unsigned> m_ids;
62 };
63 
64 } // namespace lldb_private
65 
66 #endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
lldb_private::ClangExternalASTSourceCallbacks::m_ids
llvm::DenseMap< clang::Module *, unsigned > m_ids
Definition: ClangExternalASTSourceCallbacks.h:61
lldb_private::ClangExternalASTSourceCallbacks::CompleteType
void CompleteType(clang::TagDecl *tag_decl) override
Definition: ClangExternalASTSourceCallbacks.cpp:19
lldb_private::ClangExternalASTSourceCallbacks::isA
bool isA(const void *ClassID) const override
LLVM RTTI support.
Definition: ClangExternalASTSourceCallbacks.h:23
lldb_private::ClangExternalASTSourceCallbacks::GetTypeSystem
TypeSystemClang & GetTypeSystem() const
Definition: ClangExternalASTSourceCallbacks.h:48
lldb_private::ClangExternalASTSourceCallbacks::ID
static char ID
LLVM RTTI support.
Definition: ClangExternalASTSourceCallbacks.h:19
lldb_private::ClangExternalASTSourceCallbacks::getModule
clang::Module * getModule(unsigned ID) override
Definition: ClangExternalASTSourceCallbacks.cpp:79
TypeSystemClang.h
lldb_private::ClangExternalASTSourceCallbacks
Definition: ClangExternalASTSourceCallbacks.h:17
lldb_private::ClangExternalASTSourceCallbacks::m_modules
std::vector< clang::Module * > m_modules
Definition: ClangExternalASTSourceCallbacks.h:60
lldb_private::ClangExternalASTSourceCallbacks::getSourceDescriptor
llvm::Optional< clang::ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Module-related methods.
Definition: ClangExternalASTSourceCallbacks.cpp:73
lldb_private::ClangExternalASTSourceCallbacks::layoutRecordType
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &BaseOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &VirtualBaseOffsets) override
Definition: ClangExternalASTSourceCallbacks.cpp:28
lldb_private::ClangExternalASTSourceCallbacks::classof
static bool classof(const clang::ExternalASTSource *s)
Definition: ClangExternalASTSourceCallbacks.h:24
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:57
lldb_private::ClangExternalASTSourceCallbacks::FindExternalLexicalDecls
void FindExternalLexicalDecls(const clang::DeclContext *DC, llvm::function_ref< bool(clang::Decl::Kind)> IsKindWeWant, llvm::SmallVectorImpl< clang::Decl * > &Result) override
Definition: ClangExternalASTSourceCallbacks.cpp:38
lldb_private::ClangExternalASTSourceCallbacks::RegisterModule
OptionalClangModuleID RegisterModule(clang::Module *module)
Definition: ClangExternalASTSourceCallbacks.cpp:65
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ClangExternalASTSourceCallbacks::GetIDForModule
OptionalClangModuleID GetIDForModule(clang::Module *module)
Definition: ClangExternalASTSourceCallbacks.cpp:86
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:106
lldb_private::ClangExternalASTSourceCallbacks::m_ast
TypeSystemClang & m_ast
Definition: ClangExternalASTSourceCallbacks.h:59
lldb_private::ClangExternalASTSourceCallbacks::ClangExternalASTSourceCallbacks
ClangExternalASTSourceCallbacks(TypeSystemClang &ast)
Definition: ClangExternalASTSourceCallbacks.h:26
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName
bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name) override
Definition: ClangExternalASTSourceCallbacks.cpp:50