Remove TypeValidators (NFC in terms of the testsuite)

This is a half-implemented feature that as far as we can tell was
never used by anything since its original inclusion in 2014. This
patch removes it to make remaining the code easier to understand.

Differential Revision: https://reviews.llvm.org/D71310
This commit is contained in:
Adrian Prantl
2019-12-10 15:32:57 -08:00
parent 5a3a9e9927
commit ee64dfd953
26 changed files with 14 additions and 635 deletions

View File

@@ -75,8 +75,6 @@ public:
const char *GetObjectDescription();
const char *GetTypeValidatorResult();
lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic);
lldb::SBValue GetStaticValue();

View File

@@ -179,7 +179,6 @@ public:
eClearUserVisibleDataItemsLocation = 1u << 3,
eClearUserVisibleDataItemsDescription = 1u << 4,
eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
eClearUserVisibleDataItemsValidator = 1u << 6,
eClearUserVisibleDataItemsAllStrings =
eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary |
eClearUserVisibleDataItemsLocation |
@@ -510,8 +509,6 @@ public:
std::string &destination,
const TypeSummaryOptions &options);
std::pair<TypeValidatorResult, std::string> GetValidationStatus();
const char *GetObjectDescription();
bool HasSpecialPrintableRepresentation(
@@ -711,16 +708,6 @@ public:
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 @@ protected:
// differs from the summary
// in that the summary is consed up by us, the object_desc_string is builtin.
llvm::Optional<std::pair<TypeValidatorResult, std::string>>
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 @@ protected:
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;

View File

@@ -51,12 +51,6 @@ public:
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 =

View File

@@ -24,12 +24,10 @@ private:
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 @@ private:
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<ConstString, Entry> CacheMap;
CacheMap m_map;
@@ -66,7 +61,6 @@ public:
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();

View File

@@ -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 @@ public:
typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
};
class FormattersMatchCandidate {

View File

@@ -118,9 +118,6 @@ public:
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 @@ public:
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 =

View File

@@ -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"

View File

@@ -47,7 +47,6 @@ private:
HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
template <typename ImplSP>
auto &GetHardcodedFinder();

View File

@@ -67,7 +67,6 @@ private:
typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
public:
@@ -86,9 +85,6 @@ public:
typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
template <typename T> class ForEachCallbacks {
public:
ForEachCallbacks() = default;
@@ -145,18 +141,6 @@ public:
m_synth_regex = callback;
return *this;
}
template <typename U = TypeValidatorImpl>
typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
SetExact(ValidatorContainer::ExactMatchForEachCallback callback) {
m_validator_exact = callback;
return *this;
}
template <typename U = TypeValidatorImpl>
typename std::enable_if<std::is_same<U, T>::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 @@ public:
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 @@ public:
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 @@ public:
GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
GetRegexTypeValidatorsContainer()->ForEach(
foreach.GetValidatorRegexCallback());
}
FormatContainerSP GetTypeFormatsContainer() {
@@ -277,9 +245,6 @@ public:
SynthContainer::MapValueType
GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
ValidatorContainer::MapValueType
GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForFormatAtIndex(size_t index);
@@ -310,19 +275,6 @@ public:
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 @@ public:
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 @@ private:
SummaryContainer m_summary_cont;
FilterContainer m_filter_cont;
SynthContainer m_synth_cont;
ValidatorContainer m_validator_cont;
bool m_enabled;
@@ -414,9 +362,6 @@ private:
friend class FormattersContainer<lldb::RegularExpressionSP,
ScriptedSyntheticChildren>;
friend class FormattersContainer<ConstString, TypeValidatorImpl>;
friend class FormattersContainer<lldb::RegularExpressionSP,
TypeValidatorImpl>;
};
} // namespace lldb_private

View File

@@ -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 <functional>
#include <string>
#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<TypeValidatorImpl> 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<TypeValidatorImpl::ValidationResult(
ValueObject *valobj)>
ValidatorFunction;
TypeValidatorImpl_CXX(ValidatorFunction f, std::string d,
const TypeValidatorImpl::Flags &flags = Flags());
typedef std::shared_ptr<TypeValidatorImpl_CXX> 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_

View File

