================ @@ -0,0 +1,117 @@ +//===-- DILEval.cpp -------------------------------------------------------===// +// +// 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/ValueObject/DILEval.h" + +#include <memory> + +#include "lldb/ValueObject/DILAST.h" +#include "lldb/ValueObject/ValueObject.h" +#include "llvm/Support/FormatAdapters.h" + +namespace lldb_private { + +namespace dil { + +DILInterpreter::DILInterpreter(lldb::TargetSP target, + std::shared_ptr<std::string> sm) + : m_target(std::move(target)), m_sm(std::move(sm)) { + m_default_dynamic = lldb::eNoDynamicValues; +} + +DILInterpreter::DILInterpreter(lldb::TargetSP target, + std::shared_ptr<std::string> sm, + lldb::DynamicValueType use_dynamic) + : m_target(std::move(target)), m_sm(std::move(sm)), + m_default_dynamic(use_dynamic) {} + +DILInterpreter::DILInterpreter(lldb::TargetSP target, + std::shared_ptr<std::string> sm, + lldb::ValueObjectSP scope) + : m_target(std::move(target)), m_sm(std::move(sm)), + m_scope(std::move(scope)) { + m_default_dynamic = lldb::eNoDynamicValues; + // If `m_scope` is a reference, dereference it. All operations on a reference + // should be operations on the referent. + if (m_scope->GetCompilerType().IsValid() && + m_scope->GetCompilerType().IsReferenceType()) { + Status error; + m_scope = m_scope->Dereference(error); + } +} + +lldb::ValueObjectSP DILInterpreter::DILEval(const DILASTNode *tree, + lldb::TargetSP target_sp, + Status &error) { + m_error.Clear(); + // Evaluate an AST. + DILEvalNode(tree); + // Set the error. + error = std::move(m_error); + // Return the computed result. If there was an error, it will be invalid. + return m_result; +} + +lldb::ValueObjectSP DILInterpreter::DILEvalNode(const DILASTNode *node) { + + // Traverse an AST pointed by the `node`. + node->Accept(this); + + // Return the computed value for convenience. The caller is responsible for + // checking if an error occured during the evaluation. + return m_result; +} ---------------- labath wrote:
Is this function needed (given that it's only caller is ignoring the result)? https://github.com/llvm/llvm-project/pull/120971 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits