diff options
author | Enrico Granata <egranata@apple.com> | 2014-08-23 00:20:33 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2014-08-23 00:20:33 +0000 |
commit | e3eface17ac15ff3818e76e4fcadef5afad92f2a (patch) | |
tree | 5e98296872e7f0ac79fd5b902f4559f705eaabcf | |
parent | 3ee335a762a667975fec726344b4129876e05331 (diff) | |
download | bcm5719-llvm-e3eface17ac15ff3818e76e4fcadef5afad92f2a.tar.gz bcm5719-llvm-e3eface17ac15ff3818e76e4fcadef5afad92f2a.zip |
Extend the encoding parser to support the @typeName syntax for Objective-C object types
llvm-svn: 216305
2 files changed, 24 insertions, 7 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index d4e21b3a62c..99d77ef5a16 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -37,7 +37,7 @@ AppleObjCTypeEncodingParser::ReadStructName(lldb_utility::StringLexer& type) } 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::ReadStructElement (clang::ASTContext &ast_ctx, lldb { 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 (clang::ASTContext &ast_ctx, lldb_utilit 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 (clang::ASTContext &ast_ctx, StringLexer& 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 (clang::ASTContext &ast_ctx, StringLexer& if (type.Peek() == '(') return BuildUnion(ast_ctx, type, allow_unknownanytype); + if (type.Peek() == '@') + return BuildObjCObjectType(ast_ctx, type, allow_unknownanytype); + return clang::QualType(); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h index 39ba5f9bede..1a211d88a87 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h @@ -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 |