ClangModulesDeclVendor.h revision 292932
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 10#ifndef liblldb_ClangModulesDeclVendor_h 11#define liblldb_ClangModulesDeclVendor_h 12 13#include "lldb/Core/ArchSpec.h" 14#include "lldb/Core/ClangForward.h" 15#include "lldb/Symbol/DeclVendor.h" 16#include "lldb/Target/Platform.h" 17 18#include <set> 19#include <vector> 20 21namespace lldb_private 22{ 23 24class ClangModulesDeclVendor : public DeclVendor 25{ 26public: 27 //------------------------------------------------------------------ 28 // Constructors and Destructors 29 //------------------------------------------------------------------ 30 ClangModulesDeclVendor(); 31 32 ~ClangModulesDeclVendor() override; 33 34 static ClangModulesDeclVendor * 35 Create(Target &target); 36 37 typedef std::vector<ConstString> ModulePath; 38 typedef uintptr_t ModuleID; 39 typedef std::vector<ModuleID> ModuleVector; 40 41 //------------------------------------------------------------------ 42 /// Add a module to the list of modules to search. 43 /// 44 /// @param[in] path 45 /// The path to the exact module to be loaded. E.g., if the desired 46 /// module is std.io, then this should be { "std", "io" }. 47 /// 48 /// @param[in] exported_modules 49 /// If non-NULL, a pointer to a vector to populate with the ID of every 50 /// module that is re-exported by the specified module. 51 /// 52 /// @param[in] error_stream 53 /// A stream to populate with the output of the Clang parser when 54 /// it tries to load the module. 55 /// 56 /// @return 57 /// True if the module could be loaded; false if not. If the 58 /// compiler encountered a fatal error during a previous module 59 /// load, then this will always return false for this ModuleImporter. 60 //------------------------------------------------------------------ 61 virtual bool 62 AddModule(ModulePath &path, 63 ModuleVector *exported_modules, 64 Stream &error_stream) = 0; 65 66 //------------------------------------------------------------------ 67 /// Add all modules referred to in a given compilation unit to the list 68 /// of modules to search. 69 /// 70 /// @param[in] cu 71 /// The compilation unit to scan for imported modules. 72 /// 73 /// @param[in] exported_modules 74 /// A vector to populate with the ID of each module loaded (directly 75 /// and via re-exports) in this way. 76 /// 77 /// @param[in] error_stream 78 /// A stream to populate with the output of the Clang parser when 79 /// it tries to load the modules. 80 /// 81 /// @return 82 /// True if all modules referred to by the compilation unit could be 83 /// loaded; false if one could not be loaded. If the compiler 84 /// encountered a fatal error during a previous module 85 /// load, then this will always return false for this ModuleImporter. 86 //------------------------------------------------------------------ 87 virtual bool 88 AddModulesForCompileUnit(CompileUnit &cu, 89 ModuleVector &exported_modules, 90 Stream &error_stream) = 0; 91 92 //------------------------------------------------------------------ 93 /// Enumerate all the macros that are defined by a given set of modules 94 /// that are already imported. 95 /// 96 /// @param[in] modules 97 /// The unique IDs for all modules to query. Later modules have higher 98 /// priority, just as if you @imported them in that order. This matters 99 /// if module A #defines a macro and module B #undefs it. 100 /// 101 /// @param[in] handler 102 /// A function to call with the text of each #define (including the 103 /// #define directive). #undef directives are not included; we simply 104 /// elide any corresponding #define. If this function returns true, 105 /// we stop the iteration immediately. 106 //------------------------------------------------------------------ 107 virtual void 108 ForEachMacro(const ModuleVector &modules, 109 std::function<bool (const std::string &)> handler) = 0; 110 111 //------------------------------------------------------------------ 112 /// Query whether Clang supports modules for a particular language. 113 /// LLDB uses this to decide whether to try to find the modules loaded 114 /// by a gaiven compile unit. 115 /// 116 /// @param[in] language 117 /// The language to query for. 118 /// 119 /// @return 120 /// True if Clang has modules for the given language. 121 //------------------------------------------------------------------ 122 static bool 123 LanguageSupportsClangModules (lldb::LanguageType language); 124}; 125 126} // namespace lldb_private 127 128#endif // liblldb_ClangModulesDeclVendor_h 129