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