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/Module.h"
16 namespace lldb_private
{
18 class ClangExternalASTSourceCallbacks
: public clang::ExternalASTSource
{
19 /// LLVM RTTI support.
23 /// LLVM RTTI support.
24 bool isA(const void *ClassID
) const override
{ return ClassID
== &ID
; }
25 static bool classof(const clang::ExternalASTSource
*s
) { return s
->isA(&ID
); }
27 ClangExternalASTSourceCallbacks(TypeSystemClang
&ast
) : m_ast(ast
) {}
29 void FindExternalLexicalDecls(
30 const clang::DeclContext
*DC
,
31 llvm::function_ref
<bool(clang::Decl::Kind
)> IsKindWeWant
,
32 llvm::SmallVectorImpl
<clang::Decl
*> &Result
) override
;
34 bool FindExternalVisibleDeclsByName(const clang::DeclContext
*DC
,
35 clang::DeclarationName Name
) override
;
37 void CompleteType(clang::TagDecl
*tag_decl
) override
;
39 void CompleteType(clang::ObjCInterfaceDecl
*objc_decl
) override
;
41 bool layoutRecordType(
42 const clang::RecordDecl
*Record
, uint64_t &Size
, uint64_t &Alignment
,
43 llvm::DenseMap
<const clang::FieldDecl
*, uint64_t> &FieldOffsets
,
44 llvm::DenseMap
<const clang::CXXRecordDecl
*, clang::CharUnits
>
46 llvm::DenseMap
<const clang::CXXRecordDecl
*, clang::CharUnits
>
47 &VirtualBaseOffsets
) override
;
49 TypeSystemClang
&GetTypeSystem() const { return m_ast
; }
51 /// Module-related methods.
53 std::optional
<clang::ASTSourceDescriptor
>
54 getSourceDescriptor(unsigned ID
) override
;
55 clang::Module
*getModule(unsigned ID
) override
;
56 OptionalClangModuleID
RegisterModule(clang::Module
*module
);
57 OptionalClangModuleID
GetIDForModule(clang::Module
*module
);
60 TypeSystemClang
&m_ast
;
61 std::vector
<clang::Module
*> m_modules
;
62 llvm::DenseMap
<clang::Module
*, unsigned> m_ids
;
65 } // namespace lldb_private
67 #endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H