diff options
Diffstat (limited to 'source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp')
-rw-r--r-- | source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp index bb73d55a9a41..742a14992dc9 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -1,15 +1,15 @@ //===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 "ClangPersistentVariables.h" #include "lldb/Core/Value.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" @@ -32,7 +32,7 @@ ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( } ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable( - ExecutionContextScope *exe_scope, const ConstString &name, + ExecutionContextScope *exe_scope, ConstString name, const CompilerType &compiler_type, lldb::ByteOrder byte_order, uint32_t addr_byte_size) { return AddNewlyConstructedVariable(new ClangExpressionVariable( @@ -49,11 +49,26 @@ void ClangPersistentVariables::RemovePersistentVariable( return; name++; - if (strtoul(name, NULL, 0) == m_next_persistent_variable_id - 1) + if (strtoul(name, nullptr, 0) == m_next_persistent_variable_id - 1) m_next_persistent_variable_id--; } -void ClangPersistentVariables::RegisterPersistentDecl(const ConstString &name, +llvm::Optional<CompilerType> +ClangPersistentVariables::GetCompilerTypeFromPersistentDecl( + ConstString type_name) { + CompilerType compiler_type; + if (clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>( + GetPersistentDecl(type_name))) { + compiler_type.SetCompilerType( + ClangASTContext::GetASTContext(&tdecl->getASTContext()), + reinterpret_cast<lldb::opaque_compiler_type_t>( + const_cast<clang::Type *>(tdecl->getTypeForDecl()))); + return compiler_type; + } + return llvm::None; +} + +void ClangPersistentVariables::RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl) { m_persistent_decls.insert( std::pair<const char *, clang::NamedDecl *>(name.GetCString(), decl)); @@ -68,12 +83,12 @@ void ClangPersistentVariables::RegisterPersistentDecl(const ConstString &name, } clang::NamedDecl * -ClangPersistentVariables::GetPersistentDecl(const ConstString &name) { +ClangPersistentVariables::GetPersistentDecl(ConstString name) { PersistentDeclMap::const_iterator i = m_persistent_decls.find(name.GetCString()); if (i == m_persistent_decls.end()) - return NULL; + return nullptr; else return i->second; } |