Files
clang-p2996/lldb/source/Expression/ClangExpressionVariable.cpp
Greg Clayton 99558cc424 Final bit of type system cleanup that abstracts declaration contexts into lldb_private::CompilerDeclContext and renames ClangType to CompilerType in many accessors and functions.
Create a new "lldb_private::CompilerDeclContext" class that will replace all direct uses of "clang::DeclContext" when used in compiler agnostic code, yet still allow for conversion to clang::DeclContext subclasses by clang specific code. This completes the abstraction of type parsing by removing all "clang::" references from the SymbolFileDWARF. The new "lldb_private::CompilerDeclContext" class abstracts decl contexts found in compiler type systems so they can be used in internal API calls. The TypeSystem is required to support CompilerDeclContexts with new pure virtual functions that start with "DeclContext" in the member function names. Converted all code that used lldb_private::ClangNamespaceDecl over to use the new CompilerDeclContext class and removed the ClangNamespaceDecl.cpp and ClangNamespaceDecl.h files.

Removed direct use of clang APIs from SBType and now use the abstract type systems to correctly explore types.

Bulk renames for things that used to return a ClangASTType which is now CompilerType:

    "Type::GetClangFullType()" to "Type::GetFullCompilerType()"
    "Type::GetClangLayoutType()" to "Type::GetLayoutCompilerType()"
    "Type::GetClangForwardType()" to "Type::GetForwardCompilerType()"
    "Value::GetClangType()" to "Value::GetCompilerType()"
    "Value::SetClangType (const CompilerType &)" to "Value::SetCompilerType (const CompilerType &)"
    "ValueObject::GetClangType ()" to "ValueObject::GetCompilerType()"
    many more renames that are similar.

llvm-svn: 245905
2015-08-24 23:46:31 +00:00

143 lines
3.7 KiB
C++

//===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Expression/ClangExpressionVariable.h"
#include "clang/AST/ASTContext.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
using namespace lldb_private;
using namespace clang;
ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
m_parser_vars(),
m_jit_vars (),
m_flags (EVNone),
m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
{
}
ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
Value &value,
const ConstString &name,
uint16_t flags) :
m_parser_vars(),
m_jit_vars (),
m_flags (flags),
m_frozen_sp (ValueObjectConstResult::Create (exe_scope, value, name))
{
}
ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
m_parser_vars(),
m_jit_vars (),
m_flags (EVNone),
m_frozen_sp (valobj_sp)
{
}
//----------------------------------------------------------------------
/// Return the variable's size in bytes
//----------------------------------------------------------------------
size_t
ClangExpressionVariable::GetByteSize ()
{
return m_frozen_sp->GetByteSize();
}
const ConstString &
ClangExpressionVariable::GetName ()
{
return m_frozen_sp->GetName();
}
lldb::ValueObjectSP
ClangExpressionVariable::GetValueObject()
{
return m_frozen_sp;
}
RegisterInfo *
ClangExpressionVariable::GetRegisterInfo()
{
return m_frozen_sp->GetValue().GetRegisterInfo();
}
void
ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
{
return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
}
CompilerType
ClangExpressionVariable::GetCompilerType()
{
return m_frozen_sp->GetCompilerType();
}
void
ClangExpressionVariable::SetCompilerType(const CompilerType &clang_type)
{
m_frozen_sp->GetValue().SetCompilerType(clang_type);
}
TypeFromUser
ClangExpressionVariable::GetTypeFromUser()
{
TypeFromUser tfu (m_frozen_sp->GetCompilerType());
return tfu;
}
uint8_t *
ClangExpressionVariable::GetValueBytes()
{
const size_t byte_size = m_frozen_sp->GetByteSize();
if (byte_size > 0)
{
if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
{
m_frozen_sp->GetValue().ResizeData(byte_size);
m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
}
return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
}
return NULL;
}
void
ClangExpressionVariable::SetName (const ConstString &name)
{
m_frozen_sp->SetName (name);
}
void
ClangExpressionVariable::ValueUpdated ()
{
m_frozen_sp->ValueUpdated ();
}
void
ClangExpressionVariable::TransferAddress (bool force)
{
if (m_live_sp.get() == NULL)
return;
if (m_frozen_sp.get() == NULL)
return;
if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
}