Sean Callanan | c631b64 | 2014-12-05 01:26:42 +0000 | [diff] [blame] | 1 | //===-- 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 Labath | 083645b | 2015-08-18 09:18:19 +0000 | [diff] [blame] | 10 | #ifndef liblldb_ClangModulesDeclVendor_h |
| 11 | #define liblldb_ClangModulesDeclVendor_h |
Sean Callanan | c631b64 | 2014-12-05 01:26:42 +0000 | [diff] [blame] | 12 | |
Sean Callanan | c631b64 | 2014-12-05 01:26:42 +0000 | [diff] [blame] | 13 | #include "lldb/Core/ClangForward.h" |
| 14 | #include "lldb/Symbol/DeclVendor.h" |
| 15 | #include "lldb/Target/Platform.h" |
| 16 | |
Sean Callanan | f0c5aeb | 2015-04-20 16:31:29 +0000 | [diff] [blame] | 17 | #include <set> |
Sean Callanan | c631b64 | 2014-12-05 01:26:42 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 20 | namespace lldb_private { |
Sean Callanan | f0c5aeb | 2015-04-20 16:31:29 +0000 | [diff] [blame] | 21 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 22 | class ClangModulesDeclVendor : public DeclVendor { |
| 23 | public: |
| 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 Callanan | c631b64 | 2014-12-05 01:26:42 +0000 | [diff] [blame] | 116 | }; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 117 | |
Pavel Labath | 083645b | 2015-08-18 09:18:19 +0000 | [diff] [blame] | 118 | } // namespace lldb_private |
| 119 | |
| 120 | #endif // liblldb_ClangModulesDeclVendor_h |