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[in] 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 /// \param[in] error_stream
49 /// A stream to populate with the output of the Clang parser when
50 /// it tries to load the module.
51 ///
52 /// \return
53 /// True if the module could be loaded; false if not. If the
54 /// compiler encountered a fatal error during a previous module
55 /// load, then this will always return false for this ModuleImporter.
56 virtual bool AddModule(const SourceModule &module,
57 ModuleVector *exported_modules,
58 Stream &error_stream) = 0;
59
60 /// Add all modules referred to in a given compilation unit to the list
61 /// of modules to search.
62 ///
63 /// \param[in] cu
64 /// The compilation unit to scan for imported modules.
65 ///
66 /// \param[in] exported_modules
67 /// A vector to populate with the ID of each module loaded (directly
68 /// and via re-exports) in this way.
69 ///
70 /// \param[in] error_stream
71 /// A stream to populate with the output of the Clang parser when
72 /// it tries to load the modules.
73 ///
74 /// \return
75 /// True if all modules referred to by the compilation unit could be
76 /// loaded; false if one could not be loaded. If the compiler
77 /// encountered a fatal error during a previous module
78 /// load, then this will always return false for this ModuleImporter.
80 ModuleVector &exported_modules,
81 Stream &error_stream) = 0;
82
83 /// Enumerate all the macros that are defined by a given set of modules
84 /// that are already imported.
85 ///
86 /// \param[in] modules
87 /// The unique IDs for all modules to query. Later modules have higher
88 /// priority, just as if you @imported them in that order. This matters
89 /// if module A #defines a macro and module B #undefs it.
90 ///
91 /// \param[in] handler
92 /// A function to call with the identifier of this macro and the text of
93 /// each #define (including the #define directive). #undef directives are
94 /// not included; we simply elide any corresponding #define. If this
95 /// function returns true, we stop the iteration immediately.
96 virtual void ForEachMacro(
97 const ModuleVector &modules,
98 std::function<bool(llvm::StringRef, llvm::StringRef)> handler) = 0;
99
100 /// Query whether Clang supports modules for a particular language.
101 /// LLDB uses this to decide whether to try to find the modules loaded
102 /// by a given compile unit.
103 ///
104 /// \param[in] language
105 /// The language to query for.
106 ///
107 /// \return
108 /// True if Clang has modules for the given language.
110};
111
112} // namespace lldb_private
113
114#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
static ClangModulesDeclVendor * Create(Target &target)
virtual bool AddModulesForCompileUnit(CompileUnit &cu, ModuleVector &exported_modules, Stream &error_stream)=0
Add all modules referred to in a given compilation unit to the list of modules to search.
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.
static bool LanguageSupportsClangModules(lldb::LanguageType language)
Query whether Clang supports modules for a particular language.
virtual bool AddModule(const SourceModule &module, ModuleVector *exported_modules, Stream &error_stream)=0
Add a module to the list of modules to search.
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 stream class that can stream formatted output to a file.
Definition Stream.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.