diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -75,8 +75,6 @@ const char *GetObjectDescription(); - const char *GetTypeValidatorResult(); - lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic); lldb::SBValue GetStaticValue(); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -179,7 +179,6 @@ eClearUserVisibleDataItemsLocation = 1u << 3, eClearUserVisibleDataItemsDescription = 1u << 4, eClearUserVisibleDataItemsSyntheticChildren = 1u << 5, - eClearUserVisibleDataItemsValidator = 1u << 6, eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | @@ -510,8 +509,6 @@ std::string &destination, const TypeSummaryOptions &options); - std::pair GetValidationStatus(); - const char *GetObjectDescription(); bool HasSpecialPrintableRepresentation( @@ -711,16 +708,6 @@ ClearUserVisibleData(eClearUserVisibleDataItemsSummary); } - lldb::TypeValidatorImplSP GetValidator() { - UpdateFormatsIfNeeded(); - return m_type_validator_sp; - } - - void SetValidator(lldb::TypeValidatorImplSP format) { - m_type_validator_sp = format; - ClearUserVisibleData(eClearUserVisibleDataItemsValidator); - } - void SetValueFormat(lldb::TypeFormatImplSP format) { m_type_format_sp = format; ClearUserVisibleData(eClearUserVisibleDataItemsValue); @@ -857,9 +844,6 @@ // differs from the summary // in that the summary is consed up by us, the object_desc_string is builtin. - llvm::Optional> - m_validation_result; - CompilerType m_override_type; // If the type of the value object should be // overridden, the type to impose. @@ -888,7 +872,6 @@ lldb::TypeSummaryImplSP m_type_summary_sp; lldb::TypeFormatImplSP m_type_format_sp; lldb::SyntheticChildrenSP m_synthetic_children_sp; - lldb::TypeValidatorImplSP m_type_validator_sp; ProcessModID m_user_id_of_forced_summary; AddressType m_address_type_of_ptr_or_ref_children; diff --git a/lldb/include/lldb/DataFormatters/DataVisualization.h b/lldb/include/lldb/DataFormatters/DataVisualization.h --- a/lldb/include/lldb/DataFormatters/DataVisualization.h +++ b/lldb/include/lldb/DataFormatters/DataVisualization.h @@ -51,12 +51,6 @@ static lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic); - static lldb::TypeValidatorImplSP - GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic); - - static lldb::TypeValidatorImplSP - GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); - static bool AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items = diff --git a/lldb/include/lldb/DataFormatters/FormatCache.h b/lldb/include/lldb/DataFormatters/FormatCache.h --- a/lldb/include/lldb/DataFormatters/FormatCache.h +++ b/lldb/include/lldb/DataFormatters/FormatCache.h @@ -24,12 +24,10 @@ bool m_format_cached : 1; bool m_summary_cached : 1; bool m_synthetic_cached : 1; - bool m_validator_cached : 1; lldb::TypeFormatImplSP m_format_sp; lldb::TypeSummaryImplSP m_summary_sp; lldb::SyntheticChildrenSP m_synthetic_sp; - lldb::TypeValidatorImplSP m_validator_sp; public: Entry(); @@ -38,17 +36,14 @@ bool IsFormatCached(); bool IsSummaryCached(); bool IsSyntheticCached(); - bool IsValidatorCached(); void Get(lldb::TypeFormatImplSP &); void Get(lldb::TypeSummaryImplSP &); void Get(lldb::SyntheticChildrenSP &); - void Get(lldb::TypeValidatorImplSP &); void Set(lldb::TypeFormatImplSP); void Set(lldb::TypeSummaryImplSP); void Set(lldb::SyntheticChildrenSP); - void Set(lldb::TypeValidatorImplSP); }; typedef std::map CacheMap; CacheMap m_map; @@ -66,7 +61,6 @@ void Set(ConstString type, lldb::TypeFormatImplSP &format_sp); void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp); void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp); - void Set(ConstString type, lldb::TypeValidatorImplSP &synthetic_sp); void Clear(); diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h --- a/lldb/include/lldb/DataFormatters/FormatClasses.h +++ b/lldb/include/lldb/DataFormatters/FormatClasses.h @@ -17,7 +17,6 @@ #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" -#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" #include "lldb/lldb-enumerations.h" @@ -40,7 +39,6 @@ typedef HardcodedFormatterFinders HardcodedFormatFinder; typedef HardcodedFormatterFinders HardcodedSummaryFinder; typedef HardcodedFormatterFinders HardcodedSyntheticFinder; - typedef HardcodedFormatterFinders HardcodedValidatorFinder; }; class FormattersMatchCandidate { diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -118,9 +118,6 @@ lldb::ScriptedSyntheticChildrenSP GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); - lldb::TypeValidatorImplSP - GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); - lldb::TypeFormatImplSP GetFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic); @@ -130,9 +127,6 @@ lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic); - lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj, - lldb::DynamicValueType use_dynamic); - bool AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items = diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -22,7 +22,6 @@ #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" -#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StringLexer.h" diff --git a/lldb/include/lldb/DataFormatters/LanguageCategory.h b/lldb/include/lldb/DataFormatters/LanguageCategory.h --- a/lldb/include/lldb/DataFormatters/LanguageCategory.h +++ b/lldb/include/lldb/DataFormatters/LanguageCategory.h @@ -47,7 +47,6 @@ HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats; HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries; HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics; - HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators; template auto &GetHardcodedFinder(); diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h --- a/lldb/include/lldb/DataFormatters/TypeCategory.h +++ b/lldb/include/lldb/DataFormatters/TypeCategory.h @@ -67,7 +67,6 @@ typedef FormatterContainerPair FormatContainer; typedef FormatterContainerPair SummaryContainer; typedef FormatterContainerPair FilterContainer; - typedef FormatterContainerPair ValidatorContainer; typedef FormatterContainerPair SynthContainer; public: @@ -86,9 +85,6 @@ typedef SynthContainer::ExactMatchContainerSP SynthContainerSP; typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP; - typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP; - typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP; - template class ForEachCallbacks { public: ForEachCallbacks() = default; @@ -145,18 +141,6 @@ m_synth_regex = callback; return *this; } - template - typename std::enable_if::value, ForEachCallbacks &>::type - SetExact(ValidatorContainer::ExactMatchForEachCallback callback) { - m_validator_exact = callback; - return *this; - } - template - typename std::enable_if::value, ForEachCallbacks &>::type - SetWithRegex(ValidatorContainer::RegexMatchForEachCallback callback) { - m_validator_regex = callback; - return *this; - } FormatContainer::ExactMatchForEachCallback GetFormatExactCallback() const { return m_format_exact; @@ -188,15 +172,6 @@ return m_synth_regex; } - ValidatorContainer::ExactMatchForEachCallback - GetValidatorExactCallback() const { - return m_validator_exact; - } - ValidatorContainer::RegexMatchForEachCallback - GetValidatorRegexCallback() const { - return m_validator_regex; - } - private: FormatContainer::ExactMatchForEachCallback m_format_exact; FormatContainer::RegexMatchForEachCallback m_format_regex; @@ -209,9 +184,6 @@ SynthContainer::ExactMatchForEachCallback m_synth_exact; SynthContainer::RegexMatchForEachCallback m_synth_regex; - - ValidatorContainer::ExactMatchForEachCallback m_validator_exact; - ValidatorContainer::RegexMatchForEachCallback m_validator_regex; }; TypeCategoryImpl(IFormatChangeListener *clist, ConstString name); @@ -229,10 +201,6 @@ GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback()); GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback()); - - GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback()); - GetRegexTypeValidatorsContainer()->ForEach( - foreach.GetValidatorRegexCallback()); } FormatContainerSP GetTypeFormatsContainer() { @@ -277,9 +245,6 @@ SynthContainer::MapValueType GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); - ValidatorContainer::MapValueType - GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); - lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForFormatAtIndex(size_t index); @@ -310,19 +275,6 @@ lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSyntheticAtIndex(size_t index); - ValidatorContainerSP GetTypeValidatorsContainer() { - return m_validator_cont.GetExactMatch(); - } - - RegexValidatorContainerSP GetRegexTypeValidatorsContainer() { - return m_validator_cont.GetRegexMatch(); - } - - ValidatorContainer::MapValueType GetValidatorAtIndex(size_t index); - - lldb::TypeNameSpecifierImplSP - GetTypeNameSpecifierForValidatorAtIndex(size_t index); - bool IsEnabled() const { return m_enabled; } uint32_t GetEnabledPosition() { @@ -341,9 +293,6 @@ bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr); - bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeValidatorImplSP &entry, uint32_t *reason = nullptr); - void Clear(FormatCategoryItems items = ALL_ITEM_TYPES); bool Delete(ConstString name, FormatCategoryItems items = ALL_ITEM_TYPES); @@ -373,7 +322,6 @@ SummaryContainer m_summary_cont; FilterContainer m_filter_cont; SynthContainer m_synth_cont; - ValidatorContainer m_validator_cont; bool m_enabled; @@ -414,9 +362,6 @@ friend class FormattersContainer; - friend class FormattersContainer; - friend class FormattersContainer; }; } // namespace lldb_private diff --git a/lldb/include/lldb/DataFormatters/TypeValidator.h b/lldb/include/lldb/DataFormatters/TypeValidator.h deleted file mode 100644 --- a/lldb/include/lldb/DataFormatters/TypeValidator.h +++ /dev/null @@ -1,201 +0,0 @@ -//===-- TypeValidator.h ------------------------------------------*- C++ -//-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_TypeValidator_h_ -#define lldb_TypeValidator_h_ - - -#include -#include - - -#include "lldb/lldb-enumerations.h" -#include "lldb/lldb-private-enumerations.h" -#include "lldb/lldb-public.h" - -namespace lldb_private { - -class TypeValidatorImpl { -public: - class Flags { - public: - Flags() : m_flags(lldb::eTypeOptionCascade) {} - - Flags(const Flags &other) : m_flags(other.m_flags) {} - - Flags(uint32_t value) : m_flags(value) {} - - Flags &operator=(const Flags &rhs) { - if (&rhs != this) - m_flags = rhs.m_flags; - - return *this; - } - - Flags &operator=(const uint32_t &rhs) { - m_flags = rhs; - return *this; - } - - Flags &Clear() { - m_flags = 0; - return *this; - } - - bool GetCascades() const { - return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade; - } - - Flags &SetCascades(bool value = true) { - if (value) - m_flags |= lldb::eTypeOptionCascade; - else - m_flags &= ~lldb::eTypeOptionCascade; - return *this; - } - - bool GetSkipPointers() const { - return (m_flags & lldb::eTypeOptionSkipPointers) == - lldb::eTypeOptionSkipPointers; - } - - Flags &SetSkipPointers(bool value = true) { - if (value) - m_flags |= lldb::eTypeOptionSkipPointers; - else - m_flags &= ~lldb::eTypeOptionSkipPointers; - return *this; - } - - bool GetSkipReferences() const { - return (m_flags & lldb::eTypeOptionSkipReferences) == - lldb::eTypeOptionSkipReferences; - } - - Flags &SetSkipReferences(bool value = true) { - if (value) - m_flags |= lldb::eTypeOptionSkipReferences; - else - m_flags &= ~lldb::eTypeOptionSkipReferences; - return *this; - } - - bool GetNonCacheable() const { - return (m_flags & lldb::eTypeOptionNonCacheable) == - lldb::eTypeOptionNonCacheable; - } - - Flags &SetNonCacheable(bool value = true) { - if (value) - m_flags |= lldb::eTypeOptionNonCacheable; - else - m_flags &= ~lldb::eTypeOptionNonCacheable; - return *this; - } - - uint32_t GetValue() { return m_flags; } - - void SetValue(uint32_t value) { m_flags = value; } - - private: - uint32_t m_flags; - }; - - TypeValidatorImpl(const Flags &flags = Flags()); - - typedef std::shared_ptr SharedPointer; - - virtual ~TypeValidatorImpl(); - - bool Cascades() const { return m_flags.GetCascades(); } - bool SkipsPointers() const { return m_flags.GetSkipPointers(); } - bool SkipsReferences() const { return m_flags.GetSkipReferences(); } - bool NonCacheable() const { return m_flags.GetNonCacheable(); } - - void SetCascades(bool value) { m_flags.SetCascades(value); } - - void SetSkipsPointers(bool value) { m_flags.SetSkipPointers(value); } - - void SetSkipsReferences(bool value) { m_flags.SetSkipReferences(value); } - - void SetNonCacheable(bool value) { m_flags.SetNonCacheable(value); } - - uint32_t GetOptions() { return m_flags.GetValue(); } - - void SetOptions(uint32_t value) { m_flags.SetValue(value); } - - uint32_t &GetRevision() { return m_my_revision; } - - enum class Type { eTypeUnknown, eTypeCXX }; - - struct ValidationResult { - TypeValidatorResult m_result; - std::string m_message; - }; - - virtual Type GetType() { return Type::eTypeUnknown; } - - // we are using a ValueObject* instead of a ValueObjectSP because we do not - // need to hold on to this for extended periods of time and we trust the - // ValueObject to stay around for as long as it is required for us to - // generate its value - virtual ValidationResult FormatObject(ValueObject *valobj) const = 0; - - virtual std::string GetDescription() = 0; - - static ValidationResult Success(); - - static ValidationResult Failure(std::string message); - -protected: - Flags m_flags; - uint32_t m_my_revision; - -private: - DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl); -}; - -class TypeValidatorImpl_CXX : public TypeValidatorImpl { -public: - typedef std::function - ValidatorFunction; - - TypeValidatorImpl_CXX(ValidatorFunction f, std::string d, - const TypeValidatorImpl::Flags &flags = Flags()); - - typedef std::shared_ptr SharedPointer; - - ~TypeValidatorImpl_CXX() override; - - ValidatorFunction GetValidatorFunction() const { - return m_validator_function; - } - - void SetValidatorFunction(ValidatorFunction f) { m_validator_function = f; } - - TypeValidatorImpl::Type GetType() override { - return TypeValidatorImpl::Type::eTypeCXX; - } - - ValidationResult FormatObject(ValueObject *valobj) const override; - - std::string GetDescription() override; - -protected: - std::string m_description; - ValidatorFunction m_validator_function; - -private: - DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl_CXX); -}; - -} // namespace lldb_private - -#endif // lldb_TypeValidator_h_ diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h --- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -62,8 +62,6 @@ bool ShouldPrintValueObject(); - bool ShouldPrintValidation(); - bool IsNil(); bool IsUninitialized(); @@ -76,10 +74,6 @@ bool IsAggregate(); - bool PrintValidationMarkerIfNeeded(); - - bool PrintValidationErrorIfNeeded(); - bool PrintLocationIfNeeded(); void PrintDecl(); @@ -145,7 +139,6 @@ std::string m_summary; std::string m_error; bool m_val_summary_ok; - std::pair m_validation; friend struct StringSummaryFormat; diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -176,9 +176,6 @@ virtual HardcodedFormatters::HardcodedSyntheticFinder GetHardcodedSynthetics(); - virtual HardcodedFormatters::HardcodedValidatorFinder - GetHardcodedValidators(); - virtual std::vector GetPossibleFormattersMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic); diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -260,7 +260,6 @@ class TypeEnumMemberListImpl; class TypeFormatImpl; class TypeNameSpecifierImpl; -class TypeValidatorImpl; class UUID; class UnixSignals; class Unwind; @@ -461,7 +460,6 @@ TypeNameSpecifierImplSP; typedef std::shared_ptr TypeSummaryImplSP; typedef std::shared_ptr TypeSummaryOptionsSP; -typedef std::shared_ptr TypeValidatorImplSP; typedef std::shared_ptr ScriptedSyntheticChildrenSP; typedef std::shared_ptr UnixSignalsSP; diff --git a/lldb/scripts/interface/SBValue.i b/lldb/scripts/interface/SBValue.i --- a/lldb/scripts/interface/SBValue.i +++ b/lldb/scripts/interface/SBValue.i @@ -129,9 +129,6 @@ const char * GetObjectDescription (); - const char * - GetTypeValidatorResult (); - lldb::SBValue GetDynamicValue (lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -391,25 +391,6 @@ return cstr; } -const char *SBValue::GetTypeValidatorResult() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeValidatorResult); - - const char *cstr = nullptr; - ValueLocker locker; - lldb::ValueObjectSP value_sp(GetSP(locker)); - if (value_sp) { - const auto &validation(value_sp->GetValidationStatus()); - if (TypeValidatorResult::Failure == validation.first) { - if (validation.second.empty()) - cstr = "unknown error"; - else - cstr = validation.second.c_str(); - } - } - - return cstr; -} - SBType SBValue::GetType() { LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType); @@ -1585,7 +1566,6 @@ LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ()); LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ()); LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeValidatorResult, ()); LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ()); LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ()); LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ()); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -22,7 +22,6 @@ #include "lldb/DataFormatters/StringPrinter.h" #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" -#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Expression/ExpressionVariable.h" #include "lldb/Host/Config.h" @@ -83,13 +82,12 @@ m_parent(&parent), m_root(nullptr), m_update_point(parent.GetUpdatePoint()), m_name(), m_data(), m_value(), m_error(), m_value_str(), m_old_value_str(), m_location_str(), - m_summary_str(), m_object_desc_str(), m_validation_result(), - m_manager(parent.GetManager()), m_children(), m_synthetic_children(), - m_dynamic_value(nullptr), m_synthetic_value(nullptr), - m_deref_valobj(nullptr), m_format(eFormatDefault), - m_last_format(eFormatDefault), m_last_format_mgr_revision(0), - m_type_summary_sp(), m_type_format_sp(), m_synthetic_children_sp(), - m_type_validator_sp(), m_user_id_of_forced_summary(), + m_summary_str(), m_object_desc_str(), m_manager(parent.GetManager()), + m_children(), m_synthetic_children(), m_dynamic_value(nullptr), + m_synthetic_value(nullptr), m_deref_valobj(nullptr), + m_format(eFormatDefault), m_last_format(eFormatDefault), + m_last_format_mgr_revision(0), m_type_summary_sp(), m_type_format_sp(), + m_synthetic_children_sp(), m_user_id_of_forced_summary(), m_address_type_of_ptr_or_ref_children(eAddressTypeInvalid), m_value_checksum(), m_preferred_display_language(lldb::eLanguageTypeUnknown), @@ -113,12 +111,12 @@ m_parent(nullptr), m_root(nullptr), m_update_point(exe_scope), m_name(), m_data(), m_value(), m_error(), m_value_str(), m_old_value_str(), m_location_str(), m_summary_str(), m_object_desc_str(), - m_validation_result(), m_manager(), m_children(), m_synthetic_children(), + m_manager(), m_children(), m_synthetic_children(), m_dynamic_value(nullptr), m_synthetic_value(nullptr), m_deref_valobj(nullptr), m_format(eFormatDefault), m_last_format(eFormatDefault), m_last_format_mgr_revision(0), m_type_summary_sp(), m_type_format_sp(), m_synthetic_children_sp(), - m_type_validator_sp(), m_user_id_of_forced_summary(), + m_user_id_of_forced_summary(), m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type), m_value_checksum(), m_preferred_display_language(lldb::eLanguageTypeUnknown), @@ -309,7 +307,6 @@ SetSyntheticChildren( DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType())); #endif - SetValidator(DataVisualization::GetValidator(*this, GetDynamicValueType())); } return any_change; @@ -1105,23 +1102,6 @@ return {total_bytes_read, was_capped}; } -std::pair ValueObject::GetValidationStatus() { - if (!UpdateValueIfNeeded(true)) - return {TypeValidatorResult::Success, - ""}; // not the validator's job to discuss update problems - - if (m_validation_result.hasValue()) - return m_validation_result.getValue(); - - if (!m_type_validator_sp) - return {TypeValidatorResult::Success, ""}; // no validator no failure - - auto outcome = m_type_validator_sp->FormatObject(this); - - return (m_validation_result = {outcome.m_result, outcome.m_message}) - .getValue(); -} - const char *ValueObject::GetObjectDescription() { if (!UpdateValueIfNeeded(true)) return nullptr; @@ -3130,10 +3110,6 @@ if (m_synthetic_value) m_synthetic_value = nullptr; } - - if ((clear_mask & eClearUserVisibleDataItemsValidator) == - eClearUserVisibleDataItemsValidator) - m_validation_result.reset(); } SymbolContextScope *ValueObject::GetSymbolContextScope() { diff --git a/lldb/source/DataFormatters/CMakeLists.txt b/lldb/source/DataFormatters/CMakeLists.txt --- a/lldb/source/DataFormatters/CMakeLists.txt +++ b/lldb/source/DataFormatters/CMakeLists.txt @@ -13,7 +13,6 @@ TypeFormat.cpp TypeSummary.cpp TypeSynthetic.cpp - TypeValidator.cpp ValueObjectPrinter.cpp VectorType.cpp diff --git a/lldb/source/DataFormatters/DataVisualization.cpp b/lldb/source/DataFormatters/DataVisualization.cpp --- a/lldb/source/DataFormatters/DataVisualization.cpp +++ b/lldb/source/DataFormatters/DataVisualization.cpp @@ -66,17 +66,6 @@ return GetFormatManager().GetSyntheticForType(type_sp); } -lldb::TypeValidatorImplSP -DataVisualization::GetValidator(ValueObject &valobj, - lldb::DynamicValueType use_dynamic) { - return GetFormatManager().GetValidator(valobj, use_dynamic); -} - -lldb::TypeValidatorImplSP -DataVisualization::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) { - return GetFormatManager().GetValidatorForType(type_sp); -} - bool DataVisualization::AnyMatches( ConstString type_name, TypeCategoryImpl::FormatCategoryItems items, bool only_enabled, const char **matching_category, diff --git a/lldb/source/DataFormatters/FormatCache.cpp b/lldb/source/DataFormatters/FormatCache.cpp --- a/lldb/source/DataFormatters/FormatCache.cpp +++ b/lldb/source/DataFormatters/FormatCache.cpp @@ -17,7 +17,7 @@ FormatCache::Entry::Entry() : m_format_cached(false), m_summary_cached(false), - m_synthetic_cached(false), m_validator_cached(false) {} + m_synthetic_cached(false) {} bool FormatCache::Entry::IsFormatCached() { return m_format_cached; } @@ -25,8 +25,6 @@ bool FormatCache::Entry::IsSyntheticCached() { return m_synthetic_cached; } -bool FormatCache::Entry::IsValidatorCached() { return m_validator_cached; } - void FormatCache::Entry::Get(lldb::TypeFormatImplSP &retval) { retval = m_format_sp; } @@ -39,10 +37,6 @@ retval = m_synthetic_sp; } -void FormatCache::Entry::Get(lldb::TypeValidatorImplSP &retval) { - retval = m_validator_sp; -} - void FormatCache::Entry::Set(lldb::TypeFormatImplSP format_sp) { m_format_cached = true; m_format_sp = format_sp; @@ -58,11 +52,6 @@ m_synthetic_sp = synthetic_sp; } -void FormatCache::Entry::Set(lldb::TypeValidatorImplSP validator_sp) { - m_validator_cached = true; - m_validator_sp = validator_sp; -} - FormatCache::FormatCache() : m_map(), m_mutex() #ifdef LLDB_CONFIGURATION_DEBUG @@ -89,9 +78,6 @@ template<> bool FormatCache::Entry::IsCached() { return IsSyntheticCached(); } -template<> bool FormatCache::Entry::IsCached() { - return IsValidatorCached(); -} template bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) { @@ -111,12 +97,9 @@ return false; } -/// Explicit instantiations for the four types. +/// Explicit instantiations for the three types. /// \{ template bool -FormatCache::Get(ConstString, - lldb::TypeValidatorImplSP &); -template bool FormatCache::Get(ConstString, lldb::TypeFormatImplSP &); template bool FormatCache::Get(ConstString, @@ -142,12 +125,6 @@ GetEntry(type).Set(synthetic_sp); } -void FormatCache::Set(ConstString type, - lldb::TypeValidatorImplSP &validator_sp) { - std::lock_guard guard(m_mutex); - GetEntry(type).Set(validator_sp); -} - void FormatCache::Clear() { std::lock_guard guard(m_mutex); m_map.clear(); diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -386,30 +386,6 @@ return synth_chosen_sp; } -lldb::TypeValidatorImplSP -FormatManager::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) { - if (!type_sp) - return lldb::TypeValidatorImplSP(); - lldb::TypeValidatorImplSP validator_chosen_sp; - uint32_t num_categories = m_categories_map.GetCount(); - lldb::TypeCategoryImplSP category_sp; - uint32_t prio_category = UINT32_MAX; - for (uint32_t category_id = 0; category_id < num_categories; category_id++) { - category_sp = GetCategoryAtIndex(category_id); - if (!category_sp->IsEnabled()) - continue; - lldb::TypeValidatorImplSP validator_current_sp( - category_sp->GetValidatorForType(type_sp).get()); - if (validator_current_sp && - (validator_chosen_sp.get() == nullptr || - (prio_category > category_sp->GetEnabledPosition()))) { - prio_category = category_sp->GetEnabledPosition(); - validator_chosen_sp = validator_current_sp; - } - } - return validator_chosen_sp; -} - void FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) { m_categories_map.ForEach(callback); std::lock_guard guard(m_language_categories_mutex); @@ -699,12 +675,6 @@ return Get(valobj, use_dynamic); } -lldb::TypeValidatorImplSP -FormatManager::GetValidator(ValueObject &valobj, - lldb::DynamicValueType use_dynamic) { - return Get(valobj, use_dynamic); -} - FormatManager::FormatManager() : m_last_revision(0), m_format_cache(), m_language_categories_mutex(), m_language_categories_map(), m_named_summaries_map(this), diff --git a/lldb/source/DataFormatters/LanguageCategory.cpp b/lldb/source/DataFormatters/LanguageCategory.cpp --- a/lldb/source/DataFormatters/LanguageCategory.cpp +++ b/lldb/source/DataFormatters/LanguageCategory.cpp @@ -14,7 +14,6 @@ #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" -#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/Target/Language.h" using namespace lldb; @@ -22,14 +21,12 @@ LanguageCategory::LanguageCategory(lldb::LanguageType lang_type) : m_category_sp(), m_hardcoded_formats(), m_hardcoded_summaries(), - m_hardcoded_synthetics(), m_hardcoded_validators(), m_format_cache(), - m_enabled(false) { + m_hardcoded_synthetics(), m_format_cache(), m_enabled(false) { if (Language *language_plugin = Language::FindPlugin(lang_type)) { m_category_sp = language_plugin->GetFormatters(); m_hardcoded_formats = language_plugin->GetHardcodedFormats(); m_hardcoded_summaries = language_plugin->GetHardcodedSummaries(); m_hardcoded_synthetics = language_plugin->GetHardcodedSynthetics(); - m_hardcoded_validators = language_plugin->GetHardcodedValidators(); } Enable(); } @@ -58,12 +55,9 @@ return result; } -/// Explicit instantiations for the four types. +/// Explicit instantiations for the three types. /// \{ template bool -LanguageCategory::Get(FormattersMatchData &, - lldb::TypeValidatorImplSP &); -template bool LanguageCategory::Get(FormattersMatchData &, lldb::TypeFormatImplSP &); template bool @@ -89,11 +83,6 @@ return m_hardcoded_synthetics; } -template <> -auto &LanguageCategory::GetHardcodedFinder() { - return m_hardcoded_validators; -} - template bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data, @@ -113,10 +102,8 @@ return (bool)retval_sp; } -/// Explicit instantiations for the four types. +/// Explicit instantiations for the three types. /// \{ -template bool LanguageCategory::GetHardcoded( - FormatManager &, FormattersMatchData &, lldb::TypeValidatorImplSP &); template bool LanguageCategory::GetHardcoded( FormatManager &, FormattersMatchData &, lldb::TypeFormatImplSP &); template bool LanguageCategory::GetHardcoded( diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp --- a/lldb/source/DataFormatters/TypeCategory.cpp +++ b/lldb/source/DataFormatters/TypeCategory.cpp @@ -19,7 +19,6 @@ m_summary_cont("summary", "regex-summary", clist), m_filter_cont("filter", "regex-filter", clist), m_synth_cont("synth", "regex-synth", clist), - m_validator_cont("validator", "regex-validator", clist), m_enabled(false), m_change_listener(clist), m_mutex(), m_name(name), m_languages() {} static bool IsApplicable(lldb::LanguageType category_lang, @@ -158,20 +157,6 @@ return false; } -bool TypeCategoryImpl::Get(lldb::LanguageType lang, - const FormattersMatchVector &candidates, - lldb::TypeValidatorImplSP &entry, uint32_t *reason) { - if (!IsEnabled()) - return false; - if (GetTypeValidatorsContainer()->Get(candidates, entry, reason)) - return true; - bool regex = - GetRegexTypeValidatorsContainer()->Get(candidates, entry, reason); - if (regex && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary; - return regex; -} - void TypeCategoryImpl::Clear(FormatCategoryItems items) { if ((items & eFormatCategoryItemValue) == eFormatCategoryItemValue) GetTypeFormatsContainer()->Clear(); @@ -194,12 +179,6 @@ GetTypeSyntheticsContainer()->Clear(); if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth) GetRegexTypeSyntheticsContainer()->Clear(); - - if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator) - GetTypeValidatorsContainer()->Clear(); - if ((items & eFormatCategoryItemRegexValidator) == - eFormatCategoryItemRegexValidator) - GetRegexTypeValidatorsContainer()->Clear(); } bool TypeCategoryImpl::Delete(ConstString name, FormatCategoryItems items) { @@ -227,12 +206,6 @@ if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth) success = GetRegexTypeSyntheticsContainer()->Delete(name) || success; - if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator) - success = GetTypeValidatorsContainer()->Delete(name) || success; - if ((items & eFormatCategoryItemRegexValidator) == - eFormatCategoryItemRegexValidator) - success = GetRegexTypeValidatorsContainer()->Delete(name) || success; - return success; } @@ -261,12 +234,6 @@ if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth) count += GetRegexTypeSyntheticsContainer()->GetCount(); - if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator) - count += GetTypeValidatorsContainer()->GetCount(); - if ((items & eFormatCategoryItemRegexValidator) == - eFormatCategoryItemRegexValidator) - count += GetRegexTypeValidatorsContainer()->GetCount(); - return count; } @@ -281,7 +248,6 @@ lldb::TypeSummaryImplSP summary_sp; TypeFilterImpl::SharedPointer filter_sp; ScriptedSyntheticChildren::SharedPointer synth_sp; - TypeValidatorImpl::SharedPointer validator_sp; if ((items & eFormatCategoryItemValue) == eFormatCategoryItemValue) { if (GetTypeFormatsContainer()->Get(type_name, format_sp)) { @@ -363,26 +329,6 @@ } } - if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator) { - if (GetTypeValidatorsContainer()->Get(type_name, validator_sp)) { - if (matching_category) - *matching_category = m_name.GetCString(); - if (matching_type) - *matching_type = eFormatCategoryItemValidator; - return true; - } - } - if ((items & eFormatCategoryItemRegexValidator) == - eFormatCategoryItemRegexValidator) { - if (GetRegexTypeValidatorsContainer()->Get(type_name, validator_sp)) { - if (matching_category) - *matching_category = m_name.GetCString(); - if (matching_type) - *matching_type = eFormatCategoryItemRegexValidator; - return true; - } - } - return false; } @@ -450,22 +396,6 @@ return retval; } -TypeCategoryImpl::ValidatorContainer::MapValueType -TypeCategoryImpl::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) { - ValidatorContainer::MapValueType retval; - - if (type_sp) { - if (type_sp->IsRegex()) - GetRegexTypeValidatorsContainer()->GetExact( - ConstString(type_sp->GetName()), retval); - else - GetTypeValidatorsContainer()->GetExact(ConstString(type_sp->GetName()), - retval); - } - - return retval; -} - lldb::TypeNameSpecifierImplSP TypeCategoryImpl::GetTypeNameSpecifierForSummaryAtIndex(size_t index) { if (index < GetTypeSummariesContainer()->GetCount()) @@ -538,24 +468,6 @@ index - GetTypeSyntheticsContainer()->GetCount()); } -TypeCategoryImpl::ValidatorContainer::MapValueType -TypeCategoryImpl::GetValidatorAtIndex(size_t index) { - if (index < GetTypeValidatorsContainer()->GetCount()) - return GetTypeValidatorsContainer()->GetAtIndex(index); - else - return GetRegexTypeValidatorsContainer()->GetAtIndex( - index - GetTypeValidatorsContainer()->GetCount()); -} - -lldb::TypeNameSpecifierImplSP -TypeCategoryImpl::GetTypeNameSpecifierForValidatorAtIndex(size_t index) { - if (index < GetTypeValidatorsContainer()->GetCount()) - return GetTypeValidatorsContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeValidatorsContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeValidatorsContainer()->GetCount()); -} - void TypeCategoryImpl::Enable(bool value, uint32_t position) { std::lock_guard guard(m_mutex); if ((m_enabled = value)) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -208,11 +208,8 @@ LLDB_LOGF(log, "[%s] nothing found - returning empty SP", __FUNCTION__); } -/// Explicit instantiations for the four types. +/// Explicit instantiations for the three types. /// \{ -template void TypeCategoryMap::Get( - FormattersMatchData &match_data, lldb::TypeValidatorImplSP &retval); - template void TypeCategoryMap::Get(FormattersMatchData &match_data, lldb::TypeFormatImplSP &retval); diff --git a/lldb/source/DataFormatters/TypeValidator.cpp b/lldb/source/DataFormatters/TypeValidator.cpp deleted file mode 100644 --- a/lldb/source/DataFormatters/TypeValidator.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - - - - -#include "lldb/DataFormatters/TypeValidator.h" -#include "lldb/Utility/StreamString.h" - -using namespace lldb; -using namespace lldb_private; - -TypeValidatorImpl::TypeValidatorImpl(const Flags &flags) - : m_flags(flags), m_my_revision(0) {} - -TypeValidatorImpl::~TypeValidatorImpl() {} - -TypeValidatorImpl::ValidationResult TypeValidatorImpl::Success() { - return ValidationResult{TypeValidatorResult::Success, ""}; -} - -TypeValidatorImpl::ValidationResult -TypeValidatorImpl::Failure(std::string message) { - return ValidationResult{TypeValidatorResult::Failure, message}; -} - -TypeValidatorImpl_CXX::TypeValidatorImpl_CXX( - ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags &flags) - : TypeValidatorImpl(flags), m_description(d), m_validator_function(f) {} - -TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX() {} - -TypeValidatorImpl::ValidationResult -TypeValidatorImpl_CXX::FormatObject(ValueObject *valobj) const { - if (!valobj) - return Success(); // I guess there's nothing wrong with a null valueobject.. - - return m_validator_function(valobj); -} - -std::string TypeValidatorImpl_CXX::GetDescription() { - StreamString sstr; - sstr.Printf("%s%s%s%s", m_description.c_str(), - Cascades() ? "" : " (not cascading)", - SkipsPointers() ? " (skip pointers)" : "", - SkipsReferences() ? " (skip references)" : ""); - return sstr.GetString(); -} diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -75,8 +75,6 @@ return false; if (ShouldPrintValueObject()) { - PrintValidationMarkerIfNeeded(); - PrintLocationIfNeeded(); m_stream->Indent(); @@ -94,8 +92,6 @@ else m_stream->EOL(); - PrintValidationErrorIfNeeded(); - return true; } @@ -790,37 +786,3 @@ } else m_stream->EOL(); } - -bool ValueObjectPrinter::ShouldPrintValidation() { - return m_options.m_run_validator; -} - -bool ValueObjectPrinter::PrintValidationMarkerIfNeeded() { - if (!ShouldPrintValidation()) - return false; - - m_validation = m_valobj->GetValidationStatus(); - - if (TypeValidatorResult::Failure == m_validation.first) { - m_stream->Printf("! "); - return true; - } - - return false; -} - -bool ValueObjectPrinter::PrintValidationErrorIfNeeded() { - if (!ShouldPrintValidation()) - return false; - - if (TypeValidatorResult::Success == m_validation.first) - return false; - - if (m_validation.second.empty()) - m_validation.second.assign("unknown error"); - - m_stream->Printf(" ! validation error: %s", m_validation.second.c_str()); - m_stream->EOL(); - - return true; -} diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp --- a/lldb/source/Target/Language.cpp +++ b/lldb/source/Target/Language.cpp @@ -134,11 +134,6 @@ return {}; } -HardcodedFormatters::HardcodedValidatorFinder -Language::GetHardcodedValidators() { - return {}; -} - std::vector Language::GetPossibleFormattersMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) {