Path: blob/main/contrib/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
39653 views
//===-- ClangModulesDeclVendor.h --------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H9#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H1011#include "lldb/Symbol/SourceModule.h"12#include "lldb/Target/Platform.h"1314#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"1516#include <set>17#include <vector>1819namespace lldb_private {2021class ClangModulesDeclVendor : public ClangDeclVendor {22public:23// Constructors and Destructors24ClangModulesDeclVendor();2526~ClangModulesDeclVendor() override;2728static bool classof(const DeclVendor *vendor) {29return vendor->GetKind() == eClangModuleDeclVendor;30}3132static ClangModulesDeclVendor *Create(Target &target);3334typedef std::vector<ConstString> ModulePath;35typedef uintptr_t ModuleID;36typedef std::vector<ModuleID> ModuleVector;3738/// Add a module to the list of modules to search.39///40/// \param[in] module41/// The path to the exact module to be loaded. E.g., if the desired42/// module is std.io, then this should be { "std", "io" }.43///44/// \param[in] exported_modules45/// If non-NULL, a pointer to a vector to populate with the ID of every46/// module that is re-exported by the specified module.47///48/// \param[in] error_stream49/// A stream to populate with the output of the Clang parser when50/// it tries to load the module.51///52/// \return53/// True if the module could be loaded; false if not. If the54/// compiler encountered a fatal error during a previous module55/// load, then this will always return false for this ModuleImporter.56virtual bool AddModule(const SourceModule &module,57ModuleVector *exported_modules,58Stream &error_stream) = 0;5960/// Add all modules referred to in a given compilation unit to the list61/// of modules to search.62///63/// \param[in] cu64/// The compilation unit to scan for imported modules.65///66/// \param[in] exported_modules67/// A vector to populate with the ID of each module loaded (directly68/// and via re-exports) in this way.69///70/// \param[in] error_stream71/// A stream to populate with the output of the Clang parser when72/// it tries to load the modules.73///74/// \return75/// True if all modules referred to by the compilation unit could be76/// loaded; false if one could not be loaded. If the compiler77/// encountered a fatal error during a previous module78/// load, then this will always return false for this ModuleImporter.79virtual bool AddModulesForCompileUnit(CompileUnit &cu,80ModuleVector &exported_modules,81Stream &error_stream) = 0;8283/// Enumerate all the macros that are defined by a given set of modules84/// that are already imported.85///86/// \param[in] modules87/// The unique IDs for all modules to query. Later modules have higher88/// priority, just as if you @imported them in that order. This matters89/// if module A #defines a macro and module B #undefs it.90///91/// \param[in] handler92/// A function to call with the identifier of this macro and the text of93/// each #define (including the #define directive). #undef directives are94/// not included; we simply elide any corresponding #define. If this95/// function returns true, we stop the iteration immediately.96virtual void ForEachMacro(97const ModuleVector &modules,98std::function<bool(llvm::StringRef, llvm::StringRef)> handler) = 0;99100/// Query whether Clang supports modules for a particular language.101/// LLDB uses this to decide whether to try to find the modules loaded102/// by a given compile unit.103///104/// \param[in] language105/// The language to query for.106///107/// \return108/// True if Clang has modules for the given language.109static bool LanguageSupportsClangModules(lldb::LanguageType language);110};111112} // namespace lldb_private113114#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H115116117