blob: 23769ccfb0c048cc28c9ad3cbcd7ce525627c02b [file] [log] [blame]
Sean Callananc631b642014-12-05 01:26:42 +00001//===-- ClangModulesDeclVendor.h --------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Pavel Labath083645b2015-08-18 09:18:19 +000010#ifndef liblldb_ClangModulesDeclVendor_h
11#define liblldb_ClangModulesDeclVendor_h
Sean Callananc631b642014-12-05 01:26:42 +000012
Sean Callananc631b642014-12-05 01:26:42 +000013#include "lldb/Core/ClangForward.h"
14#include "lldb/Symbol/DeclVendor.h"
15#include "lldb/Target/Platform.h"
16
Sean Callananf0c5aeb2015-04-20 16:31:29 +000017#include <set>
Sean Callananc631b642014-12-05 01:26:42 +000018#include <vector>
19
Kate Stoneb9c1b512016-09-06 20:57:50 +000020namespace lldb_private {
Sean Callananf0c5aeb2015-04-20 16:31:29 +000021
Kate Stoneb9c1b512016-09-06 20:57:50 +000022class ClangModulesDeclVendor : public DeclVendor {
23public:
24 //------------------------------------------------------------------
25 // Constructors and Destructors
26 //------------------------------------------------------------------
27 ClangModulesDeclVendor();
28
29 ~ClangModulesDeclVendor() override;
30
31 static ClangModulesDeclVendor *Create(Target &target);
32
33 typedef std::vector<ConstString> ModulePath;
34 typedef uintptr_t ModuleID;
35 typedef std::vector<ModuleID> ModuleVector;
36
37 //------------------------------------------------------------------
38 /// Add a module to the list of modules to search.
39 ///
40 /// @param[in] path
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 //------------------------------------------------------------------
57 virtual bool AddModule(ModulePath &path, ModuleVector *exported_modules,
58 Stream &error_stream) = 0;
59
60 //------------------------------------------------------------------
61 /// Add all modules referred to in a given compilation unit to the list
62 /// of modules to search.
63 ///
64 /// @param[in] cu
65 /// The compilation unit to scan for imported modules.
66 ///
67 /// @param[in] exported_modules
68 /// A vector to populate with the ID of each module loaded (directly
69 /// and via re-exports) in this way.
70 ///
71 /// @param[in] error_stream
72 /// A stream to populate with the output of the Clang parser when
73 /// it tries to load the modules.
74 ///
75 /// @return
76 /// True if all modules referred to by the compilation unit could be
77 /// loaded; false if one could not be loaded. If the compiler
78 /// encountered a fatal error during a previous module
79 /// load, then this will always return false for this ModuleImporter.
80 //------------------------------------------------------------------
81 virtual bool AddModulesForCompileUnit(CompileUnit &cu,
82 ModuleVector &exported_modules,
83 Stream &error_stream) = 0;
84
85 //------------------------------------------------------------------
86 /// Enumerate all the macros that are defined by a given set of modules
87 /// that are already imported.
88 ///
89 /// @param[in] modules
90 /// The unique IDs for all modules to query. Later modules have higher
91 /// priority, just as if you @imported them in that order. This matters
92 /// if module A #defines a macro and module B #undefs it.
93 ///
94 /// @param[in] handler
95 /// A function to call with the text of each #define (including the
96 /// #define directive). #undef directives are not included; we simply
97 /// elide any corresponding #define. If this function returns true,
98 /// we stop the iteration immediately.
99 //------------------------------------------------------------------
100 virtual void
101 ForEachMacro(const ModuleVector &modules,
102 std::function<bool(const std::string &)> handler) = 0;
103
104 //------------------------------------------------------------------
105 /// Query whether Clang supports modules for a particular language.
106 /// LLDB uses this to decide whether to try to find the modules loaded
107 /// by a gaiven compile unit.
108 ///
109 /// @param[in] language
110 /// The language to query for.
111 ///
112 /// @return
113 /// True if Clang has modules for the given language.
114 //------------------------------------------------------------------
115 static bool LanguageSupportsClangModules(lldb::LanguageType language);
Sean Callananc631b642014-12-05 01:26:42 +0000116};
Kate Stoneb9c1b512016-09-06 20:57:50 +0000117
Pavel Labath083645b2015-08-18 09:18:19 +0000118} // namespace lldb_private
119
120#endif // liblldb_ClangModulesDeclVendor_h