@@ -62,8 +62,6 @@ protected:
bool ShouldPrintValueObject();
bool ShouldPrintValidation();
bool IsNil();
bool IsUninitialized();
@@ -76,10 +74,6 @@ protected:
bool IsAggregate();
bool PrintValidationMarkerIfNeeded();
bool PrintValidationErrorIfNeeded();
bool PrintLocationIfNeeded();
void PrintDecl();
@@ -145,7 +139,6 @@ private:
std::string m_summary;
std::string m_error;
bool m_val_summary_ok;
std::pair<TypeValidatorResult, std::string> m_validation;
friend struct StringSummaryFormat;

View File

@@ -176,9 +176,6 @@ public:
virtual HardcodedFormatters::HardcodedSyntheticFinder
GetHardcodedSynthetics();
virtual HardcodedFormatters::HardcodedValidatorFinder
GetHardcodedValidators();
virtual std::vector<ConstString>
GetPossibleFormattersMatches(ValueObject &valobj,
lldb::DynamicValueType use_dynamic);

View File

@@ -260,7 +260,6 @@ class TypeEnumMemberImpl;
class TypeEnumMemberListImpl;
class TypeFormatImpl;
class TypeNameSpecifierImpl;
class TypeValidatorImpl;
class UUID;
class UnixSignals;
class Unwind;
@@ -461,7 +460,6 @@ typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl>
TypeNameSpecifierImplSP;
typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP;
typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP;
typedef std::shared_ptr<lldb_private::TypeValidatorImpl> TypeValidatorImplSP;
typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren>
ScriptedSyntheticChildrenSP;
typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP;

View File

@@ -129,9 +129,6 @@ public:
const char *
GetObjectDescription ();
const char *
GetTypeValidatorResult ();
lldb::SBValue
GetDynamicValue (lldb::DynamicValueType use_dynamic);

View File

