summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/ValueObject.h3
-rw-r--r--lldb/source/Core/ValueObject.cpp23
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py2
-rw-r--r--lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py2
4 files changed, 24 insertions, 6 deletions
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 9ca60e502ce..ae57ac88f45 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -613,6 +613,9 @@ public:
IsPossibleDynamicType ();
virtual bool
+ IsObjCNil ();
+
+ virtual bool
IsBaseClass ()
{
return false;
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)
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
index 9f8877f57d1..1c45e76421b 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
+++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
@@ -380,7 +380,7 @@ class ObjCDataFormatterTestCase(TestBase):
self.expect('frame variable myclass4',
substrs = ['(Class) myclass4 = NSMutableArray'])
self.expect('frame variable myclass5',
- substrs = ['(Class) myclass5 = <error: unknown Class>'])
+ substrs = ['(Class) myclass5 = nil'])
def expr_objc_data_formatter_commands(self):
diff --git a/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
index 427193adf5f..e0ebee67b1f 100644
--- a/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -62,7 +62,7 @@ class TestObjCBuiltinTypes(TestBase):
self.expect("expr (foo)", patterns = ["\(ns::id\) \$.* = 0"])
- self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = 0x0"])
+ self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = nil"])
if __name__ == '__main__':
import atexit
OpenPOWER on IntegriCloud