TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index c4db97c..9f22bba 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -146,8 +146,14 @@
result.SetStatus (eReturnStatusFailed);
return false;
}
-
- ClangASTContext &ast_context = thread_module_sp->GetClangASTContext();
+
+ TypeSystem *type_system = thread_module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
+ if (type_system == nullptr)
+ {
+ result.AppendError ("Unable to create C type system.");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
ValueList value_list;
@@ -156,7 +162,7 @@
const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index);
Value value;
value.SetValueType(Value::eValueTypeScalar);
- CompilerType clang_type;
+ CompilerType compiler_type;
char *int_pos;
if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int")))
@@ -198,10 +204,9 @@
result.SetStatus (eReturnStatusFailed);
return false;
}
+ compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
- clang_type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
-
- if (!clang_type.IsValid())
+ if (!compiler_type.IsValid())
{
result.AppendErrorWithFormat ("Couldn't get Clang type for format %s (%s integer, width %d).\n",
arg_type_cstr,
@@ -215,9 +220,9 @@
else if (strchr (arg_type_cstr, '*'))
{
if (!strcmp (arg_type_cstr, "void*"))
- clang_type = ast_context.GetBasicType(eBasicTypeVoid).GetPointerType();
+ compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
else if (!strcmp (arg_type_cstr, "char*"))
- clang_type = ast_context.GetCStringType (false);
+ compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeChar).GetPointerType();
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
@@ -232,7 +237,7 @@
return false;
}
- value.SetCompilerType (clang_type);
+ value.SetCompilerType (compiler_type);
value_list.PushValue(value);
}