llvm-project/lldb/source/Expression/ClangExpressionVariable.cpp
Greg Clayton 57ee306789 Huge change to clean up types.
A long time ago we start with clang types that were created by the symbol files and there were many functions in lldb_private::ClangASTContext that helped. Later we create ClangASTType which contains a clang::ASTContext and an opauque QualType, but we didn't switch over to fully using it. There were a lot of places where we would pass around a raw clang_type_t and also pass along a clang::ASTContext separately. This left room for error.

This checkin change all type code over to use ClangASTType everywhere and I cleaned up the interfaces quite a bit. Any code that was in ClangASTContext that was type related, was moved over into ClangASTType. All code that used these types was switched over to use all of the new goodness.

llvm-svn: 186130
2013-07-11 22:46:58 +00:00

137 lines
3.4 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"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#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 (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));
}
ClangASTType
ClangExpressionVariable::GetClangType()
{
return m_frozen_sp->GetClangType();
}
void
ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
{
m_frozen_sp->GetValue().SetClangType(clang_type);
}
TypeFromUser
ClangExpressionVariable::GetTypeFromUser()
{
TypeFromUser tfu (m_frozen_sp->GetClangType());
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());
}