aboutsummaryrefslogtreecommitdiff
path: root/source/DataFormatters/VectorType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/DataFormatters/VectorType.cpp')
-rw-r--r--source/DataFormatters/VectorType.cpp128
1 files changed, 68 insertions, 60 deletions
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
index 316d7b540bcd..347afa5c0559 100644
--- a/source/DataFormatters/VectorType.cpp
+++ b/source/DataFormatters/VectorType.cpp
@@ -1,4 +1,4 @@
-//===-- VectorType.cpp ---------------------------------------------*- C++ -*-===//
+//===-- VectorType.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/DataFormatters/VectorType.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
@@ -20,87 +25,87 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-static ClangASTType
-GetClangTypeForFormat (lldb::Format format,
- ClangASTType element_type,
- ClangASTContext *ast_ctx)
+static CompilerType
+GetCompilerTypeForFormat (lldb::Format format,
+ CompilerType element_type,
+ TypeSystem *type_system)
{
- lldbassert(ast_ctx && "ast_ctx needs to be not NULL");
+ lldbassert(type_system && "type_system needs to be not NULL");
switch (format)
{
case lldb::eFormatAddressInfo:
case lldb::eFormatPointer:
- return ast_ctx->GetPointerSizedIntType(false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8*type_system->GetPointerByteSize());
case lldb::eFormatBoolean:
- return ast_ctx->GetBasicType(lldb::eBasicTypeBool);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeBool);
case lldb::eFormatBytes:
case lldb::eFormatBytesWithASCII:
case lldb::eFormatChar:
case lldb::eFormatCharArray:
case lldb::eFormatCharPrintable:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar);
case lldb::eFormatComplex /* lldb::eFormatComplexFloat */:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloatComplex);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloatComplex);
case lldb::eFormatCString:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar).GetPointerType();
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar).GetPointerType();
case lldb::eFormatFloat:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat);
case lldb::eFormatHex:
case lldb::eFormatHexUppercase:
case lldb::eFormatOctal:
- return ast_ctx->GetBasicType(lldb::eBasicTypeInt);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeInt);
case lldb::eFormatHexFloat:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat);
case lldb::eFormatUnicode16:
case lldb::eFormatUnicode32:
case lldb::eFormatUnsigned:
- return ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedInt);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeUnsignedInt);
case lldb::eFormatVectorOfChar:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar);
case lldb::eFormatVectorOfFloat32:
- return ast_ctx->GetFloatTypeFromBitSize(32);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 32);
case lldb::eFormatVectorOfFloat64:
- return ast_ctx->GetFloatTypeFromBitSize(64);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 64);
case lldb::eFormatVectorOfSInt16:
- return ast_ctx->GetIntTypeFromBitSize(16, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 16);
case lldb::eFormatVectorOfSInt32:
- return ast_ctx->GetIntTypeFromBitSize(32, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 32);
case lldb::eFormatVectorOfSInt64:
- return ast_ctx->GetIntTypeFromBitSize(64, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 64);
case lldb::eFormatVectorOfSInt8:
- return ast_ctx->GetIntTypeFromBitSize(8, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 8);
case lldb::eFormatVectorOfUInt128:
- return ast_ctx->GetIntTypeFromBitSize(128, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 128);
case lldb::eFormatVectorOfUInt16:
- return ast_ctx->GetIntTypeFromBitSize(16, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 16);
case lldb::eFormatVectorOfUInt32:
- return ast_ctx->GetIntTypeFromBitSize(32, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 32);
case lldb::eFormatVectorOfUInt64:
- return ast_ctx->GetIntTypeFromBitSize(64, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 64);
case lldb::eFormatVectorOfUInt8:
- return ast_ctx->GetIntTypeFromBitSize(8, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8);
case lldb::eFormatDefault:
return element_type;
@@ -113,13 +118,13 @@ GetClangTypeForFormat (lldb::Format format,
case lldb::eFormatOSType:
case lldb::eFormatVoid:
default:
- return ast_ctx->GetIntTypeFromBitSize(8, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8);
}
}
static lldb::Format
GetItemFormatForFormat (lldb::Format format,
- ClangASTType element_type)
+ CompilerType element_type)
{
switch (format)
{
@@ -169,8 +174,8 @@ GetItemFormatForFormat (lldb::Format format,
}
static size_t
-CalculateNumChildren (ClangASTType container_type,
- ClangASTType element_type,
+CalculateNumChildren (CompilerType container_type,
+ CompilerType element_type,
lldb_private::ExecutionContextScope *exe_scope = nullptr // does not matter here because all we trade in are basic types
)
{
@@ -199,15 +204,17 @@ namespace lldb_private {
m_child_type(),
m_num_children(0)
{}
-
- virtual size_t
- CalculateNumChildren ()
+
+ ~VectorTypeSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
{
return m_num_children;
}
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
{
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
@@ -225,29 +232,32 @@ namespace lldb_private {
return child_sp;
}
- virtual bool
- Update()
+ bool
+ Update() override
{
m_parent_format = m_backend.GetFormat();
- ClangASTType parent_type(m_backend.GetClangType());
- ClangASTType element_type;
+ CompilerType parent_type(m_backend.GetCompilerType());
+ CompilerType element_type;
parent_type.IsVectorType(&element_type, nullptr);
- m_child_type = ::GetClangTypeForFormat(m_parent_format, element_type, ClangASTContext::GetASTContext(parent_type.GetASTContext()));
+ TargetSP target_sp(m_backend.GetTargetSP());
+ m_child_type = ::GetCompilerTypeForFormat(m_parent_format,
+ element_type,
+ target_sp ? target_sp->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC) : nullptr);
m_num_children = ::CalculateNumChildren(parent_type,
m_child_type);
m_item_format = GetItemFormatForFormat(m_parent_format,
m_child_type);
return false;
}
-
- virtual bool
- MightHaveChildren ()
+
+ bool
+ MightHaveChildren() override
{
return true;
}
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name)
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
{
const char* item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
@@ -255,18 +265,16 @@ namespace lldb_private {
return UINT32_MAX;
return idx;
}
-
- virtual
- ~VectorTypeSyntheticFrontEnd () {}
-
+
private:
lldb::Format m_parent_format;
lldb::Format m_item_format;
- ClangASTType m_child_type;
+ CompilerType m_child_type;
size_t m_num_children;
};
- }
-}
+
+ } // namespace formatters
+} // namespace lldb_private
bool
lldb_private::formatters::VectorTypeSummaryProvider (ValueObject& valobj,
@@ -317,6 +325,6 @@ lldb_private::SyntheticChildrenFrontEnd*
lldb_private::formatters::VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
if (!valobj_sp)
- return NULL;
- return (new VectorTypeSyntheticFrontEnd(valobj_sp));
+ return nullptr;
+ return new VectorTypeSyntheticFrontEnd(valobj_sp);
}