]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/source/DataFormatters/TypeValidator.cpp
Fix a memory leak in if_delgroups() introduced in r334118.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / source / DataFormatters / TypeValidator.cpp
1 //===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9
10
11
12 #include "lldb/DataFormatters/TypeValidator.h"
13 #include "lldb/Utility/StreamString.h"
14
15 using namespace lldb;
16 using namespace lldb_private;
17
18 TypeValidatorImpl::TypeValidatorImpl(const Flags &flags)
19     : m_flags(flags), m_my_revision(0) {}
20
21 TypeValidatorImpl::~TypeValidatorImpl() {}
22
23 TypeValidatorImpl::ValidationResult TypeValidatorImpl::Success() {
24   return ValidationResult{TypeValidatorResult::Success, ""};
25 }
26
27 TypeValidatorImpl::ValidationResult
28 TypeValidatorImpl::Failure(std::string message) {
29   return ValidationResult{TypeValidatorResult::Failure, message};
30 }
31
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) {}
35
36 TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX() {}
37
38 TypeValidatorImpl::ValidationResult
39 TypeValidatorImpl_CXX::FormatObject(ValueObject *valobj) const {
40   if (!valobj)
41     return Success(); // I guess there's nothing wrong with a null valueobject..
42
43   return m_validator_function(valobj);
44 }
45
46 std::string TypeValidatorImpl_CXX::GetDescription() {
47   StreamString sstr;
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();
53 }