diff options
| author | Enrico Granata <egranata@apple.com> | 2012-12-13 23:50:33 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2012-12-13 23:50:33 +0000 |
| commit | 9e7b388589b19f859ce6e6e53886958c707a504e (patch) | |
| tree | 4dcaac05be2e66742901ebfbe6c9dc77a462e3f6 /lldb/source | |
| parent | f5f4d2fd2e47463276a310dc5164dfbcdb582f1c (diff) | |
| download | bcm5719-llvm-9e7b388589b19f859ce6e6e53886958c707a504e.tar.gz bcm5719-llvm-9e7b388589b19f859ce6e6e53886958c707a504e.zip | |
<rdar://problem/11689939>
Supporting a compact display syntax for ObjC pointers where 0x00.....0 is replaced by a much more legible "nil"
e.g. this would show:
(NSArray *) $2 = nil
instead of:
(NSArray *) $2 = 0x0000000000000000 <nil>
llvm-svn: 170161
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index c24c8bb6aaf..2a597b344c7 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1823,6 +1823,15 @@ ValueObject::IsPossibleDynamicType () return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType(), NULL, true, true); } +bool +ValueObject::IsObjCNil () +{ + bool isObjCpointer = ClangASTContext::IsObjCObjectPointerType(GetClangType(), NULL); + bool canReadValue = true; + bool isZero = GetValueAsUnsigned(0,&canReadValue) == 0; + return canReadValue && isZero && isObjCpointer; +} + ValueObjectSP ValueObject::GetSyntheticArrayMember (int32_t index, bool can_create) { @@ -3308,6 +3317,8 @@ DumpValueObject_Impl (Stream &s, if (options.m_omit_summary_depth > 0) entry = NULL; + bool is_nil = valobj->IsObjCNil(); + if (err_cstr == NULL) { if (options.m_format != eFormatDefault && options.m_format != valobj->GetFormat()) @@ -3333,7 +3344,9 @@ DumpValueObject_Impl (Stream &s, const bool is_ref = type_flags.Test (ClangASTContext::eTypeIsReference); if (print_valobj) { - if (options.m_omit_summary_depth == 0) + if (is_nil) + sum_cstr = "nil"; + else if (options.m_omit_summary_depth == 0) { if (options.m_summary_sp) { @@ -3345,14 +3358,16 @@ DumpValueObject_Impl (Stream &s, } // Make sure we have a value and make sure the summary didn't - // specify that the value should not be printed - if (!value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL)) + // specify that the value should not be printed - and do not print + // the value if this thing is nil + if (!is_nil && !value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL)) s.Printf(" %s", value_str.c_str()); if (sum_cstr) s.Printf(" %s", sum_cstr); - if (options.m_use_objc) + // let's avoid the overly verbose no description error for a nil thing + if (options.m_use_objc && !is_nil) { const char *object_desc = valobj->GetObjectDescription(); if (object_desc) |

