diff options
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangASTContext.h | 4 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/TypeSystem.h | 6 | ||||
| -rw-r--r-- | lldb/include/lldb/Target/Target.h | 8 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/CoreMedia.cpp | 10 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/VectorType.cpp | 57 | ||||
| -rw-r--r-- | lldb/source/Target/Target.cpp | 21 |
6 files changed, 72 insertions, 34 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 22a4814a857..9a96e0a99cd 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -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); } diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 655107bafd5..a5d25f99f0d 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -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; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index d624f7520cd..14e9a760c08 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -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(); diff --git a/lldb/source/DataFormatters/CoreMedia.cpp b/lldb/source/DataFormatters/CoreMedia.cpp index 21dd11f0ca3..7be6f9a02a3 100644 --- a/lldb/source/DataFormatters/CoreMedia.cpp +++ b/lldb/source/DataFormatters/CoreMedia.cpp @@ -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::CMTimeSummaryProvider (ValueObject& valobj, Stream& st 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)); diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index b01d89050fb..faef33de909 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -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 format, 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, diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index d58df596b4d..c3d342e003a 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1906,6 +1906,27 @@ Target::GetScratchClangASTContext(bool create_on_demand) 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() { |

