[DataFormatter] Add CFDictionary data formatter

Add data formatter for NSCFDictionary/CFDictionaryRef.

Differential revision: https://reviews.llvm.org/D48450

llvm-svn: 335271
This commit is contained in:
Jonas Devlieghere 2018-06-21 19:13:47 +00:00
parent 1763dbb278
commit 702e140d68
3 changed files with 13 additions and 2 deletions

View File

@ -225,7 +225,7 @@ class ObjCDataFormatterTestCase(TestBase):
def nscontainers_data_formatter_commands(self): def nscontainers_data_formatter_commands(self):
self.expect( self.expect(
'frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref',
substrs=[ substrs=[
'(NSArray *) newArray = ', '(NSArray *) newArray = ',
'@"50 elements"', '@"50 elements"',
@ -233,6 +233,10 @@ class ObjCDataFormatterTestCase(TestBase):
' 12 key/value pairs', ' 12 key/value pairs',
'(NSDictionary *) newMutableDictionary = ', '(NSDictionary *) newMutableDictionary = ',
' 21 key/value pairs', ' 21 key/value pairs',
'(NSDictionary *) nsDictionary = ',
' 2 key/value pairs',
'(CFDictionaryRef) cfDictionaryRef = ',
' 3 key/value pairs',
'(CFArrayRef) cfarray_ref = ', '(CFArrayRef) cfarray_ref = ',
'@"3 elements"', '@"3 elements"',
'(CFMutableArrayRef) mutable_array_ref = ', '(CFMutableArrayRef) mutable_array_ref = ',

View File

@ -385,6 +385,11 @@ int main (int argc, const char * argv[])
[newMutableDictionary setObject:@"foo" forKey:@"bar19"]; [newMutableDictionary setObject:@"foo" forKey:@"bar19"];
[newMutableDictionary setObject:@"foo" forKey:@"bar20"]; [newMutableDictionary setObject:@"foo" forKey:@"bar20"];
id cfKeys[2] = { @"foo", @"bar", @"baz", @"quux" };
id cfValues[2] = { @"foo", @"bar", @"baz", @"quux" };
NSDictionary *nsDictionary = CFBridgingRelease(CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil));
CFDictionaryRef cfDictionaryRef = CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 3, nil, nil);
NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];
[attrString isEqual:nil]; [attrString isEqual:nil];
NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];

View File

@ -397,6 +397,7 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable"); static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI"); static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_Dictionary0("__NSDictionary0"); static const ConstString g_Dictionary0("__NSDictionary0");
static const ConstString g_DictionaryCF("__NSCFDictionary");
if (class_name.IsEmpty()) if (class_name.IsEmpty())
return false; return false;
@ -408,7 +409,8 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
if (error.Fail()) if (error.Fail())
return false; return false;
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U); value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
} else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy) { } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy ||
class_name == g_DictionaryCF) {
AppleObjCRuntime *apple_runtime = AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime); llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error; Status error;