@@ -391,25 +391,6 @@ const char *SBValue::GetObjectDescription() {
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 @@ void RegisterMethods<SBValue>(Registry &R) {
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, ());

View File

@@ -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 @@ ValueObject::ValueObject(ValueObject &parent)
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 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
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 @@ bool ValueObject::UpdateFormatsIfNeeded() {
SetSyntheticChildren(
DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
#endif
SetValidator(DataVisualization::GetValidator(*this, GetDynamicValueType()));
}
return any_change;
@@ -1105,23 +1102,6 @@ ValueObject::ReadPointedString(lldb::DataBufferSP &buffer_sp, Status &error,
return {total_bytes_read, was_capped};
}
std::pair<TypeValidatorResult, std::string> 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 @@ void ValueObject::ClearUserVisibleData(uint32_t clear_mask) {
if (m_synthetic_value)
m_synthetic_value = nullptr;
}
if ((clear_mask & eClearUserVisibleDataItemsValidator) ==
eClearUserVisibleDataItemsValidator)
m_validation_result.reset();
}
SymbolContextScope *ValueObject::GetSymbolContextScope() {

View File

@@ -13,7 +13,6 @@ add_lldb_library(lldbDataFormatters
TypeFormat.cpp
TypeSummary.cpp
TypeSynthetic.cpp
TypeValidator.cpp
ValueObjectPrinter.cpp
VectorType.cpp

View File

@@ -66,17 +66,6 @@ DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
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,

View File

@@ -17,7 +17,7 @@ using namespace lldb_private;
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::IsSummaryCached() { return m_summary_cached; }
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 @@ void FormatCache::Entry::Get(lldb::SyntheticChildrenSP &retval) {
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 @@ void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
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<lldb::TypeSummaryImplSP> () {
template<> bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>() {
return IsSyntheticCached();
}
template<> bool FormatCache::Entry::IsCached<lldb::TypeValidatorImplSP>() {
return IsValidatorCached();
}
template <typename ImplSP>
bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
@@ -111,12 +97,9 @@ bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
return false;
}
/// Explicit instantiations for the four types.
/// Explicit instantiations for the three types.
/// \{
template bool
FormatCache::Get<lldb::TypeValidatorImplSP>(ConstString,
lldb::TypeValidatorImplSP &);
template bool
FormatCache::Get<lldb::TypeFormatImplSP>(ConstString, lldb::TypeFormatImplSP &);
template bool
FormatCache::Get<lldb::TypeSummaryImplSP>(ConstString,
@@ -142,12 +125,6 @@ void FormatCache::Set(ConstString type,
GetEntry(type).Set(synthetic_sp);
}
void FormatCache::Set(ConstString type,
lldb::TypeValidatorImplSP &validator_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).Set(validator_sp);
}
void FormatCache::Clear() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_map.clear();

View File

@@ -386,30 +386,6 @@ FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
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<std::recursive_mutex> guard(m_language_categories_mutex);
@@ -699,12 +675,6 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
return Get<lldb::SyntheticChildrenSP>(valobj, use_dynamic);
}
lldb::TypeValidatorImplSP
FormatManager::GetValidator(ValueObject &valobj,
lldb::DynamicValueType use_dynamic) {
return Get<lldb::TypeValidatorImplSP>(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),

View File

@@ -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 @@ using namespace lldb_private;
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 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
return result;
}
/// Explicit instantiations for the four types.
/// Explicit instantiations for the three types.
/// \{
template bool
LanguageCategory::Get<lldb::TypeValidatorImplSP>(FormattersMatchData &,
lldb::TypeValidatorImplSP &);
template bool
LanguageCategory::Get<lldb::TypeFormatImplSP>(FormattersMatchData &,
lldb::TypeFormatImplSP &);
template bool
@@ -89,11 +83,6 @@ auto &LanguageCategory::GetHardcodedFinder<lldb::SyntheticChildrenSP>() {
return m_hardcoded_synthetics;
}
template <>
auto &LanguageCategory::GetHardcodedFinder<lldb::TypeValidatorImplSP>() {
return m_hardcoded_validators;
}
template <typename ImplSP>
bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
FormattersMatchData &match_data,
@@ -113,10 +102,8 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
return (bool)retval_sp;
}
/// Explicit instantiations for the four types.
/// Explicit instantiations for the three types.
/// \{
template bool LanguageCategory::GetHardcoded<lldb::TypeValidatorImplSP>(
FormatManager &, FormattersMatchData &, lldb::TypeValidatorImplSP &);
template bool LanguageCategory::GetHardcoded<lldb::TypeFormatImplSP>(
FormatManager &, FormattersMatchData &, lldb::TypeFormatImplSP &);
template bool LanguageCategory::GetHardcoded<lldb::TypeSummaryImplSP>(

View File

@@ -19,7 +19,6 @@ TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist,
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 @@ bool TypeCategoryImpl::Get(lldb::LanguageType lang,
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 @@ void TypeCategoryImpl::Clear(FormatCategoryItems items) {
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 @@ bool TypeCategoryImpl::Delete(ConstString name, FormatCategoryItems items) {
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 @@ uint32_t TypeCategoryImpl::GetCount(FormatCategoryItems items) {
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 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
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 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
}
}
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 @@ TypeCategoryImpl::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
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 @@ TypeCategoryImpl::GetTypeNameSpecifierForSyntheticAtIndex(size_t index) {
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<std::recursive_mutex> guard(m_mutex);
if ((m_enabled = value))

View File

@@ -208,11 +208,8 @@ void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
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<lldb::TypeValidatorImplSP>(
FormattersMatchData &match_data, lldb::TypeValidatorImplSP &retval);
template void
TypeCategoryMap::Get<lldb::TypeFormatImplSP>(FormattersMatchData &match_data,
lldb::TypeFormatImplSP &retval);

View File

@@ -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();
}

View File

@@ -75,8 +75,6 @@ bool ValueObjectPrinter::PrintValueObject() {
return false;
if (ShouldPrintValueObject()) {
PrintValidationMarkerIfNeeded();
PrintLocationIfNeeded();
m_stream->Indent();
@@ -94,8 +92,6 @@ bool ValueObjectPrinter::PrintValueObject() {
else
m_stream->EOL();
PrintValidationErrorIfNeeded();
return true;
}
@@ -790,37 +786,3 @@ void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
} 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;
}

View File

@@ -134,11 +134,6 @@ Language::GetHardcodedSynthetics() {
return {};
}
HardcodedFormatters::HardcodedValidatorFinder
Language::GetHardcodedValidators() {
return {};
}
std::vector<ConstString>
Language::GetPossibleFormattersMatches(ValueObject &valobj,
lldb::DynamicValueType use_dynamic) {