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

llvm-svn: 219540
This commit is contained in:
Enrico Granata 2014-10-10 22:45:38 +00:00
parent 337f7c9716
commit 0aa6926d0b
1 changed files with 17 additions and 6 deletions

View File

@ -249,13 +249,24 @@ AppleObjCTypeEncodingParser::BuildType (clang::ASTContext &ast_ctx, StringLexer&
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('?'))