1 //===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 #include "lldb/DataFormatters/TypeValidator.h"
13 #include "lldb/Utility/StreamString.h"
16 using namespace lldb_private;
18 TypeValidatorImpl::TypeValidatorImpl(const Flags &flags)
19 : m_flags(flags), m_my_revision(0) {}
21 TypeValidatorImpl::~TypeValidatorImpl() {}
23 TypeValidatorImpl::ValidationResult TypeValidatorImpl::Success() {
24 return ValidationResult{TypeValidatorResult::Success, ""};
27 TypeValidatorImpl::ValidationResult
28 TypeValidatorImpl::Failure(std::string message) {
29 return ValidationResult{TypeValidatorResult::Failure, message};
32 TypeValidatorImpl_CXX::TypeValidatorImpl_CXX(
33 ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags &flags)
34 : TypeValidatorImpl(flags), m_description(d), m_validator_function(f) {}
36 TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX() {}
38 TypeValidatorImpl::ValidationResult
39 TypeValidatorImpl_CXX::FormatObject(ValueObject *valobj) const {
41 return Success(); // I guess there's nothing wrong with a null valueobject..
43 return m_validator_function(valobj);
46 std::string TypeValidatorImpl_CXX::GetDescription() {
48 sstr.Printf("%s%s%s%s", m_description.c_str(),
49 Cascades() ? "" : " (not cascading)",
50 SkipsPointers() ? " (skip pointers)" : "",
51 SkipsReferences() ? " (skip references)" : "");
52 return sstr.GetString();