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 12 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" 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. isA(const void * ClassID)23 bool isA(const void *ClassID) const override { return ClassID == &ID; } classof(const clang::ExternalASTSource * s)24 static bool classof(const clang::ExternalASTSource *s) { return s->isA(&ID); } 25 ClangExternalASTSourceCallbacks(TypeSystemClang & ast)26 ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {} 27 28 void FindExternalLexicalDecls( 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 GetTypeSystem()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: 59 TypeSystemClang &m_ast; 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 67