LLDB mainline
ClangModulesDeclVendor.h
Go to the documentation of this file.
1//===-- ClangModulesDeclVendor.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_CLANGMODULESDECLVENDOR_H
10#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
11
15
16#include <set>
17#include <vector>
18
19namespace lldb_private {
20
22public:
23 // Constructors and Destructors
25
27
28 static bool classof(const DeclVendor *vendor) {
29 return vendor->GetKind() == eClangModuleDeclVendor;
30 }
31
32 static ClangModulesDeclVendor *Create(Target &target);
33
34 typedef std::vector<ConstString> ModulePath;
35 typedef uintptr_t ModuleID;
36 typedef std::vector<ModuleID> ModuleVector;
37
38 /// Add a module to the list of modules to search.
39 ///
40 /// \param[in] module
41 /// The path to the exact module to be loaded. E.g., if the desired
42 /// module is std.io, then this should be { "std", "io" }.
43 ///
44 /// \param[out] exported_modules
45 /// If non-NULL, a pointer to a vector to populate with the ID of every
46 /// module that is re-exported by the specified module.
47 ///
48 /// \return
49 /// True if the module could be loaded; false if not. If the
50 /// compiler encountered a fatal error during a previous module
51 /// load, then this will always return false for this ModuleImporter.
52 virtual llvm::Error AddModule(const SourceModule &module,
53 ModuleVector *exported_modules) = 0;
54
55 /// Add all modules referred to in a given compilation unit to the list
56 /// of modules to search.
57 ///
58 /// \param[in] cu
59 /// The compilation unit to scan for imported modules.
60 ///
61 /// \param[out] exported_modules
62 /// A vector to populate with the ID of each module loaded (directly
63 /// and via re-exports) in this way.
64 ///
65 /// \return
66 /// True if all modules referred to by the compilation unit could be
67 /// loaded; false if one could not be loaded. If the compiler
68 /// encountered a fatal error during a previous module
69 /// load, then this will always return false for this ModuleImporter.
70 virtual llvm::Error
72
73 /// Enumerate all the macros that are defined by a given set of modules
74 /// that are already imported.
75 ///
76 /// \param[in] modules
77 /// The unique IDs for all modules to query. Later modules have higher
78 /// priority, just as if you @imported them in that order. This matters
79 /// if module A #defines a macro and module B #undefs it.
80 ///
81 /// \param[in] handler
82 /// A function to call with the identifier of this macro and the text of
83 /// each #define (including the #define directive). #undef directives are
84 /// not included; we simply elide any corresponding #define. If this
85 /// function returns true, we stop the iteration immediately.
86 virtual void ForEachMacro(
87 const ModuleVector &modules,
88 std::function<bool(llvm::StringRef, llvm::StringRef)> handler) = 0;
89
90 /// Query whether Clang supports modules for a particular language.
91 /// LLDB uses this to decide whether to try to find the modules loaded
92 /// by a given compile unit.
93 ///
94 /// \param[in] language
95 /// The language to query for.
96 ///
97 /// \return
98 /// True if Clang has modules for the given language.
100};
101
102} // namespace lldb_private
103
104#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
virtual llvm::Error AddModulesForCompileUnit(CompileUnit &cu, ModuleVector &exported_modules)=0
Add all modules referred to in a given compilation unit to the list of modules to search.
static ClangModulesDeclVendor * Create(Target &target)
virtual void ForEachMacro(const ModuleVector &modules, std::function< bool(llvm::StringRef, llvm::StringRef)> handler)=0
Enumerate all the macros that are defined by a given set of modules that are already imported.
virtual llvm::Error AddModule(const SourceModule &module, ModuleVector *exported_modules)=0
Add a module to the list of modules to search.
static bool LanguageSupportsClangModules(lldb::LanguageType language)
Query whether Clang supports modules for a particular language.
static bool classof(const DeclVendor *vendor)
A class that describes a compilation unit.
Definition CompileUnit.h:43
DeclVendorKind GetKind() const
Definition DeclVendor.h:32
DeclVendor(DeclVendorKind kind)
Definition DeclVendor.h:28
A class that represents a running process on the host machine.
LanguageType
Programming language type.
Information needed to import a source-language module.