Author: enrico Date: Tue Sep 8 17:09:19 2015 New Revision: 247082 URL: http://llvm.org/viewvc/llvm-project?rev=247082&view=rev Log: Implement a Target::GetTypeSystemForLanguage API, as well as provide helpers on the TypeSystem to get numeric types of specific sizes and signedness
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/TypeSystem.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/DataFormatters/CoreMedia.cpp lldb/trunk/source/DataFormatters/VectorType.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Sep 8 17:09:19 2015 @@ -454,7 +454,7 @@ public: //------------------------------------------------------------------ CompilerType - GetIntTypeFromBitSize (size_t bit_size, bool is_signed) + GetIntTypeFromBitSize (size_t bit_size, bool is_signed) override { return GetIntTypeFromBitSize (getASTContext(), bit_size, is_signed); } @@ -477,7 +477,7 @@ public: //------------------------------------------------------------------ CompilerType - GetFloatTypeFromBitSize (size_t bit_size) + GetFloatTypeFromBitSize (size_t bit_size) override { return GetFloatTypeFromBitSize (getASTContext(), bit_size); } Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original) +++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Tue Sep 8 17:09:19 2015 @@ -400,6 +400,12 @@ public: virtual CompilerType GetBasicTypeFromAST (lldb::BasicType basic_type) = 0; + virtual CompilerType + GetIntTypeFromBitSize (size_t bit_size, bool is_signed) = 0; + + virtual CompilerType + GetFloatTypeFromBitSize (size_t bit_size) = 0; + virtual bool IsBeingDefined (void *type) = 0; Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 8 17:09:19 2015 @@ -1230,6 +1230,14 @@ public: ClangASTContext * GetScratchClangASTContext(bool create_on_demand=true); + TypeSystem* + GetTypeSystemForLanguage (lldb::LanguageType language); + + CompilerType + GetBasicType (lldb::LanguageType language, + lldb::BasicType basic_type, + size_t size = 0); + ClangASTImporter * GetClangASTImporter(); Modified: lldb/trunk/source/DataFormatters/CoreMedia.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CoreMedia.cpp?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/CoreMedia.cpp (original) +++ lldb/trunk/source/DataFormatters/CoreMedia.cpp Tue Sep 8 17:09:19 2015 @@ -10,7 +10,7 @@ #include "lldb/DataFormatters/CoreMedia.h" #include "lldb/Core/Flags.h" -#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/Target.h" #include <inttypes.h> @@ -25,13 +25,13 @@ lldb_private::formatters::CMTimeSummaryP if (!type.IsValid()) return false; - ClangASTContext *ast_ctx = valobj.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext(); - if (!ast_ctx) + TypeSystem *type_system = valobj.GetExecutionContextRef().GetTargetSP()->GetTypeSystemForLanguage(lldb::eLanguageTypeC); + if (!type_system) return false; // fetch children by offset to compensate for potential lack of debug info - auto int64_ty = ast_ctx->GetIntTypeFromBitSize(64, true); - auto int32_ty = ast_ctx->GetIntTypeFromBitSize(32, true); + auto int64_ty = type_system->GetIntTypeFromBitSize(64, true); + auto int32_ty = type_system->GetIntTypeFromBitSize(32, true); auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true)); auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty, true)); Modified: lldb/trunk/source/DataFormatters/VectorType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/VectorType.cpp (original) +++ lldb/trunk/source/DataFormatters/VectorType.cpp Tue Sep 8 17:09:19 2015 @@ -11,8 +11,8 @@ #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/FormattersHelpers.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompilerType.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Utility/LLDBAssert.h" @@ -22,85 +22,85 @@ using namespace lldb_private::formatters static CompilerType GetCompilerTypeForFormat (lldb::Format format, - CompilerType element_type, - ClangASTContext *ast_ctx) + 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->GetIntTypeFromBitSize(8*type_system->GetPointerByteSize(), false); 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->GetFloatTypeFromBitSize(32); case lldb::eFormatVectorOfFloat64: - return ast_ctx->GetFloatTypeFromBitSize(64); + return type_system->GetFloatTypeFromBitSize(64); case lldb::eFormatVectorOfSInt16: - return ast_ctx->GetIntTypeFromBitSize(16, true); + return type_system->GetIntTypeFromBitSize(16, true); case lldb::eFormatVectorOfSInt32: - return ast_ctx->GetIntTypeFromBitSize(32, true); + return type_system->GetIntTypeFromBitSize(32, true); case lldb::eFormatVectorOfSInt64: - return ast_ctx->GetIntTypeFromBitSize(64, true); + return type_system->GetIntTypeFromBitSize(64, true); case lldb::eFormatVectorOfSInt8: - return ast_ctx->GetIntTypeFromBitSize(8, true); + return type_system->GetIntTypeFromBitSize(8, true); case lldb::eFormatVectorOfUInt128: - return ast_ctx->GetIntTypeFromBitSize(128, false); + return type_system->GetIntTypeFromBitSize(128, false); case lldb::eFormatVectorOfUInt16: - return ast_ctx->GetIntTypeFromBitSize(16, false); + return type_system->GetIntTypeFromBitSize(16, false); case lldb::eFormatVectorOfUInt32: - return ast_ctx->GetIntTypeFromBitSize(32, false); + return type_system->GetIntTypeFromBitSize(32, false); case lldb::eFormatVectorOfUInt64: - return ast_ctx->GetIntTypeFromBitSize(64, false); + return type_system->GetIntTypeFromBitSize(64, false); case lldb::eFormatVectorOfUInt8: - return ast_ctx->GetIntTypeFromBitSize(8, false); + return type_system->GetIntTypeFromBitSize(8, false); case lldb::eFormatDefault: return element_type; @@ -113,7 +113,7 @@ GetCompilerTypeForFormat (lldb::Format f case lldb::eFormatOSType: case lldb::eFormatVoid: default: - return ast_ctx->GetIntTypeFromBitSize(8, false); + return type_system->GetIntTypeFromBitSize(8, false); } } @@ -232,7 +232,10 @@ 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, llvm::dyn_cast_or_null<ClangASTContext>(parent_type.GetTypeSystem())); + TargetSP target_sp(m_backend.GetTargetSP()); + m_child_type = ::GetCompilerTypeForFormat(m_parent_format, + element_type, + target_sp ? target_sp->GetTypeSystemForLanguage(lldb::eLanguageTypeC) : nullptr); m_num_children = ::CalculateNumChildren(parent_type, m_child_type); m_item_format = GetItemFormatForFormat(m_parent_format, Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=247082&r1=247081&r2=247082&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 8 17:09:19 2015 @@ -1906,6 +1906,27 @@ Target::GetScratchClangASTContext(bool c return m_scratch_ast_context_ap.get(); } +TypeSystem* +Target::GetTypeSystemForLanguage (lldb::LanguageType language) +{ + switch (language) + { + case lldb::eLanguageTypeC: + case lldb::eLanguageTypeC11: + case lldb::eLanguageTypeC89: + case lldb::eLanguageTypeC99: + case lldb::eLanguageTypeC_plus_plus: + case lldb::eLanguageTypeC_plus_plus_03: + case lldb::eLanguageTypeC_plus_plus_11: + case lldb::eLanguageTypeC_plus_plus_14: + case lldb::eLanguageTypeObjC: + case lldb::eLanguageTypeObjC_plus_plus: + return GetScratchClangASTContext(true); + default: + return nullptr; + } +} + ClangASTImporter * Target::GetClangASTImporter() { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits