[Lldb-commits] [lldb] r247041 - Use LLVM casting for TypeSystem so you can cast it to subclasses.
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 8 11:15:06 PDT 2015
Author: gclayton
Date: Tue Sep 8 13:15:05 2015
New Revision: 247041
URL: http://llvm.org/viewvc/llvm-project?rev=247041&view=rev
Log:
Use LLVM casting for TypeSystem so you can cast it to subclasses.
This will keep our code cleaner and it removes the need for intrusive additions to TypeSystem like:
class TypeSystem
{
virtual ClangASTContext *
AsClangASTContext() = 0;
}
As you can now just use the llvm::dyn_cast and other casts.
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/TypeSystem.h
lldb/trunk/source/DataFormatters/CoreMedia.cpp
lldb/trunk/source/DataFormatters/NSArray.cpp
lldb/trunk/source/DataFormatters/NSIndexPath.cpp
lldb/trunk/source/DataFormatters/VectorType.cpp
lldb/trunk/source/Expression/ClangASTSource.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/CompilerDeclContext.cpp
lldb/trunk/source/Symbol/TypeSystem.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Sep 8 13:15:05 2015
@@ -40,7 +40,15 @@ class ClangASTContext : public TypeSyste
public:
typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
-
+
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts)
+ {
+ return ts->getKind() == TypeSystem::eKindClang;
+ }
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
@@ -482,12 +490,6 @@ public:
// TypeSystem methods
//------------------------------------------------------------------
- ClangASTContext*
- AsClangASTContext() override
- {
- return this;
- }
-
DWARFASTParser *
GetDWARFParser () override;
@@ -532,7 +534,7 @@ public:
static bool
IsClangType (const CompilerType &ct)
{
- return (ct.GetTypeSystem()->AsClangASTContext() != nullptr);
+ return llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) != nullptr;
}
//----------------------------------------------------------------------
@@ -1049,7 +1051,9 @@ public:
static clang::QualType
GetQualType (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ // Make sure we have a clang type before making a clang::QualType
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
return clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType());
return clang::QualType();
}
@@ -1057,7 +1061,9 @@ public:
static clang::QualType
GetCanonicalQualType (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ // Make sure we have a clang type before making a clang::QualType
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
return clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType()).getCanonicalType();
return clang::QualType();
}
Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Tue Sep 8 13:15:05 2015
@@ -17,6 +17,7 @@
#include "lldb/Symbol/CompilerDeclContext.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Type.h"
+#include "llvm/Support/Casting.h"
class DWARFDIE;
class DWARFASTParser;
@@ -30,14 +31,51 @@ class TypeSystem
{
public:
//----------------------------------------------------------------------
+ // Intrusive type system that allows us to use llvm casting.
+ //
+ // To add a new type system:
+ //
+ // 1 - Add a new enumeration for llvm casting below for your TypeSystem
+ // subclass, here we will use eKindFoo
+ //
+ // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
+ // to implement a static classof() function that returns your
+ // enumeration:
+ //
+ // class Foo : public lldb_private::TypeSystem
+ // {
+ // static bool classof(const TypeSystem *ts)
+ // {
+ // return ts->getKind() == TypeSystem::eKindFoo;
+ // }
+ // };
+ //
+ // 3 - Contruct your TypeSystem subclass with the enumeration from below
+ //
+ // Foo() :
+ // TypeSystem(TypeSystem::eKindFoo),
+ // ...
+ // {
+ // }
+ //
+ // Then you can use the llvm casting on any "TypeSystem *" to get an
+ // instance of your subclass.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind {
+ eKindClang,
+ eKindSwift,
+ eKindGo,
+ kNumKinds
+ };
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ //----------------------------------------------------------------------
// Constructors and Destructors
//----------------------------------------------------------------------
- TypeSystem ();
+ TypeSystem (LLVMCastKind kind);
virtual ~TypeSystem ();
-
- virtual ClangASTContext *
- AsClangASTContext() = 0;
virtual DWARFASTParser *
GetDWARFParser ()
@@ -395,6 +433,7 @@ public:
virtual bool
IsReferenceType (void *type, CompilerType *pointee_type, bool* is_rvalue) = 0;
protected:
+ const LLVMCastKind m_kind; // Support for llvm casting
SymbolFile *m_sym_file;
};
Modified: lldb/trunk/source/DataFormatters/CoreMedia.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CoreMedia.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CoreMedia.cpp (original)
+++ lldb/trunk/source/DataFormatters/CoreMedia.cpp Tue Sep 8 13:15:05 2015
@@ -11,7 +11,7 @@
#include "lldb/Core/Flags.h"
#include "lldb/Symbol/ClangASTContext.h"
-
+#include "lldb/Target/Target.h"
#include <inttypes.h>
using namespace lldb;
@@ -21,9 +21,11 @@ using namespace lldb_private::formatters
bool
lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
- if (!valobj.GetCompilerType().IsValid())
+ CompilerType type = valobj.GetCompilerType();
+ if (!type.IsValid())
return false;
- ClangASTContext *ast_ctx = valobj.GetCompilerType().GetTypeSystem()->AsClangASTContext();
+
+ ClangASTContext *ast_ctx = valobj.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext();
if (!ast_ctx)
return false;
Modified: lldb/trunk/source/DataFormatters/NSArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/NSArray.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/NSArray.cpp (original)
+++ lldb/trunk/source/DataFormatters/NSArray.cpp Tue Sep 8 13:15:05 2015
@@ -529,11 +529,15 @@ lldb_private::formatters::NSArrayISynthe
m_items (0),
m_data_ptr (0)
{
- if (valobj_sp && valobj_sp->GetCompilerType().IsValid())
+ if (valobj_sp)
{
- ClangASTContext *ast = valobj_sp->GetCompilerType().GetTypeSystem()->AsClangASTContext();
- if (ast)
- m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy);
+ CompilerType type = valobj_sp->GetCompilerType();
+ if (type)
+ {
+ ClangASTContext *ast = valobj_sp->GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext();
+ if (ast)
+ m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy);
+ }
}
}
Modified: lldb/trunk/source/DataFormatters/NSIndexPath.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/NSIndexPath.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/NSIndexPath.cpp (original)
+++ lldb/trunk/source/DataFormatters/NSIndexPath.cpp Tue Sep 8 13:15:05 2015
@@ -27,7 +27,6 @@ public:
NSIndexPathSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd (*valobj_sp.get()),
m_ptr_size(0),
- m_ast_ctx(nullptr),
m_uint_star_type()
{
m_ptr_size = m_backend.GetTargetSP()->GetArchitecture().GetAddressByteSize();
@@ -53,11 +52,12 @@ public:
TypeSystem* type_system = m_backend.GetCompilerType().GetTypeSystem();
if (!type_system)
return false;
- m_ast_ctx = type_system->AsClangASTContext();
- if (!m_ast_ctx)
+
+ ClangASTContext *ast = m_backend.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext();
+ if (!ast)
return false;
-
- m_uint_star_type = m_ast_ctx->GetPointerSizedIntType(false);
+
+ m_uint_star_type = ast->GetPointerSizedIntType(false);
static ConstString g__indexes("_indexes");
static ConstString g__length("_length");
@@ -325,7 +325,6 @@ protected:
} m_impl;
uint32_t m_ptr_size;
- ClangASTContext* m_ast_ctx;
CompilerType m_uint_star_type;
};
Modified: lldb/trunk/source/DataFormatters/VectorType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/VectorType.cpp (original)
+++ lldb/trunk/source/DataFormatters/VectorType.cpp Tue Sep 8 13:15:05 2015
@@ -232,7 +232,7 @@ namespace lldb_private {
CompilerType parent_type(m_backend.GetCompilerType());
CompilerType element_type;
parent_type.IsVectorType(&element_type, nullptr);
- m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type, parent_type.GetTypeSystem()->AsClangASTContext());
+ m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type, llvm::dyn_cast_or_null<ClangASTContext>(parent_type.GetTypeSystem()));
m_num_children = ::CalculateNumChildren(parent_type,
m_child_type);
m_item_format = GetItemFormatForFormat(m_parent_format,
Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Sep 8 13:15:05 2015
@@ -1889,15 +1889,12 @@ ClangASTSource::AddNamespace (NameSearch
CompilerType
ClangASTSource::GuardedCopyType (const CompilerType &src_type)
{
- if (!ClangASTContext::IsClangType(src_type))
+ ClangASTContext *src_ast = llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
+ if (src_ast == nullptr)
return CompilerType();
-
+
ClangASTMetrics::RegisterLLDBImport();
- ClangASTContext* src_ast = src_type.GetTypeSystem()->AsClangASTContext();
- if (!src_ast)
- return CompilerType();
-
SetImportInProgress(true);
QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_ast->getASTContext(), ClangASTContext::GetQualType(src_type));
@@ -1920,7 +1917,7 @@ NameSearchContext::AddVarDecl(const Comp
if (!type.IsValid())
return NULL;
- ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext* lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!lldb_ast)
return NULL;
@@ -1952,7 +1949,7 @@ NameSearchContext::AddFunDecl (const Com
if (m_function_types.count(type))
return NULL;
- ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext* lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!lldb_ast)
return NULL;
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep 8 13:15:05 2015
@@ -194,19 +194,23 @@ ClangExpressionDeclMap::AddPersistentVar
{
assert (m_parser_vars.get());
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(parser_type.GetTypeSystem());
+ if (ast == nullptr)
+ return false;
+
if (m_parser_vars->m_materializer && is_result)
{
Error err;
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
- if (target == NULL)
+ if (target == nullptr)
return false;
ClangASTContext *context(target->GetScratchClangASTContext());
TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
- parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
+ ast->getASTContext(),
parser_type.GetOpaqueQualType()),
context);
@@ -247,7 +251,7 @@ ClangExpressionDeclMap::AddPersistentVar
ClangASTContext *context(target->GetScratchClangASTContext());
TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
- parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
+ ast->getASTContext(),
parser_type.GetOpaqueQualType()),
context);
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Tue Sep 8 13:15:05 2015
@@ -423,13 +423,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl
if (!clang_type)
return return_valobj_sp;
-
- ClangASTContext* ast = clang_type.GetTypeSystem()->AsClangASTContext();
- clang::ASTContext *ast_context = ast ? ast->getASTContext() : nullptr;
- if (!ast_context)
- return return_valobj_sp;
- //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType());
value.SetCompilerType (clang_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Sep 8 13:15:05 2015
@@ -1597,8 +1597,7 @@ public:
bool
Finalize()
{
- ClangASTContext* ast = m_class_opaque_type.GetTypeSystem()->AsClangASTContext();
- assert(ast);
+ ClangASTContext *ast = llvm::cast<ClangASTContext>(m_class_opaque_type.GetTypeSystem());
return ast->AddObjCClassProperty (m_class_opaque_type,
m_property_name,
m_property_opaque_type,
@@ -2360,7 +2359,7 @@ DWARFASTParserClang::ParseChildMembers (
BitfieldInfo last_field_info;
ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
- ClangASTContext* ast = class_clang_type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
if (ast == nullptr)
return 0;
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 8 13:15:05 2015
@@ -285,7 +285,8 @@ ParseLangArgs (LangOptions &Opts, InputK
}
-ClangASTContext::ClangASTContext (const char *target_triple) :
+ClangASTContext::ClangASTContext (const char *target_triple) :
+ TypeSystem (TypeSystem::eKindClang),
m_target_triple (),
m_ast_ap (),
m_language_options_ap (),
@@ -1118,7 +1119,7 @@ ClangASTContext::CopyType (ASTContext *d
CompilerType src)
{
FileSystemOptions file_system_options;
- ClangASTContext *src_ast = src.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *src_ast = llvm::dyn_cast_or_null<ClangASTContext>(src.GetTypeSystem());
if (src_ast == nullptr)
return CompilerType();
FileManager file_manager (file_system_options);
@@ -1151,8 +1152,8 @@ ClangASTContext::AreTypesSame (CompilerT
CompilerType type2,
bool ignore_qualifiers)
{
- TypeSystem *ast = type1.GetTypeSystem();
- if (!ast->AsClangASTContext() || ast != type2.GetTypeSystem())
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type1.GetTypeSystem());
+ if (!ast || ast != type2.GetTypeSystem())
return false;
if (type1.GetOpaqueQualType() == type2.GetOpaqueQualType())
@@ -1167,7 +1168,7 @@ ClangASTContext::AreTypesSame (CompilerT
type2_qual = type2_qual.getUnqualifiedType();
}
- return ast->AsClangASTContext()->getASTContext()->hasSameType (type1_qual, type2_qual);
+ return ast->getASTContext()->hasSameType (type1_qual, type2_qual);
}
CompilerType
@@ -3767,19 +3768,21 @@ ClangASTContext::GetTypeQualifiers(void*
CompilerType
ClangASTContext::AddConstModifier (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ if (type && llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem()))
{
+ // Make sure this type is a clang AST type
clang::QualType result(GetQualType(type));
result.addConst();
return CompilerType (type.GetTypeSystem(), result.getAsOpaquePtr());
}
+
return CompilerType();
}
CompilerType
ClangASTContext::AddRestrictModifier (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ if (type && llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem()))
{
clang::QualType result(GetQualType(type));
result.getQualifiers().setRestrict (true);
@@ -3791,7 +3794,7 @@ ClangASTContext::AddRestrictModifier (co
CompilerType
ClangASTContext::AddVolatileModifier (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ if (type && llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem()))
{
clang::QualType result(GetQualType(type));
result.getQualifiers().setVolatile (true);
@@ -4094,7 +4097,7 @@ ClangASTContext::GetLValueReferenceType
{
if (type)
{
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (ast)
return CompilerType(ast->getASTContext(), ast->getASTContext()->getLValueReferenceType(GetQualType(type)));
}
@@ -4106,7 +4109,7 @@ ClangASTContext::GetRValueReferenceType
{
if (type)
{
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (ast)
return CompilerType(ast->getASTContext(), ast->getASTContext()->getRValueReferenceType(GetQualType(type)));
}
@@ -4128,7 +4131,7 @@ ClangASTContext::CreateTypedefType (cons
{
if (type && typedef_name && typedef_name[0])
{
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return CompilerType();
clang::ASTContext* clang_ast = ast->getASTContext();
@@ -4201,7 +4204,7 @@ ClangASTContext::GetTypedefedType (void*
CompilerType
ClangASTContext::RemoveFastQualifiers (const CompilerType& type)
{
- if (type && type.GetTypeSystem()->AsClangASTContext())
+ if (type && llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem()))
{
clang::QualType qual_type(GetQualType(type));
qual_type.getQualifiers().removeFastQualifiers();
@@ -6959,7 +6962,7 @@ ClangASTContext::AddFieldToRecordType (c
{
if (!type.IsValid() || !field_clang_type.IsValid())
return nullptr;
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return nullptr;
clang::ASTContext* clang_ast = ast->getASTContext();
@@ -7049,9 +7052,10 @@ ClangASTContext::AddFieldToRecordType (c
void
ClangASTContext::BuildIndirectFields (const CompilerType& type)
{
- ClangASTContext* ast = nullptr;
- if (type)
- ast = type.GetTypeSystem()->AsClangASTContext();
+ if (!type)
+ return;
+
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return;
@@ -7160,12 +7164,19 @@ ClangASTContext::BuildIndirectFields (co
void
ClangASTContext::SetIsPacked (const CompilerType& type)
{
- clang::RecordDecl *record_decl = GetAsRecordDecl(type);
+ if (type)
+ {
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
+ {
+ clang::RecordDecl *record_decl = GetAsRecordDecl(type);
- if (!record_decl)
- return;
+ if (!record_decl)
+ return;
- record_decl->addAttr(clang::PackedAttr::CreateImplicit(*type.GetTypeSystem()->AsClangASTContext()->getASTContext()));
+ record_decl->addAttr(clang::PackedAttr::CreateImplicit(*ast->getASTContext()));
+ }
+ }
}
clang::VarDecl *
@@ -7177,7 +7188,7 @@ ClangASTContext::AddVariableToRecordType
if (!type.IsValid() || !var_type.IsValid())
return nullptr;
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return nullptr;
@@ -7460,7 +7471,7 @@ ClangASTContext::SetBaseClassesForClassT
bool
ClangASTContext::SetObjCSuperClass (const CompilerType& type, const CompilerType &superclass_clang_type)
{
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return false;
clang::ASTContext* clang_ast = ast->getASTContext();
@@ -7490,7 +7501,7 @@ ClangASTContext::AddObjCClassProperty (c
{
if (!type || !property_clang_type.IsValid() || property_name == nullptr || property_name[0] == '\0')
return false;
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return false;
clang::ASTContext* clang_ast = ast->getASTContext();
@@ -7695,8 +7706,11 @@ ClangASTContext::AddMethodToObjCObjectTy
if (class_interface_decl == nullptr)
return nullptr;
- clang::ASTContext* ast = type.GetTypeSystem()->AsClangASTContext()->getASTContext();
-
+ ClangASTContext *lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (lldb_ast == nullptr)
+ return nullptr;
+ clang::ASTContext *ast = lldb_ast->getASTContext();
+
const char *selector_start = ::strchr (name, ' ');
if (selector_start == nullptr)
return nullptr;
@@ -7917,8 +7931,11 @@ ClangASTContext::CompleteTagDeclarationD
clang::QualType qual_type (GetQualType(type));
if (qual_type.isNull())
return false;
- clang::ASTContext* ast = type.GetTypeSystem()->AsClangASTContext()->getASTContext();
-
+ ClangASTContext *lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (lldb_ast == nullptr)
+ return false;
+ clang::ASTContext *ast = lldb_ast->getASTContext();
+
clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
if (cxx_record_decl)
@@ -8033,7 +8050,7 @@ ClangASTContext::CreateMemberPointerType
{
if (type && pointee_type.IsValid() && type.GetTypeSystem() == pointee_type.GetTypeSystem())
{
- ClangASTContext* ast = type.GetTypeSystem()->AsClangASTContext();
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return CompilerType();
return CompilerType (ast->getASTContext(),
@@ -8934,13 +8951,9 @@ ClangASTContext::DeclContextGetMetaData
clang::ASTContext *
ClangASTContext::DeclContextGetClangASTContext (const CompilerDeclContext &dc)
{
- TypeSystem *type_system = dc.GetTypeSystem();
- if (type_system)
- {
- ClangASTContext *ast = type_system->AsClangASTContext();
- if (ast)
- return ast->getASTContext();
- }
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(dc.GetTypeSystem());
+ if (ast)
+ return ast->getASTContext();
return nullptr;
}
Modified: lldb/trunk/source/Symbol/CompilerDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerDeclContext.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompilerDeclContext.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerDeclContext.cpp Tue Sep 8 13:15:05 2015
@@ -15,7 +15,7 @@ using namespace lldb_private;
bool
CompilerDeclContext::IsClang () const
{
- return IsValid() && m_type_system->AsClangASTContext() != nullptr;
+ return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
}
ConstString
Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=247041&r1=247040&r2=247041&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Tue Sep 8 13:15:05 2015
@@ -10,7 +10,8 @@
using namespace lldb_private;
-TypeSystem::TypeSystem() :
+TypeSystem::TypeSystem(LLVMCastKind kind) :
+ m_kind (kind),
m_sym_file (nullptr)
{
}
More information about the lldb-commits
mailing list