aprantl created this revision.
aprantl added reviewers: jingham, jasonmolenda.
Herald added a subscriber: mgorny.

Data formatter Validators are completely wired up all the way to the SBAPI, but 
as far as I can tell they are not used anywhere (including swift-lldb) and also 
are not tested. I'm puzzled by this, so if anyone can share some info about 
what this was intended for, please let me know.

This patch deletes them as dead code.


https://reviews.llvm.org/D71310

Files:
  lldb/include/lldb/API/SBValue.h
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/DataFormatters/FormatClasses.h
  lldb/include/lldb/DataFormatters/FormatManager.h
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/DataFormatters/LanguageCategory.h
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/include/lldb/DataFormatters/TypeValidator.h
  lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
  lldb/include/lldb/Target/Language.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/CMakeLists.txt
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp
  lldb/source/DataFormatters/TypeCategory.cpp
  lldb/source/DataFormatters/TypeCategoryMap.cpp
  lldb/source/DataFormatters/TypeValidator.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/source/Target/Language.cpp

Index: lldb/source/Target/Language.cpp
===================================================================
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -134,11 +134,6 @@
   return {};
 }
 
-HardcodedFormatters::HardcodedValidatorFinder
-Language::GetHardcodedValidators() {
-  return {};
-}
-
 std::vector<ConstString>
 Language::GetPossibleFormattersMatches(ValueObject &valobj,
                                        lldb::DynamicValueType use_dynamic) {
Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===================================================================
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ 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;
-}
Index: lldb/source/DataFormatters/TypeValidator.cpp
===================================================================
--- 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();
-}
Index: lldb/source/DataFormatters/TypeCategoryMap.cpp
===================================================================
--- lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ 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<lldb::TypeValidatorImplSP>(
-    FormattersMatchData &match_data, lldb::TypeValidatorImplSP &retval);
-
 template void
 TypeCategoryMap::Get<lldb::TypeFormatImplSP>(FormattersMatchData &match_data,
                                              lldb::TypeFormatImplSP &retval);
Index: lldb/source/DataFormatters/TypeCategory.cpp
===================================================================
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ 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,
@@ -159,20 +158,6 @@
   return false;
 }
 
-bool TypeCategoryImpl::Get(ValueObject &valobj,
-                           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();
@@ -195,12 +180,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) {
@@ -228,12 +207,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;
 }
 
@@ -262,12 +235,6 @@
   if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth)
     count += GetRegexTypeSyntheticsContainer()->GetCount();
 
-  if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator)
-    count += GetTypeValidatorsContainer()->GetCount();
-  if ((items & eFormatCategoryItemRegexValidator) ==
-      eFormatCategoryItemRegexValidator)
-    count += GetRegexTypeValidatorsContainer()->GetCount();
-
   return count;
 }
 
@@ -282,7 +249,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)) {
@@ -364,26 +330,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;
 }
 
@@ -451,22 +397,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())
@@ -539,24 +469,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<std::recursive_mutex> guard(m_mutex);
   if ((m_enabled = value))
Index: lldb/source/DataFormatters/LanguageCategory.cpp
===================================================================
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ 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<lldb::TypeValidatorImplSP>(FormattersMatchData &,
-                                                 lldb::TypeValidatorImplSP &);
-template bool
 LanguageCategory::Get<lldb::TypeFormatImplSP>(FormattersMatchData &,
                                               lldb::TypeFormatImplSP &);
 template bool
@@ -89,11 +83,6 @@
   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 @@
   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>(
Index: lldb/source/DataFormatters/FormatManager.cpp
===================================================================
--- lldb/source/DataFormatters/FormatManager.cpp
+++ 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<std::recursive_mutex> guard(m_language_categories_mutex);
@@ -699,12 +675,6 @@
   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),
