Index: lldb/include/lldb/Core/PluginManager.h =================================================================== --- lldb/include/lldb/Core/PluginManager.h +++ lldb/include/lldb/Core/PluginManager.h @@ -428,6 +428,7 @@ // TypeSystem static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, TypeSystemCreateInstance create_callback, + DebuggerInitializeCallback debugger_callback, LanguageSet supported_languages_for_types, LanguageSet supported_languages_for_expressions); @@ -487,6 +488,13 @@ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, ConstString description, bool is_global_property); + static lldb::OptionValuePropertiesSP + GetSettingForTypeSystemPlugin(Debugger &debugger, ConstString setting_name); + + static bool CreateSettingForTypeSystemPlugin( + Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, + ConstString description, bool is_global_property); + static lldb::OptionValuePropertiesSP GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name); Index: lldb/source/Core/PluginManager.cpp =================================================================== --- lldb/source/Core/PluginManager.cpp +++ lldb/source/Core/PluginManager.cpp @@ -1258,10 +1258,11 @@ struct TypeSystemInstance : public PluginInstance { TypeSystemInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, + DebuggerInitializeCallback debugger_init_callback, LanguageSet supported_languages_for_types, LanguageSet supported_languages_for_expressions) - : PluginInstance(name, description, - create_callback), + : PluginInstance( + name, description, create_callback, debugger_init_callback), supported_languages_for_types(supported_languages_for_types), supported_languages_for_expressions( supported_languages_for_expressions) {} @@ -1280,11 +1281,12 @@ bool PluginManager::RegisterPlugin( llvm::StringRef name, llvm::StringRef description, TypeSystemCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback, LanguageSet supported_languages_for_types, LanguageSet supported_languages_for_expressions) { return GetTypeSystemInstances().RegisterPlugin( - name, description, create_callback, supported_languages_for_types, - supported_languages_for_expressions); + name, description, create_callback, debugger_init_callback, + supported_languages_for_types, supported_languages_for_expressions); } bool PluginManager::UnregisterPlugin(TypeSystemCreateInstance create_callback) { @@ -1364,6 +1366,7 @@ GetOperatingSystemInstances().PerformDebuggerCallback(debugger); GetStructuredDataPluginInstances().PerformDebuggerCallback(debugger); GetTracePluginInstances().PerformDebuggerCallback(debugger); + GetTypeSystemInstances().PerformDebuggerCallback(debugger); } // This is the preferred new way to register plugin specific settings. e.g. @@ -1485,6 +1488,7 @@ static const char *kPlatformPluginName("platform"); static const char *kProcessPluginName("process"); static const char *kSymbolFilePluginName("symbol-file"); +static const char *kTypeSystemPluginName("typesystem"); static const char *kJITLoaderPluginName("jit-loader"); static const char *kStructuredDataPluginName("structured-data"); @@ -1552,6 +1556,22 @@ description, is_global_property); } +lldb::OptionValuePropertiesSP +PluginManager::GetSettingForTypeSystemPlugin(Debugger &debugger, + ConstString setting_name) { + return GetSettingForPlugin(debugger, setting_name, + ConstString(kTypeSystemPluginName)); +} + +bool PluginManager::CreateSettingForTypeSystemPlugin( + Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, + ConstString description, bool is_global_property) { + return CreateSettingForPlugin( + debugger, ConstString(kTypeSystemPluginName), + ConstString("Settings for type system plug-ins"), properties_sp, + description, is_global_property); +} + lldb::OptionValuePropertiesSP PluginManager::GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name) { Index: lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt +++ lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt @@ -1,3 +1,11 @@ +lldb_tablegen(TypeSystemClangProperties.inc -gen-lldb-property-defs + SOURCE TypeSystemClangProperties.td + TARGET LLDBPluginTypeSystemClangPropertiesGen) + +lldb_tablegen(TypeSystemClangPropertiesEnum.inc -gen-lldb-property-enum-defs + SOURCE TypeSystemClangProperties.td + TARGET LLDBPluginTypeSystemClangPropertiesEnumGen) + add_lldb_library(lldbPluginTypeSystemClang PLUGIN ImporterBackedASTSource.cpp TypeSystemClang.cpp @@ -19,3 +27,7 @@ LINK_COMPONENTS Support ) + +add_dependencies(lldbPluginTypeSystemClang + LLDBPluginTypeSystemClangPropertiesGen + LLDBPluginTypeSystemClangPropertiesEnumGen) Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -148,6 +148,8 @@ static LanguageSet GetSupportedLanguagesForTypes(); static LanguageSet GetSupportedLanguagesForExpressions(); + static void DebuggerInitialize(Debugger &debugger); + static void Initialize(); static void Terminate(); @@ -482,6 +484,14 @@ DWARFASTParser *GetDWARFParser() override; PDBASTParser *GetPDBParser() override; + /// If true, then declarations are completed by completing their redeclaration + /// chain. + /// + /// Initially declarations might just be forward declared in an AST but have a + /// defining redeclaration (that might be lazily added to the AST via the + /// ExternalASTSource). + static bool UseRedeclCompletion(); + // TypeSystemClang callbacks for external source lookups. void CompleteTagDecl(clang::TagDecl *); Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -59,6 +59,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Core/UniqueCStringMap.h" +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Target/ExecutionContext.h" @@ -86,6 +87,40 @@ LLDB_PLUGIN_DEFINE(TypeSystemClang) +namespace { + +#define LLDB_PROPERTIES_typesystemclang +#include "TypeSystemClangProperties.inc" + +enum { +#define LLDB_PROPERTIES_typesystemclang +#include "TypeSystemClangPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static ConstString GetSettingName() { + return ConstString(TypeSystemClang::GetPluginNameStatic()); + } + + PluginProperties() { + m_collection_sp = std::make_shared(GetSettingName()); + m_collection_sp->Initialize(g_typesystemclang_properties); + } + + bool UseRedeclCompletion() const { + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, ePropertyRedeclCompletion, false); + } +}; + +static PluginProperties &GetGlobalPluginProperties() { + static PluginProperties g_settings; + return g_settings; +} + +} // namespace + namespace { static void VerifyDecl(clang::Decl *decl) { assert(decl && "VerifyDecl called with nullptr?"); @@ -634,10 +669,22 @@ return languages; } +void TypeSystemClang::DebuggerInitialize(Debugger &debugger) { + if (PluginManager::GetSettingForTypeSystemPlugin( + debugger, PluginProperties::GetSettingName())) + return; + const bool is_global_setting = true; + PluginManager::CreateSettingForTypeSystemPlugin( + debugger, GetGlobalPluginProperties().GetValueProperties(), + ConstString("Properties for the Clang type system plug-in."), + is_global_setting); +} + void TypeSystemClang::Initialize() { PluginManager::RegisterPlugin( GetPluginNameStatic(), "clang base AST context plug-in", CreateInstance, - GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions()); + DebuggerInitialize, GetSupportedLanguagesForTypes(), + GetSupportedLanguagesForExpressions()); } void TypeSystemClang::Terminate() { @@ -9374,6 +9421,10 @@ return m_pdb_ast_parser_up.get(); } +bool TypeSystemClang::UseRedeclCompletion() { + return GetGlobalPluginProperties().UseRedeclCompletion(); +} + bool TypeSystemClang::LayoutRecordType( const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClangProperties.td =================================================================== --- /dev/null +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClangProperties.td @@ -0,0 +1,8 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "typesystemclang" in { + def RedeclCompletion: Property<"experimental-redecl-completion", "Boolean">, + Global, + DefaultFalse, + Desc<"Use redeclarations to complete Clang types. Experimental setting.">; +}