[Lldb-commits] [lldb] r216305 - Extend the encoding parser to support the @typeName syntax for Objective-C object types

Enrico Granata egranata at apple.com
Fri Aug 22 17:20:33 PDT 2014


Author: enrico
Date: Fri Aug 22 19:20:33 2014
New Revision: 216305

URL: http://llvm.org/viewvc/llvm-project?rev=216305&view=rev
Log:
Extend the encoding parser to support the @typeName syntax for Objective-C object types

Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp?rev=216305&r1=216304&r2=216305&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp Fri Aug 22 19:20:33 2014
@@ -37,7 +37,7 @@ AppleObjCTypeEncodingParser::ReadStructN
 }
 
 std::string
-AppleObjCTypeEncodingParser::ReadStructElementName(lldb_utility::StringLexer& type)
+AppleObjCTypeEncodingParser::ReadQuotedString(lldb_utility::StringLexer& type)
 {
     StreamString buffer;
     while (type.HasAtLeast(1) && type.Peek() != '"')
@@ -68,7 +68,7 @@ AppleObjCTypeEncodingParser::ReadStructE
 {
     StructElement retval;
     if (type.NextIf('"'))
-        retval.name = ReadStructElementName(type);
+        retval.name = ReadQuotedString(type);
     if (!type.NextIf('"'))
         return retval;
     uint32_t bitfield_size = 0;
@@ -159,6 +159,20 @@ AppleObjCTypeEncodingParser::BuildArray
     return array_type.GetQualType();
 }
 
+// the runtime can emit these in the form of @"SomeType", giving more specifics
+// this would be interesting for expression parser interop, but since we actually try
+// to avoid exposing the ivar info to the expression evaluator, consume but ignore the type info
+// and always return an 'id'; if anything, dynamic typing will resolve things for us anyway
+clang::QualType
+AppleObjCTypeEncodingParser::BuildObjCObjectType (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype)
+{
+    if (!type.NextIf('@'))
+        return clang::QualType();
+    if (type.NextIf('"'))
+        ReadQuotedString(type);
+    return ast_ctx.getObjCIdType();;
+}
+
 clang::QualType
 AppleObjCTypeEncodingParser::BuildType (clang::ASTContext &ast_ctx, StringLexer& type, bool allow_unknownanytype, uint32_t *bitfield_bit_size)
 {
@@ -205,8 +219,6 @@ AppleObjCTypeEncodingParser::BuildType (
         return ast_ctx.VoidTy;
     if (type.NextIf('*'))
         return ast_ctx.getPointerType(ast_ctx.CharTy);
-    if (type.NextIf('@'))
-        return ast_ctx.getObjCIdType();
     if (type.NextIf('#'))
         return ast_ctx.getObjCClassType();
     if (type.NextIf(':'))
@@ -258,6 +270,9 @@ AppleObjCTypeEncodingParser::BuildType (
     if (type.Peek() == '(')
         return BuildUnion(ast_ctx, type, allow_unknownanytype);
     
+    if (type.Peek() == '@')
+        return BuildObjCObjectType(ast_ctx, type, allow_unknownanytype);
+    
     return clang::QualType();
 }
 

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h?rev=216305&r1=216304&r2=216305&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h Fri Aug 22 19:20:33 2014
@@ -65,12 +65,14 @@ namespace lldb_private {
         StructElement
         ReadStructElement (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);
         
-        std::string
-        ReadStructElementName(lldb_utility::StringLexer& type);
+        clang::QualType
+        BuildObjCObjectType (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool allow_unknownanytype);
         
         uint32_t
         ReadNumber (lldb_utility::StringLexer& type);
-
+        
+        std::string
+        ReadQuotedString(lldb_utility::StringLexer& type);
     };
     
 } // namespace lldb_private





More information about the lldb-commits mailing list