brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · d0eabb5 Raw
76 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H10#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H11 12#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"13#include "clang/Basic/ASTSourceDescriptor.h"14#include <optional>15 16namespace clang {17 18class Module;19 20} // namespace clang21 22namespace lldb_private {23 24class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {25  /// LLVM RTTI support.26  static char ID;27 28public: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); }32 33  ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {}34 35  void FindExternalLexicalDecls(36      const clang::DeclContext *DC,37      llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,38      llvm::SmallVectorImpl<clang::Decl *> &Result) override;39 40  bool41  FindExternalVisibleDeclsByName(const clang::DeclContext *DC,42                                 clang::DeclarationName Name,43                                 const clang::DeclContext *OriginalDC) override;44 45  void CompleteType(clang::TagDecl *tag_decl) override;46 47  void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;48 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>53          &BaseOffsets,54      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>55          &VirtualBaseOffsets) override;56 57  TypeSystemClang &GetTypeSystem() const { return m_ast; }58 59  /// Module-related methods.60  /// \{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);66  /// \}67private:68  TypeSystemClang &m_ast;69  std::vector<clang::Module *> m_modules;70  llvm::DenseMap<clang::Module *, unsigned> m_ids;71};72 73} // namespace lldb_private74 75#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H76