From 4c508df925dbb41b19317d4bb8871f6944114f0c Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Thu, 6 Nov 2014 19:26:10 +0000 Subject: [PATCH] Handle types from the runtime that conform to protocols. llvm-svn: 221476 --- .../AppleObjCTypeEncodingParser.cpp | 12 +++++++- .../objc/objc-ivar-protocols/TestIvarProtocols.py | 4 +++ lldb/test/lang/objc/objc-ivar-protocols/main.m | 33 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 lldb/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py create mode 100644 lldb/test/lang/objc/objc-ivar-protocols/main.m diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index d5dba66..9445fa5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -175,8 +175,18 @@ AppleObjCTypeEncodingParser::BuildObjCObjectPointerType (clang::ASTContext &ast_ if (type.NextIf('"')) name = ReadQuotedString(type); - if (for_expression && !name.empty() && name[0] != '<') + if (for_expression && !name.empty()) { + size_t less_than_pos = name.find_first_of('<'); + + if (less_than_pos != std::string::npos) + { + if (less_than_pos == 0) + return ast_ctx.getObjCIdType(); + else + name.erase(less_than_pos); + } + TypeVendor *type_vendor = m_runtime.GetTypeVendor(); assert (type_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play? diff --git a/lldb/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py b/lldb/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py new file mode 100644 index 0000000..356979f --- /dev/null +++ b/lldb/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py @@ -0,0 +1,4 @@ +import lldbinline +import lldbtest + +lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) diff --git a/lldb/test/lang/objc/objc-ivar-protocols/main.m b/lldb/test/lang/objc/objc-ivar-protocols/main.m new file mode 100644 index 0000000..aa6c471 --- /dev/null +++ b/lldb/test/lang/objc/objc-ivar-protocols/main.m @@ -0,0 +1,33 @@ +#import + +@protocol MyProtocol +-(void)aMethod; +@end + +@interface MyClass : NSObject { + id myId; + NSObject *myObject; +}; + +-(void)doSomething; + +@end + +@implementation MyClass + +-(void)doSomething +{ + NSLog(@"Hello"); //% self.expect("expression -- myId", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["id"]); + //% self.expect("expression -- myObject", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["NSObject"]); +} + +@end + +int main () +{ + @autoreleasepool + { + MyClass *c = [MyClass alloc]; + [c doSomething]; + } +} -- 2.7.4