Files
clang-p2996/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
Adrian Prantl 0e4c482124 Pass ConstString by value (NFC)
My apologies for the large patch. With the exception of ConstString.h
itself it was entirely produced by sed.

ConstString has exactly one const char * data member, so passing a
ConstString by reference is not any more efficient than copying it by
value. In both cases a single pointer is passed. But passing it by
value makes it harder to accidentally return the address of a local
object.

(This fixes rdar://problem/48640859 for the Apple folks)

Differential Revision: https://reviews.llvm.org/D59030

llvm-svn: 355553
2019-03-06 21:22:25 +00:00

61 lines
1.7 KiB
C++

//===-- LibCxxQueue.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 "LibCxx.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
using namespace lldb;
using namespace lldb_private;
namespace {
class QueueFrontEnd : public SyntheticChildrenFrontEnd {
public:
QueueFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
Update();
}
size_t GetIndexOfChildWithName(ConstString name) override {
return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name)
: UINT32_MAX;
}
bool MightHaveChildren() override { return true; }
bool Update() override;
size_t CalculateNumChildren() override {
return m_container_sp ? m_container_sp->GetNumChildren() : 0;
}
ValueObjectSP GetChildAtIndex(size_t idx) override {
return m_container_sp ? m_container_sp->GetChildAtIndex(idx, true)
: nullptr;
}
private:
ValueObjectSP m_container_sp;
};
} // namespace
bool QueueFrontEnd::Update() {
m_container_sp.reset();
ValueObjectSP c_sp = m_backend.GetChildMemberWithName(ConstString("c"), true);
if (!c_sp)
return false;
m_container_sp = c_sp->GetSyntheticValue();
return false;
}
SyntheticChildrenFrontEnd *
formatters::LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP valobj_sp) {
if (valobj_sp)
return new QueueFrontEnd(*valobj_sp);
return nullptr;
}