[Lldb-commits] [lldb] r219540 - When parsing ObjC types from encoded strings (and disallowing any-type), the ^? combination gets resolved to no type, while we could resolve it to void*

Enrico Granata egranata at apple.com
Fri Oct 10 15:45:38 PDT 2014


Author: enrico
Date: Fri Oct 10 17:45:38 2014
New Revision: 219540

URL: http://llvm.org/viewvc/llvm-project?rev=219540&view=rev
Log:
When parsing ObjC types from encoded strings (and disallowing any-type), the ^? combination gets resolved to no type, while we could resolve it to void*
I don't think on any of the platforms where ObjC matters sizeof(T*) depends on T, so even if we never figured out the pointee type, the pointer type should still be sane
This might also allow some limited inspection where previously none was possible, so a win


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

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=219540&r1=219539&r2=219540&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp Fri Oct 10 17:45:38 2014
@@ -249,13 +249,24 @@ AppleObjCTypeEncodingParser::BuildType (
     
     if (type.NextIf('^'))
     {
-        clang::QualType target_type = BuildType(ast_ctx, type, allow_unknownanytype);
-        if (target_type.isNull())
-            return clang::QualType();
-        else if (target_type == ast_ctx.UnknownAnyTy)
-            return ast_ctx.UnknownAnyTy;
+        if (!allow_unknownanytype && type.NextIf('?'))
+        {
+            // if we are not supporting the concept of unknownAny, but what is being created here is an unknownAny*, then
+            // we can just get away with a void*
+            // this is theoretically wrong (in the same sense as 'theoretically nothing exists') but is way better than outright failure
+            // in many practical cases
+            return ast_ctx.VoidPtrTy;
+        }
         else
-            return ast_ctx.getPointerType(target_type);
+        {
+            clang::QualType target_type = BuildType(ast_ctx, type, allow_unknownanytype);
+            if (target_type.isNull())
+                return clang::QualType();
+            else if (target_type == ast_ctx.UnknownAnyTy)
+                return ast_ctx.UnknownAnyTy;
+            else
+                return ast_ctx.getPointerType(target_type);
+        }
     }
     
     if (type.NextIf('?'))





More information about the lldb-commits mailing list