1 //===-- ClangExternalASTSourceCallbacks.cpp -------------------------------===//
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 #include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
10 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
11 
12 #include "clang/AST/Decl.h"
13 
14 using namespace lldb_private;
15 
16 void ClangExternalASTSourceCallbacks::CompleteType(clang::TagDecl *tag_decl) {
17   m_ast.CompleteTagDecl(tag_decl);
18 }
19 
20 void ClangExternalASTSourceCallbacks::CompleteType(
21     clang::ObjCInterfaceDecl *objc_decl) {
22   m_ast.CompleteObjCInterfaceDecl(objc_decl);
23 }
24 
25 bool ClangExternalASTSourceCallbacks::layoutRecordType(
26     const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
27     llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
28     llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
29     llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
30         &VirtualBaseOffsets) {
31   return m_ast.LayoutRecordType(Record, Size, Alignment, FieldOffsets,
32                                 BaseOffsets, VirtualBaseOffsets);
33 }
34 
35 void ClangExternalASTSourceCallbacks::FindExternalLexicalDecls(
36     const clang::DeclContext *decl_ctx,
37     llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
38     llvm::SmallVectorImpl<clang::Decl *> &decls) {
39   if (decl_ctx) {
40     clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(
41         const_cast<clang::DeclContext *>(decl_ctx));
42     if (tag_decl)
43       CompleteType(tag_decl);
44   }
45 }
46