diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
commit | ead246455adf1a215ec2715dad6533073a6beb4e (patch) | |
tree | f3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Plugins/Language/ObjC | |
parent | fdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff) |
Notes
Diffstat (limited to 'source/Plugins/Language/ObjC')
-rw-r--r-- | source/Plugins/Language/ObjC/CoreMedia.cpp | 20 | ||||
-rw-r--r-- | source/Plugins/Language/ObjC/NSArray.cpp | 26 | ||||
-rw-r--r-- | source/Plugins/Language/ObjC/NSDictionary.h | 4 | ||||
-rw-r--r-- | source/Plugins/Language/ObjC/NSString.cpp | 22 | ||||
-rw-r--r-- | source/Plugins/Language/ObjC/ObjCLanguage.cpp | 1 |
5 files changed, 40 insertions, 33 deletions
diff --git a/source/Plugins/Language/ObjC/CoreMedia.cpp b/source/Plugins/Language/ObjC/CoreMedia.cpp index d19290ec56fb..247429da1b06 100644 --- a/source/Plugins/Language/ObjC/CoreMedia.cpp +++ b/source/Plugins/Language/ObjC/CoreMedia.cpp @@ -10,6 +10,7 @@ #include "CoreMedia.h" #include "lldb/Utility/Flags.h" +#include "lldb/Utility/Log.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/Target.h" @@ -25,18 +26,21 @@ bool lldb_private::formatters::CMTimeSummaryProvider( if (!type.IsValid()) return false; - TypeSystem *type_system = + auto type_system_or_err = valobj.GetExecutionContextRef() .GetTargetSP() - ->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC); - if (!type_system) + ->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC); + if (auto err = type_system_or_err.takeError()) { + LLDB_LOG_ERROR( + lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS), + std::move(err), "Failed to get scratch type system"); return false; - + } // fetch children by offset to compensate for potential lack of debug info - auto int64_ty = - type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64); - auto int32_ty = - type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 32); + auto int64_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize( + eEncodingSint, 64); + auto int32_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize( + eEncodingSint, 32); auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true)); auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty, true)); diff --git a/source/Plugins/Language/ObjC/NSArray.cpp b/source/Plugins/Language/ObjC/NSArray.cpp index 404dabf2870c..7219c016dfd1 100644 --- a/source/Plugins/Language/ObjC/NSArray.cpp +++ b/source/Plugins/Language/ObjC/NSArray.cpp @@ -461,12 +461,13 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontE : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8), m_id_type() { if (valobj_sp) { - clang::ASTContext *ast = valobj_sp->GetExecutionContextRef() - .GetTargetSP() - ->GetScratchClangASTContext() - ->getASTContext(); - if (ast) - m_id_type = CompilerType(ast, ast->ObjCBuiltinIdTy); + auto *clang_ast_context = valobj_sp->GetExecutionContextRef() + .GetTargetSP() + ->GetScratchClangASTContext(); + if (clang_ast_context) + m_id_type = CompilerType( + clang_ast_context, + clang_ast_context->getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr()); if (valobj_sp->GetProcessSP()) m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize(); } @@ -609,12 +610,13 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: if (valobj_sp) { 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); + auto *clang_ast_context = valobj_sp->GetExecutionContextRef() + .GetTargetSP() + ->GetScratchClangASTContext(); + if (clang_ast_context) + m_id_type = CompilerType(clang_ast_context, + clang_ast_context->getASTContext() + ->ObjCBuiltinIdTy.getAsOpaquePtr()); } } } diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h index ecb3fccdf877..44d56f9c2c68 100644 --- a/source/Plugins/Language/ObjC/NSDictionary.h +++ b/source/Plugins/Language/ObjC/NSDictionary.h @@ -68,10 +68,10 @@ public: }; typedef Matcher::UP MatcherUP; - MatcherUP GetFullMatch(ConstString n) { return llvm::make_unique<Full>(n); } + MatcherUP GetFullMatch(ConstString n) { return std::make_unique<Full>(n); } MatcherUP GetPrefixMatch(ConstString p) { - return llvm::make_unique<Prefix>(p); + return std::make_unique<Prefix>(p); } }; diff --git a/source/Plugins/Language/ObjC/NSString.cpp b/source/Plugins/Language/ObjC/NSString.cpp index 4800c955e5f5..55e129b098dc 100644 --- a/source/Plugins/Language/ObjC/NSString.cpp +++ b/source/Plugins/Language/ObjC/NSString.cpp @@ -78,12 +78,12 @@ bool lldb_private::formatters::NSStringSummaryProvider( return false; ConstString class_name_cs = descriptor->GetClassName(); - const char *class_name = class_name_cs.GetCString(); + llvm::StringRef class_name = class_name_cs.GetStringRef(); - if (!class_name || !*class_name) + if (class_name.empty()) return false; - bool is_tagged_ptr = (0 == strcmp(class_name, "NSTaggedPointerString")) && + bool is_tagged_ptr = class_name == "NSTaggedPointerString" && descriptor->GetTaggedPointerInfo(); // for a tagged pointer, the descriptor has everything we need if (is_tagged_ptr) @@ -111,7 +111,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( bool is_inline = (info_bits & 0x60) == 0; bool has_explicit_length = (info_bits & (1 | 4)) != 4; bool is_unicode = (info_bits & 0x10) == 0x10; - bool is_path_store = strcmp(class_name, "NSPathStore2") == 0; + bool is_path_store = class_name == "NSPathStore2"; bool has_null = (info_bits & 8) == 8; size_t explicit_length = 0; @@ -135,14 +135,14 @@ bool lldb_private::formatters::NSStringSummaryProvider( } } - if (strcmp(class_name, "NSString") && strcmp(class_name, "CFStringRef") && - strcmp(class_name, "CFMutableStringRef") && - strcmp(class_name, "__NSCFConstantString") && - strcmp(class_name, "__NSCFString") && - strcmp(class_name, "NSCFConstantString") && - strcmp(class_name, "NSCFString") && strcmp(class_name, "NSPathStore2")) { + const llvm::StringSet<> supported_string_classes = { + "NSString", "CFMutableStringRef", + "CFStringRef", "__NSCFConstantString", + "__NSCFString", "NSCFConstantString", + "NSCFString", "NSPathStore2"}; + if (supported_string_classes.count(class_name) == 0) { // not one of us - but tell me class name - stream.Printf("class name = %s", class_name); + stream.Printf("class name = %s", class_name_cs.GetCString()); return true; } diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp index f9ab18688de7..c5bfb5747c13 100644 --- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/Threading.h" +#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" #include "CF.h" |