brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 9540bff Raw
70 lines · cpp
1//===-- MsvcStlUnordered.cpp ----------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "MsvcStl.h"10#include "lldb/DataFormatters/TypeSynthetic.h"11 12using namespace lldb;13using namespace lldb_private;14 15namespace {16 17class UnorderedFrontEnd : public SyntheticChildrenFrontEnd {18public:19  UnorderedFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {20    Update();21  }22 23  llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {24    if (!m_list_sp)25      return llvm::createStringError("Missing _List");26    return m_list_sp->GetIndexOfChildWithName(name);27  }28 29  lldb::ChildCacheState Update() override;30 31  llvm::Expected<uint32_t> CalculateNumChildren() override {32    if (!m_list_sp)33      return llvm::createStringError("Missing _List");34    return m_list_sp->GetNumChildren();35  }36 37  ValueObjectSP GetChildAtIndex(uint32_t idx) override {38    if (!m_list_sp)39      return nullptr;40    return m_list_sp->GetChildAtIndex(idx);41  }42 43private:44  ValueObjectSP m_list_sp;45};46 47} // namespace48 49lldb::ChildCacheState UnorderedFrontEnd::Update() {50  m_list_sp = nullptr;51  ValueObjectSP list_sp = m_backend.GetChildMemberWithName("_List");52  if (!list_sp)53    return lldb::ChildCacheState::eRefetch;54  m_list_sp = list_sp->GetSyntheticValue();55  return lldb::ChildCacheState::eRefetch;56}57 58bool formatters::IsMsvcStlUnordered(ValueObject &valobj) {59  if (auto valobj_sp = valobj.GetNonSyntheticValue())60    return valobj_sp->GetChildMemberWithName("_List") != nullptr;61  return false;62}63 64SyntheticChildrenFrontEnd *formatters::MsvcStlUnorderedSyntheticFrontEndCreator(65    CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {66  if (valobj_sp)67    return new UnorderedFrontEnd(*valobj_sp);68  return nullptr;69}70