Index: lldb/source/DataFormatters/DataVisualization.cpp
===================================================================
--- lldb/source/DataFormatters/DataVisualization.cpp
+++ 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,
Index: lldb/source/DataFormatters/CMakeLists.txt
===================================================================
--- lldb/source/DataFormatters/CMakeLists.txt
+++ lldb/source/DataFormatters/CMakeLists.txt
@@ -13,7 +13,6 @@
   TypeFormat.cpp
   TypeSummary.cpp
   TypeSynthetic.cpp
-  TypeValidator.cpp
   ValueObjectPrinter.cpp
   VectorType.cpp
 
Index: lldb/source/Core/ValueObject.cpp
===================================================================
--- lldb/source/Core/ValueObject.cpp
+++ 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/Symbol/ClangASTContext.h"
@@ -82,13 +81,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),
@@ -112,12 +110,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),
@@ -308,7 +306,6 @@
     SetSyntheticChildren(
         DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
 #endif
-    SetValidator(DataVisualization::GetValidator(*this, GetDynamicValueType()));
   }
 
   return any_change;
@@ -1104,23 +1101,6 @@
   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;
@@ -3129,10 +3109,6 @@
     if (m_synthetic_value)
       m_synthetic_value = nullptr;
   }
-
-  if ((clear_mask & eClearUserVisibleDataItemsValidator) ==
-      eClearUserVisibleDataItemsValidator)
-    m_validation_result.reset();
 }
 
 SymbolContextScope *ValueObject::GetSymbolContextScope() {
Index: lldb/source/API/SBValue.cpp
===================================================================
--- lldb/source/API/SBValue.cpp
+++ 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, ());
Index: lldb/include/lldb/Target/Language.h
===================================================================
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -176,9 +176,6 @@
   virtual HardcodedFormatters::HardcodedSyntheticFinder
   GetHardcodedSynthetics();
 
-  virtual HardcodedFormatters::HardcodedValidatorFinder
-  GetHardcodedValidators();
-
   virtual std::vector<ConstString>
   GetPossibleFormattersMatches(ValueObject &valobj,
                                lldb::DynamicValueType use_dynamic);
Index: lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
===================================================================
--- lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ 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<TypeValidatorResult, std::string> m_validation;
 
   friend struct StringSummaryFormat;
 
Index: lldb/include/lldb/DataFormatters/TypeValidator.h
===================================================================
--- 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 <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_
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===================================================================
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -67,7 +67,6 @@
   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 @@
   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 @@
       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 @@
       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(ValueObject &valobj, const FormattersMatchVector &candidates,
            lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr);
 
-  bool Get(ValueObject &valobj, 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<lldb::RegularExpressionSP,
                                    ScriptedSyntheticChildren>;
 
-  friend class FormattersContainer<ConstString, TypeValidatorImpl>;
-  friend class FormattersContainer<lldb::RegularExpressionSP,
-                                   TypeValidatorImpl>;
 };
 
 } // namespace lldb_private
Index: lldb/include/lldb/DataFormatters/LanguageCategory.h
===================================================================
--- lldb/include/lldb/DataFormatters/LanguageCategory.h
+++ 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 <typename ImplSP>
   auto &GetHardcodedFinder();
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===================================================================
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ 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"
Index: lldb/include/lldb/DataFormatters/FormatManager.h
===================================================================
--- lldb/include/lldb/DataFormatters/FormatManager.h
+++ 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 =
Index: lldb/include/lldb/DataFormatters/FormatClasses.h
===================================================================
--- lldb/include/lldb/DataFormatters/FormatClasses.h
+++ 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<TypeFormatImpl> HardcodedFormatFinder;
   typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
   typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
-  typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
 };
 
 class FormattersMatchCandidate {
Index: lldb/include/lldb/Core/ValueObject.h
===================================================================
--- lldb/include/lldb/Core/ValueObject.h
+++ 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<TypeValidatorResult, std::string> 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<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 @@
   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;
 
Index: lldb/include/lldb/API/SBValue.h
===================================================================
--- lldb/include/lldb/API/SBValue.h
+++ 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();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to