diff options
author | Enrico Granata <egranata@apple.com> | 2015-11-10 22:39:15 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-11-10 22:39:15 +0000 |
commit | 608d67c1520b9dd960f69a9137aab1ad78daae10 (patch) | |
tree | f0d99348e90f903d4824e614bd3bc7d9c8c67a2c /lldb/source/Plugins/Language/ObjC | |
parent | 467ab052916ca820eb0332ec499446640b7e0d48 (diff) | |
download | bcm5719-llvm-608d67c1520b9dd960f69a9137aab1ad78daae10.tar.gz bcm5719-llvm-608d67c1520b9dd960f69a9137aab1ad78daae10.zip |
Introduce a way for Languages to specify whether values of "reference types" are "nil" (not pointing to anything) or uninitialized (never made to point at anything)
This latter determination may or may not be possible on a per-language basis; and neither is mandatory to implement for any language
Use this knowledge in the ValueObjectPrinter to generalize the notion of IsObjCNil() and the respective printout
llvm-svn: 252663
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC')
-rw-r--r-- | lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Plugins/Language/ObjC/ObjCLanguage.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index e8d008c00a6..1cec6269029 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -863,3 +863,15 @@ ObjCLanguage::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hi return false; } + +bool +ObjCLanguage::IsNilReference (ValueObject& valobj) +{ + const uint32_t mask = eTypeIsObjC | eTypeIsPointer; + bool isObjCpointer = (((valobj.GetCompilerType().GetTypeInfo(nullptr)) & mask) == mask); + if (!isObjCpointer) + return false; + bool canReadValue = true; + bool isZero = valobj.GetValueAsUnsigned(0,&canReadValue) == 0; + return canReadValue && isZero; +} diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index 0f96ff8601d..e30aa18c044 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -153,6 +153,9 @@ public: GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint, std::string& prefix, std::string& suffix) override; + bool + IsNilReference (ValueObject& valobj) override; + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ |