aboutsummaryrefslogtreecommitdiff
path: root/source/Symbol/ClangASTType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/ClangASTType.cpp')
-rw-r--r--source/Symbol/ClangASTType.cpp97
1 files changed, 69 insertions, 28 deletions
diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp
index eaff90ab8a0a..a62cc9f45a6b 100644
--- a/source/Symbol/ClangASTType.cpp
+++ b/source/Symbol/ClangASTType.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/Symbol/ClangASTType.h"
#include "clang/AST/ASTConsumer.h"
@@ -30,6 +28,8 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Signals.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
@@ -43,8 +43,10 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/VerifyDecl.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include <iterator>
@@ -313,6 +315,18 @@ ClangASTType::IsVectorType (ClangASTType *element_type,
return true;
}
break;
+ case clang::Type::ExtVector:
+ {
+ const clang::ExtVectorType *ext_vector_type = qual_type->getAs<clang::ExtVectorType>();
+ if (ext_vector_type)
+ {
+ if (size)
+ *size = ext_vector_type->getNumElements();
+ if (element_type)
+ *element_type = ClangASTType(m_ast, ext_vector_type->getElementType().getAsOpaquePtr());
+ }
+ return true;
+ }
default:
break;
}
@@ -493,7 +507,7 @@ ClangASTType::IsHomogeneousAggregate (ClangASTType* base_type_ptr) const
}
else if (field_qual_type->isVectorType() || field_qual_type->isExtVectorType())
{
- const clang::VectorType *array = llvm::cast<clang::VectorType>(field_qual_type.getTypePtr());
+ const clang::VectorType *array = field_qual_type.getTypePtr()->getAs<clang::VectorType>();
if (array && array->getNumElements() <= 4)
{
if (num_fields == 0)
@@ -2093,7 +2107,7 @@ ClangASTType::GetBasicTypeFromAST (lldb::BasicType basic_type) const
//----------------------------------------------------------------------
uint64_t
-ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
+ClangASTType::GetBitSize (ExecutionContextScope *exe_scope) const
{
if (GetCompleteType ())
{
@@ -2102,9 +2116,12 @@ ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
{
case clang::Type::ObjCInterface:
case clang::Type::ObjCObject:
- if (exe_ctx && exe_ctx->GetProcessPtr())
+ {
+ ExecutionContext exe_ctx (exe_scope);
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
{
- ObjCLanguageRuntime *objc_runtime = exe_ctx->GetProcessPtr()->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
if (objc_runtime)
{
uint64_t bit_size = 0;
@@ -2118,14 +2135,18 @@ ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
if (!g_printed)
{
StreamString s;
- s.Printf("warning: trying to determine the size of type ");
DumpTypeDescription(&s);
- s.Printf("\n without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\nbacktrace:\n");
- Host::Backtrace(s, 10);
- printf("%s\n", s.GetData());
+
+ llvm::outs() << "warning: trying to determine the size of type ";
+ llvm::outs() << s.GetString() << "\n";
+ llvm::outs() << "without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\n";
+ llvm::outs() << "backtrace:\n";
+ llvm::sys::PrintStackTrace(llvm::outs());
+ llvm::outs() << "\n";
g_printed = true;
}
}
+ }
// fallthrough
default:
const uint32_t bit_size = m_ast->getTypeSize (qual_type);
@@ -2143,11 +2164,12 @@ ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
}
uint64_t
-ClangASTType::GetByteSize (ExecutionContext *exe_ctx) const
+ClangASTType::GetByteSize (ExecutionContextScope *exe_scope) const
{
- return (GetBitSize (exe_ctx) + 7) / 8;
+ return (GetBitSize (exe_scope) + 7) / 8;
}
+
size_t
ClangASTType::GetTypeBitAlign () const
{
@@ -2224,6 +2246,24 @@ ClangASTType::GetEncoding (uint64_t &count) const
case clang::BuiltinType::ObjCSel: return lldb::eEncodingUint;
case clang::BuiltinType::NullPtr: return lldb::eEncodingUint;
+
+ case clang::BuiltinType::Kind::ARCUnbridgedCast:
+ case clang::BuiltinType::Kind::BoundMember:
+ case clang::BuiltinType::Kind::BuiltinFn:
+ case clang::BuiltinType::Kind::Dependent:
+ case clang::BuiltinType::Kind::Half:
+ case clang::BuiltinType::Kind::OCLEvent:
+ case clang::BuiltinType::Kind::OCLImage1d:
+ case clang::BuiltinType::Kind::OCLImage1dArray:
+ case clang::BuiltinType::Kind::OCLImage1dBuffer:
+ case clang::BuiltinType::Kind::OCLImage2d:
+ case clang::BuiltinType::Kind::OCLImage2dArray:
+ case clang::BuiltinType::Kind::OCLImage3d:
+ case clang::BuiltinType::Kind::OCLSampler:
+ case clang::BuiltinType::Kind::Overload:
+ case clang::BuiltinType::Kind::PseudoObject:
+ case clang::BuiltinType::Kind::UnknownAny:
+ break;
}
break;
// All pointer types are represented as unsigned integer encodings.
@@ -3478,7 +3518,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
child_byte_offset = bit_offset/8;
ClangASTType base_class_clang_type(m_ast, base_class->getType());
child_name = base_class_clang_type.GetTypeName().AsCString("");
- uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(nullptr);
+ uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
// Base classes bit sizes should be a multiple of 8 bits in size
assert (base_class_clang_type_bit_size % 8 == 0);
@@ -3506,7 +3546,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
// alignment (field_type_info.second) from the AST context.
ClangASTType field_clang_type (m_ast, field->getType());
assert(field_idx < record_layout.getFieldCount());
- child_byte_size = field_clang_type.GetByteSize(exe_ctx);
+ child_byte_size = field_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
// Figure out the field offset within the current struct/union/class type
bit_offset = record_layout.getFieldOffset (field_idx);
@@ -3671,7 +3711,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
// We have a pointer to an simple type
if (idx == 0 && pointee_clang_type.GetCompleteType())
{
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -3690,9 +3730,9 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
if (element_type.GetCompleteType())
{
char element_name[64];
- ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
+ ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize(exe_ctx);
+ child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
return element_type;
}
@@ -3711,9 +3751,9 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
if (element_type.GetCompleteType())
{
char element_name[64];
- ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
+ ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize(exe_ctx);
+ child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
return element_type;
}
@@ -3763,7 +3803,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
// We have a pointer to an simple type
if (idx == 0)
{
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -3807,7 +3847,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
// We have a pointer to an simple type
if (idx == 0)
{
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -5136,7 +5176,7 @@ ClangASTType::AddMethodToCXXRecordType (const char *name,
{
// Check the number of operator parameters. Sometimes we have
// seen bad DWARF that doesn't correctly describe operators and
- // if we try to create a methed and add it to the class, clang
+ // if we try to create a method and add it to the class, clang
// will assert and crash, so we need to make sure things are
// acceptable.
if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params))
@@ -5358,6 +5398,7 @@ ClangASTType::AddObjCClassProperty (const char *property_name,
&m_ast->Idents.get(property_name),
clang::SourceLocation(), //Source Location for AT
clang::SourceLocation(), //Source location for (
+ ivar_decl ? ivar_decl->getType() : property_clang_type.GetQualType(),
prop_type_source);
if (property_decl)
@@ -6123,7 +6164,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx,
for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
{
// Print the starting squiggly bracket (if this is the
- // first member) or comman (for member 2 and beyong) for
+ // first member) or comma (for member 2 and beyond) for
// the struct/union/class member.
if (child_idx == 0)
s->PutChar('{');
@@ -6238,7 +6279,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx,
for (element_idx = 0; element_idx < element_count; ++element_idx)
{
// Print the starting squiggly bracket (if this is the
- // first member) or comman (for member 2 and beyong) for
+ // first member) or comma (for member 2 and beyond) for
// the struct/union/class member.
if (element_idx == 0)
s->PutChar('{');
@@ -6345,7 +6386,7 @@ ClangASTType::DumpValue (ExecutionContext *exe_ctx,
break;
default:
- // We are down the a scalar type that we just need to display.
+ // We are down to a scalar type that we just need to display.
data.Dump(s,
data_byte_offset,
format,
@@ -6454,7 +6495,7 @@ ClangASTType::DumpTypeValue (Stream *s,
// format was not enum, just fall through and dump the value as requested....
default:
- // We are down the a scalar type that we just need to display.
+ // We are down to a scalar type that we just need to display.
{
uint32_t item_count = 1;
// A few formats, we might need to modify our size and count for depending
@@ -6913,7 +6954,7 @@ ClangASTType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx,
if (!GetCompleteType())
return false;
- const uint64_t byte_size = GetByteSize(exe_ctx);
+ const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (data.GetByteSize() < byte_size)
{
lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
@@ -6963,7 +7004,7 @@ ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx,
if (!GetCompleteType())
return false;
- const uint64_t byte_size = GetByteSize(exe_ctx);
+ const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (byte_size > 0)
{