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
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index b2b4cdf..05fd53b 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -164,7 +164,7 @@
const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index);
Value value;
value.SetValueType(Value::eValueTypeScalar);
- void *type;
+ ClangASTType clang_type;
char *int_pos;
if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int")))
@@ -207,9 +207,9 @@
return false;
}
- type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
+ clang_type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
- if (!type)
+ if (!clang_type.IsValid())
{
result.AppendErrorWithFormat ("Couldn't get Clang type for format %s (%s integer, width %d).\n",
arg_type_cstr,
@@ -223,9 +223,9 @@
else if (strchr (arg_type_cstr, '*'))
{
if (!strcmp (arg_type_cstr, "void*"))
- type = ast_context.CreatePointerType (ast_context.GetBuiltInType_void ());
+ clang_type = ast_context.GetBasicType(eBasicTypeVoid).GetPointerType();
else if (!strcmp (arg_type_cstr, "char*"))
- type = ast_context.GetCStringType (false);
+ clang_type = ast_context.GetCStringType (false);
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
@@ -240,8 +240,7 @@
return false;
}
- value.SetContext (Value::eContextTypeClangType, type);
-
+ value.SetClangType (clang_type);
value_list.PushValue(value);
}
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 97ab957..eea0cf5 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -543,15 +543,15 @@
else
{
TypeSP type_sp (type_list.GetTypeAtIndex(0));
- clang_ast_type.SetClangType (type_sp->GetClangAST(), type_sp->GetClangFullType());
+ clang_ast_type = type_sp->GetClangFullType();
}
}
while (pointer_count > 0)
{
- clang_type_t pointer_type = ClangASTContext::CreatePointerType (clang_ast_type.GetASTContext(), clang_ast_type.GetOpaqueQualType());
- if (pointer_type)
- clang_ast_type.SetClangType (clang_ast_type.GetASTContext(), pointer_type);
+ ClangASTType pointer_type = clang_ast_type.GetPointerType();
+ if (pointer_type.IsValid())
+ clang_ast_type = pointer_type;
else
{
result.AppendError ("unable make a pointer type\n");
@@ -561,7 +561,7 @@
--pointer_count;
}
- m_format_options.GetByteSizeValue() = clang_ast_type.GetClangTypeByteSize();
+ m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize();
if (m_format_options.GetByteSizeValue() == 0)
{
@@ -675,7 +675,7 @@
if (m_format_options.GetFormatValue().OptionWasSet() == false)
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
- bytes_read = clang_ast_type.GetTypeByteSize() * m_format_options.GetCountValue().GetCurrentValue();
+ bytes_read = clang_ast_type.GetByteSize() * m_format_options.GetCountValue().GetCurrentValue();
}
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
diff --git a/lldb/source/Commands/CommandObjectVersion.cpp b/lldb/source/Commands/CommandObjectVersion.cpp
index ea1930e..2d950a8 100644
--- a/lldb/source/Commands/CommandObjectVersion.cpp
+++ b/lldb/source/Commands/CommandObjectVersion.cpp
@@ -38,8 +38,16 @@
bool
CommandObjectVersion::DoExecute (Args& args, CommandReturnObject &result)
{
- result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion());
- result.SetStatus (eReturnStatusSuccessFinishResult);
+ if (args.GetArgumentCount() == 0)
+ {
+ result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion());
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendError("the version command takes no arguments.");
+ result.SetStatus (eReturnStatusFailed);
+ }
return true;
}
diff --git a/lldb/source/Commands/CommandObjectVersion.h b/lldb/source/Commands/CommandObjectVersion.h
index 035c65e..1fdbed6 100644
--- a/lldb/source/Commands/CommandObjectVersion.h
+++ b/lldb/source/Commands/CommandObjectVersion.h
@@ -34,7 +34,7 @@
protected:
virtual bool
DoExecute (Args& args,
- CommandReturnObject &result);
+ CommandReturnObject &result);
};
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 7a6a47e..c1f0c41 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -1050,7 +1050,7 @@
valobj_sp = valobj_list.GetValueObjectAtIndex(0);
}
- ClangASTType type;
+ ClangASTType clang_type;
if (valobj_sp)
{
@@ -1063,7 +1063,7 @@
size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
: m_option_watchpoint.watch_size;
}
- type.SetClangType(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
+ clang_type = valobj_sp->GetClangType();
}
else
{
@@ -1080,7 +1080,7 @@
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
- Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &clang_type, watch_type, error).get();
if (wp)
{
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
@@ -1292,12 +1292,10 @@
// Fetch the type from the value object, the type of the watched object is the pointee type
/// of the expression, so convert to that if we found a valid type.
- ClangASTType type(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
- if (type.IsValid())
- type.SetClangType(type.GetASTContext(), type.GetPointeeType());
+ ClangASTType clang_type(valobj_sp->GetClangType());
Error error;
- Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &clang_type, watch_type, error).get();
if (wp)
{
Stream &output_stream = result.GetOutputStream();