Differential D79752 Diff 266389 lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
//===-- ClangPersistentVariables.cpp --------------------------------------===// | //===-- ClangPersistentVariables.cpp --------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "ClangPersistentVariables.h" | #include "ClangPersistentVariables.h" | ||||
#include "ClangASTImporter.h" | #include "ClangASTImporter.h" | ||||
#include "ClangModulesDeclVendor.h" | |||||
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h" | #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" | ||||
#include "lldb/Core/Value.h" | #include "lldb/Core/Value.h" | ||||
#include "lldb/Target/Target.h" | #include "lldb/Target/Target.h" | ||||
#include "lldb/Utility/DataExtractor.h" | #include "lldb/Utility/DataExtractor.h" | ||||
#include "lldb/Utility/Log.h" | #include "lldb/Utility/Log.h" | ||||
#include "lldb/Utility/StreamString.h" | #include "lldb/Utility/StreamString.h" | ||||
#include "clang/AST/Decl.h" | #include "clang/AST/Decl.h" | ||||
#include "llvm/ADT/StringMap.h" | #include "llvm/ADT/StringMap.h" | ||||
using namespace lldb; | using namespace lldb; | ||||
using namespace lldb_private; | using namespace lldb_private; | ||||
ClangPersistentVariables::ClangPersistentVariables() | ClangPersistentVariables::ClangPersistentVariables( | ||||
: lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang) {} | std::shared_ptr<Target> target) | ||||
: lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang), | |||||
m_target_sp(target) {} | |||||
ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( | ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( | ||||
const lldb::ValueObjectSP &valobj_sp) { | const lldb::ValueObjectSP &valobj_sp) { | ||||
return AddNewlyConstructedVariable(new ClangExpressionVariable(valobj_sp)); | return AddNewlyConstructedVariable(new ClangExpressionVariable(valobj_sp)); | ||||
} | } | ||||
ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( | ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( | ||||
ExecutionContextScope *exe_scope, ConstString name, | ExecutionContextScope *exe_scope, ConstString name, | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
std::shared_ptr<ClangASTImporter> | std::shared_ptr<ClangASTImporter> | ||||
ClangPersistentVariables::GetClangASTImporter() { | ClangPersistentVariables::GetClangASTImporter() { | ||||
if (!m_ast_importer_sp) { | if (!m_ast_importer_sp) { | ||||
m_ast_importer_sp = std::make_shared<ClangASTImporter>(); | m_ast_importer_sp = std::make_shared<ClangASTImporter>(); | ||||
} | } | ||||
return m_ast_importer_sp; | return m_ast_importer_sp; | ||||
} | } | ||||
std::shared_ptr<ClangModulesDeclVendor> | |||||
ClangPersistentVariables::GetClangModulesDeclVendor() { | |||||
if (!m_modules_decl_vendor_sp) { | |||||
m_modules_decl_vendor_sp.reset( | |||||
ClangModulesDeclVendor::Create(*m_target_sp.get())); | |||||
} | |||||
return m_modules_decl_vendor_sp; | |||||
} | |||||
ConstString | ConstString | ||||
ClangPersistentVariables::GetNextPersistentVariableName(bool is_error) { | ClangPersistentVariables::GetNextPersistentVariableName(bool is_error) { | ||||
llvm::SmallString<64> name; | llvm::SmallString<64> name; | ||||
{ | { | ||||
llvm::raw_svector_ostream os(name); | llvm::raw_svector_ostream os(name); | ||||
os << GetPersistentVariablePrefix(is_error) | os << GetPersistentVariablePrefix(is_error) | ||||
<< m_next_persistent_variable_id++; | << m_next_persistent_variable_id++; | ||||
} | } | ||||
return ConstString(name); | return ConstString(name); | ||||
} | } |