1 //===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
10 #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
12 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
13 #include "clang/Basic/ASTSourceDescriptor.h"
22 namespace lldb_private
{
24 class ClangExternalASTSourceCallbacks
: public clang::ExternalASTSource
{
25 /// LLVM RTTI support.
29 /// LLVM RTTI support.
30 bool isA(const void *ClassID
) const override
{ return ClassID
== &ID
; }
31 static bool classof(const clang::ExternalASTSource
*s
) { return s
->isA(&ID
); }
33 ClangExternalASTSourceCallbacks(TypeSystemClang
&ast
) : m_ast(ast
) {}
35 void FindExternalLexicalDecls(
36 const clang::DeclContext
*DC
,
37 llvm::function_ref
<bool(clang::Decl::Kind
)> IsKindWeWant
,
38 llvm::SmallVectorImpl
<clang::Decl
*> &Result
) override
;
41 FindExternalVisibleDeclsByName(const clang::DeclContext
*DC
,
42 clang::DeclarationName Name
,
43 const clang::DeclContext
*OriginalDC
) override
;
45 void CompleteType(clang::TagDecl
*tag_decl
) override
;
47 void CompleteType(clang::ObjCInterfaceDecl
*objc_decl
) override
;
49 bool layoutRecordType(
50 const clang::RecordDecl
*Record
, uint64_t &Size
, uint64_t &Alignment
,
51 llvm::DenseMap
<const clang::FieldDecl
*, uint64_t> &FieldOffsets
,
52 llvm::DenseMap
<const clang::CXXRecordDecl
*, clang::CharUnits
>
54 llvm::DenseMap
<const clang::CXXRecordDecl
*, clang::CharUnits
>
55 &VirtualBaseOffsets
) override
;
57 TypeSystemClang
&GetTypeSystem() const { return m_ast
; }
59 /// Module-related methods.
61 std::optional
<clang::ASTSourceDescriptor
>
62 getSourceDescriptor(unsigned ID
) override
;
63 clang::Module
*getModule(unsigned ID
) override
;
64 OptionalClangModuleID
RegisterModule(clang::Module
*module
);
65 OptionalClangModuleID
GetIDForModule(clang::Module
*module
);
68 TypeSystemClang
&m_ast
;
69 std::vector
<clang::Module
*> m_modules
;
70 llvm::DenseMap
<clang::Module
*, unsigned> m_ids
;
73 } // namespace lldb_private
75 #endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H